Question

As long as Gradle has been around, I'd have thought this was well documented, but I'm struggling. Sorry if this is obvious to everyone else.

I have a multi-project build setup with maven, I'm setting up gradle for comparison.

Project A produces a jar file, Project B produces a war file (and depends on the jar from A). Project C I want to create an assembly, i.e. a zip file. The zip file should contain the contents of a directory within project C, the war file from Project B, and the unpacked contents of a tomcat assembly pulled down from Archiva.

The problem I'm having is that when gradle evaluates the build.gradle files, it fails because it can't find the war file - which is no surprise, the war file hasn't been built yet.

So, how do I express the dependency on the war file in such a way that it doesn't cause the failure during evaluation?

apply plugin: 'distribution'

description = """E2am Assembly"""

project(':assembly') {
    dependencies {
        compile project(':webapps/e2am')
    }
}


dependencies {
    compile group: 'com.e2open.platform', name: 'e2am', version:'9.0-SNAPSHOT', ext:'war'
    compile group: 'com.e2open.platform.third-party.tomcat', name: 'tomcat-assembly',version:'7.0.42-1002', classifier:'bin', ext:'zip'
}

task explodeTomcat(type: Copy, dependsOn: ':webapps/e2am:install'){

   configurations.compile.filter { it.toString().endsWith(".zip") }.each{
      from zipTree(it)
   }
   into 'TomcatUnpacked'

   configurations.compile.filter { it.toString().endsWith(".war") }.each{
      from it
   }
   into 'war'

}

distributions {
    main {
        baseName = 'e2am-assembly'
        contents {
            from { 'tomcat' }
            from { 'TomcatUnpacked' }
            from { 'war' }
        }
    }
}


distZip.dependsOn explodeTomcat
install.dependsOn distZip

Also, the top level project applies the 'java' and 'maven' plugin to all sub projects.

The error is:

FAILURE: Build failed with an exception.

* Where:
    Build file '/kwork/wkcopy/e2amA/assembly/build.gradle' line: 25

* What went wrong:
    A problem occurred evaluating project ':assembly'.
    > Could not resolve all dependencies for configuration ':assembly:compile'.
       > Could not find com.e2open.platform:e2am:9.0-SNAPSHOT.
         Required by:
             com.e2open.platform:assembly:9.0-SNAPSHOT

Can someone point me to documentation or a discussion that gets me farther down the road? Thanks!

Was it helpful?

Solution

You should take a look at Multi-project Builds - Project lib dependencies in the Gradle documentation.

Something like this should work:

dependencies{
   compile project(:webapps/e2am)
   compile group: 'com.e2open.platform.third-party.tomcat', name: 'tomcat-assembly',version:'7.0.42-1002', classifier:'bin', ext:'zip'
}

There's also an example that looks a lot like what you are trying to do - might be worth a look :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top