I have a repository with multiple projects. Our existing build infrastructure is Ant and I’m converting our build to Gradle, so I’m using “ant.importBuild ‘build.xml’”. I’m trying to set dependencies on these projects. Some projects are libraries which I use ‘gradle jar’ to build and they produce JARs. Some are applications which I use ‘gradle dist’ to build and they produce EE artifacts (e.g. .ear). Here is what my repo looks like:
/service/Service1 /shared/SharedLib
I have SharedLib building fine. I want to put a dependency on SharedLib in Service1 so when I run ‘gradle dist’ in Service1, SharedLib builds also if it isn’t built. I’ve tried two different things in Service1’s build.gradle:
dependencies {
compile (’:shared/SharedLib’) }
but this doesn’t work. I get this error:
Could not find method compile() for arguments [project ‘:shared/SharedLib’
Probably because I’m not using the Java plugin as it will cause Gradle to add tasks which conflict with the Ant targets. I tried using jar instead of compile, but this didn’t work either. The other thing I tried was:
task dist(dependsOn: ‘:shared/SharedLib:jar’) << { }
this builds shared/SharedLib, but doesn’t execute Service1’s build. I’m guessing this is overriding Service1’s dist target. BTW, I tried this also:
task dist(overwrite: false, dependsOn: ‘:shared/SharedLib:jar’) << { }
but it still failed.
What’s the best way to handle this?