I’ve encountered a problem with maven-publish and a rather large multi-project build. The observed behavior is that no custom publication task is added to the graph, thus publishToMavenLocal is always marked as up to date. This is the output I get when invoking ‘gradle tasks --all’
Publishing tasks
----------------
publish - Publishes all publications produced by this project.
publishToMavenLocal - Publishes all Maven publications produced by this project to the local Maven cache.
The build files that cause trouble are
https://github.com/griffon/griffon/blob/development/build.gradle https://github.com/griffon/griffon/blob/development/gradle/publish.gradle
What’s interesting is that I have a very similar setup on another project
https://github.com/aalmiray/TestFX/blob/gradle_build/build.gradle https://github.com/aalmiray/TestFX/blob/gradle_build/gradle/publish.gradle
where the publication tasks work perfectly well. The main difference is that the second project contains a single child module at the moment. Any pointers to get the griffon build to work are greatly appreciated.
TIA Andres
Where do you declare the repository(s) to publish you? They usually go under ‘publishing { repositories { … }}’.
I haven’t defined any repositories because I’d like to publish to maven local for the time being. Bintray will be used at a later stage, the bintray plugin already supports a link between publications.
I can’t spot the problem. Do you get a publish task when you declare a Maven repo to publish to?
Nope. I tried by defining a local repo as shown in the docs but it doesn’t work either
Does it help when you add ‘apply plugin: “java”’ in the root build script (for some subproject), rather than relying on ‘evaluationDependsOnChildren()’?
Sadly it does not. I applied the java plugin to the root, also applied ‘java’ instead of ‘base’ (although for this setup is wrong because there’s at least one project that is just documentation (asciidoc)), and also applied ‘publish.gradle’ without any conditions, no dice.
If I remove ‘evaluationDependsOnChildren’ then no publishing task gets added at all.
I’m out of ideas then. Maybe somebody with a better understanding of the ‘maven-publish’ plugin and model rules can weigh in.
evaluationDependsOnChildren() is the problem. The code that inspects the publication data is firing before evaluationDependsOnChildren() returns.
I think it can be removed, and the following can be used…
subprojects {
plugins.withType(JavaPlugin) {
// …
}
}
Another option is to use afterEvaluate in the subprojects block and remove the evaluationDependsOnChildren() call.
Hi Luke, your suggestions were spot on! I had to look at the Ratpack build to figure out how the ‘plugins.withType()’ block would work.
Here’s the diff for posterity in case anyone gets in the same trouble as myself
https://github.com/griffon/griffon/commit/26e6e59a1de553969fde3ad57077c83a3c7fc0ab
Cheers, Andres
Thanks Andres.
I’ve made some notes about this. I’m not sure if we can make the original way work, but at least we can error.