ModuleDependency.artifact() not working with 2.0 nightly

(Nikita Salnikov-Tarnovski) #1

I have dependency declaration in build file as follows:

accept('eu.plumbr:agent:' + version) {
    artifact {
      name = 'plumbr-test'
      type = 'jar'

This works fine with gradle 1.11 and 1.12, but current 2.0 nightly gives me:

08:10:08.909 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Sending request: HEAD /artifactory/repo/eu/plumbr/agent/B3194/agent-B3194.jar HTTP/1.1
08:10:08.910 [DEBUG] [org.apache.http.headers] >> HEAD /artifactory/repo/eu/plumbr/agent/B3194/agent-B3194.jar HTTP/1.1
08:10:08.910 [DEBUG] [org.apache.http.headers] >> Accept-Encoding: gzip,deflate
08:10:08.911 [DEBUG] [org.apache.http.headers] >> Host:
08:10:08.912 [DEBUG] [org.apache.http.headers] >> Connection: Keep-Alive
08:10:08.912 [DEBUG] [org.apache.http.headers] >> User-Agent: Gradle/2.0-20140513031510+0000 (Mac OS X;10.9.2;x86_64) (Oracle Corporation;1.8.0;25.0-b70)
08:10:08.913 [DEBUG] [org.apache.http.headers] >> Authorization: Basic cGx1bWJyOi0uMEFZMz1uWkRaJA==
08:10:08.983 [DEBUG] [org.apache.http.impl.conn.DefaultClientConnection] Receiving response: HTTP/1.1 404 Not Found
08:10:08.983 [DEBUG] [org.apache.http.headers] << HTTP/1.1 404 Not Found
08:10:08.984 [DEBUG] [org.apache.http.headers] << Server: nginx/1.4.7
08:10:08.984 [DEBUG] [org.apache.http.headers] << Date: Tue, 13 May 2014 05:10:08 GMT
08:10:08.984 [DEBUG] [org.apache.http.headers] << Content-Type: text/html;charset=utf-8
08:10:08.985 [DEBUG] [org.apache.http.headers] << Content-Length: 995
08:10:08.985 [DEBUG] [org.apache.http.headers] << Connection: keep-alive
08:10:08.985 [DEBUG] [org.apache.http.headers] << X-Artifactory-Id: 6fab8db6575524e8:-5d57b9fc:145e0289e73:-8000
08:10:08.986 [DEBUG] [org.apache.http.impl.client.SystemDefaultHttpClient] Connection can be kept alive indefinitely
08:10:08.986 [DEBUG] [org.apache.http.impl.client.SystemDefaultHttpClient] Authentication succeeded
08:10:08.987 [DEBUG] [org.apache.http.impl.client.TargetAuthenticationStrategy] Caching 'basic' auth scheme for
08:10:08.987 [DEBUG] [org.apache.http.impl.conn.PoolingClientConnectionManager] Connection [id: 15][route: {}->] can be kept alive indefinitely
08:10:08.987 [DEBUG] [org.apache.http.impl.conn.PoolingClientConnectionManager] Connection released: [id: 15][route: {}->][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
08:10:08.988 [INFO] [org.gradle.internal.resource.transport.http.HttpClientHelper] Resource missing. [HTTP HEAD:]
08:10:08.988 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'eu.plumbr:agent:B3194' in repository 'maven'.
08:10:08.988 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.DefaultModuleMetaDataCache] Recording absence of module descriptor in cache: eu.plumbr:agent:B3194 [changing = false]
08:10:08.989 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.ResolvedConfigurationDependencyGraphVisitor] Attaching :plumbr-acceptance:B3194(accept) to its parents.
08:10:08.990 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in /private/var/folders/cp/yn7c3w916551mjyjr0n80t8m0000gn/T/gradle2831932390490250168.bin. Wrote root :plumbr-acceptance:B3194:accept.
08:10:08.991 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.result.StreamingResolutionResultBuilder$RootFactory] Loaded resolution results (0.0 secs) from Binary store in /private/var/folders/cp/yn7c3w916551mjyjr0n80t8m0000gn/T/gradle3771921613145207079.bin (exist: true)
08:10:08.991 [QUIET] [org.gradle.api.tasks.diagnostics.DependencyReportTask_Decorated] \--- eu.plumbr:agent:B3194 FAILED
08:10:08.992 [QUIET] [org.gradle.api.tasks.diagnostics.DependencyReportTask_Decorated]

So it ignores artefact name completely.

(Nikita Salnikov-Tarnovski) #2

Still does not work with latest nightly 2.1 :frowning:

(Peter Niederwieser) #3

Where did you get this from? I’m not sure if it was ever officially supported.

(Nikita Salnikov-Tarnovski) #4

There is an example here:

//configuring dependency on 'someLib' module
  compile(group: 'org.myorg', name: 'someLib', version:'1.0') {
    //explicitly adding the dependency artifact:
    artifact {
      //useful when some artifact properties unconventional
      name = 'someArtifact' //artifact name different than module name
      extension = 'someExt'
      type = 'someType'
      classifier = 'someClassifier'

and javadoc here:

(Peter Niederwieser) #5

Thanks for the pointers. ‘DependencyArtifact’ is a read-only interface, and above code is mutating private fields of the interface implementation. But since this made its way into the DSL reference, we’ll investigate. Raised GRADLE-3092.

(Nikita Salnikov-Tarnovski) #6

Wow :slight_smile: Thanks.

But it is really nice to have some way to specify the exact name of artefact, if it differs from module name. E.g. in case of multiple artefacts per module.

(Nikita Salnikov-Tarnovski) #7

Is there any workaround to achieve the desired functionality? To get the artefact with specific name.

(Peter Niederwieser) #8

You’d have to explain in more detail why you need this. Maven dependency resolution doesn’t support artifacts with arbitrary names.