I have a build where I defined javadoc jars to be created for our normal source and our test sources. I want to make sure they get published to our Nexus repository, so I added them to our publishing section like this:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
mavenJavadoc(MavenPublication) {
artifact(javadocJar) {
classifier "javadoc"
}
}
mavenTestJavadoc(MavenPublication) {
artifact(testJavadocJar) {
classifier "testjavadoc"
}
}
}
}
}
This works nicely, but one more thing I would like to accomplish is to have these javadoc jars only be created and published if a certain task is run, instead of always when a publish task is called. The reason I would like this is for during normal development, I don’t really care if javadoc jars are created when I do a publishToMavenLocal. But when we go to do a release, I’d like to be able to call another task to make sure they get published, like:
./gradlew test generateJavadoc publish
So I guess what I am looking for is to be able to conditionally add my javadoc jars to the publish task dependency.