Maven-publish generating incomplete maven-metadata.xml

my build.gradle looks roughly like this:

apply plugin: 'maven-publish'
  ...
  task sourcesJar(type: Jar) {
    classifier = 'sources'
    from sourceSets.main.allJava
}
  task testsJar(type: Jar) {
    classifier = 'tests'
    from sourceSets.test.output
}
  task javadocJar(type: Jar) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}
  publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
              artifact sourcesJar
            artifact testsJar
            artifact javadocJar
        }
    }
    repositories {
        maven {
            url ...
            credentials { ... }
                 }
    }
}

When I use ‘gradle publish’ the plugin uploads all four generated JARs and the POM to the specified URL, but it looks like the generated maven-metadata.xml file is incomplete. When I deploy the project via Maven there is a ‘’ element in ‘metadata.versioning’ that lists all the uploaded artifacts, but that element doesn’t exist when I deploy via the maven-publish gradle plugin.

e.g.

<snapshotVersion>
<classifier>tests</classifier>
<extension>jar</extension>
<value>0.0.1-20140505.143439-4</value>
<updated>20140505143439</updated>
</snapshotVersion>

This is no problem when your only dependency in another project is the main jar, but if you have a dependency on the tests.jar gradle will complain that it can’t resolve the dependency, because the tests.jar is not mentioned in the metadata.

Has anyone experienced similar issues? Is there a workaround? Is that simply not implemented yet? Any ideas how to resolve this?

What exactly isn’t working? Can you show a concrete dependency declaration and the expected/actual outcome?

I wish I could… Just when I tried to copy-paste the exact error message the build suddenly worked. I assume that the maven/gradle caches still had an index without the additional tests.jar and one of my attempts to clear/ignore the caches has been successful. Sorry for the inconvenience and thanks for the fast reply.

For reference, this was the declared dependency:

testCompile 'abc:xyz:0.0.1-SNAPSHOT:tests'

and when executing ‘gradle test’ or ‘gradle build’ it was complaining that the dependency could not be resolved.

I just found the old output in my console buffer:

FAILURE: Build failed with an exception.
  * What went wrong:
Could not resolve all dependencies for configuration ':testCompile'.
> Could not download artifact 'abc:xyz:0.0.1-SNAPSHOT:xyz-tests.jar'
   > Artifact 'abc:xyz:0.0.1-SNAPSHOT:xyz-tests.jar' not found.

As said above, I suspect that there was a caching issue that caused my initial problem.