Javadoc archive doesn't get published to Maven


(Scott Palmer) #1

I am using the older ‘maven’ plugin because ‘maven-publish’ doesn’t work with the release plugin (townsfolk)

I create three archives. The main jar, a zip file containing an XML schema, and a jar with javadocs. The main jar and the schema zip are uploaded, but the javadocs are not. Unless I force it, the javadocs jar isn’t even created before the uploadArchives task runs. I find it odd that my “schemaZip” is included,but my javadocJar" is not.

The relevant gradle code looks like this:

configurations {

xjc

schema

javadocs

}

task schemaZip(type: Zip, dependsOn: schemaGen) {

from ‘build/Schemas’

include ‘*.xsd’

classifier ‘schema’

}

task javadocJar(type: Jar, dependsOn: javadoc) {

from javadoc.destinationDir

classifier ‘javadoc’

}

artifacts {

schema schemaZip

javadocs javadocJar

}

uploadArchives {

repositories {

mavenDeployer {

snapshotRepository(url: “http://dcm-maven-repo/libs-snapshot-local”)

repository(url: “http://dcm-maven-repo/libs-release-local”)

}

}

}

uploadArchives.dependsOn javadocJar


(Scott Palmer) #2

Figured it out. uploadArchives doesn’t upload “artifacts” it only uploads what is added to the “archives” configuration. Apparently the Zip task type adds the output to the “archives” configuration automatically, but the Jar task type doesn’t???

Adding:

artifacts {

schema schemaJar

javadocs javadocJar

archives javadocJar

}

did the trick.


(Peter Niederwieser) #3

At most one Jar is automatically added to the ‘archives’ configuration, and if you apply the ‘java’ plugin, it will be that plugin’s ‘Jar’ task.


(Scott Palmer) #4

Wouldn’t it make sense to add additional jars automatically so long as as they have a unique classifier?


(Peter Niederwieser) #5

The new ‘maven-publish’ plugin realizes what we now consider the right strategy (every artifact has to be published explicitly). The old ‘maven’ plugin will go away at some point, and I don’t expect it to receive further changes.


(Scott Palmer) #6

Yes. I want to use the newer plugin, but it had issues with the release plugin that removes -SNAPSHOT from the jar name and results in the publish task not finding the jars at the path with the previous name.

I couldn’t get it to work. Presumably that can be fixed (I would love to see it fixed in 1.8) so that actual file created by the jar task is used instead of what it would have been before the tasks actually ran.


(Peter Niederwieser) #7

It’s probably a matter of adapting the release plugin to work with the maven-publish plugin.