Gradle gather all jar dependencies in multi project and build a ear

893 views Asked by At

I am pretty new to gradle and I am trying to achieve the following I have setup a multi project build, with the following structure root: :commonjar (java-library) :war1 (war) :war2 (war) :externaljars (local repository for unmanaged jars) :libs (ear)

I would like to automatically gather all runtime dependencies for commonjar, war1 and war2 and generate a deployable ear (libs) where all jars are stored inside libs.ear/lib

I have kind found a way to gather all jar using taks definition like this:

task copyDeps(type: Copy) {
    from(subprojects.configurations.runtime) 
    into project.file(libDirName)
}

But no matter where I store the jars, the get not picked up by the "ear" task.

Just to explain, I need to make a dummy ear, with only jars to do remote deployment and create shared library definitions on IBM Websphere application server.

Any good suggestion to have an ear gather and package all jars (transitive as well) used in the entire project? Thanks

1

There are 1 answers

0
Vampire On BEST ANSWER

You can simply configure the ear task to include the dependencies you want to have in there with something like

ear {
    duplicateStrategy = DuplicateStrategy.EXCLUDE
    lib {
        from rootProject.subprojects.configurations.runtime
    }
}