I am going to try to assemble this assembly of snapshots, but here's how I hacked everything together from yesterday just for the sake of completeness. Feel free to improve my Gradle / Groovy. I am sure that it is not as elegant as it could be.
task ('ear', type:Jar, dependsOn: ":myWarProject:assemble" ){
from{ "ear/src/main/application" }
}
ear.doFirst{
baseName = "myapp-" + rootVersion
extension = "ear"
def allSubprojectDependencies = getAllProjectDependencies([
"subproject1",
"subproject2",
"subproject3",
"subproject4",
"subproject5"
])
from { allSubprojectDependencies }
from {
subprojects.find{ it.name=="myWarFile" }.war.archivePath
}
from { configurations.earConfig.files }
manifestClassPath = allSubprojectDependencies.collect { it.name }.sort().join(' ')
manifest { attributes( "Class-Path": manifestClassPath ) }
}
def getAllProjectDependencies (def projectNames){
def allDependencies = []as Set
projectNames.each{ projectName ->
def subProject = subprojects.find{ subProject ->
subProject.name.equals(projectName)
}
def subProjectDependencies = subProject.configurations.compile.files
allDependencies.addAll subProjectDependencies
}
return allDependencies.unique{ a,b->
if (a.equals(b)){
return 0
}
return -1
}
}
(Please note that all banks are at the root of the ear on purpose. Do not ask me why, but some people like it.)
source
share