How can I .jar all .class output from all sub-projects into one jar? I want to find a solution that does not require OneJar or fatJar , or any similar 3rd party projects/plugins.
Looking for a pure Groovy script, or Gradle script, solution.
Here is the code that looked hopeful to me but it doesn’t work. I get an error in multiple places in this block are all similar to : “Could not find property ‘build’ on project” . I tried various things and always get a similar error.
subprojects.each { subproject -> evaluationDependsOn(subproject.path)}
task allJar( type: Jar, dependsOn: subprojects.build ) {
baseName = 'allJar'
subprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
}
}
artifacts {
archives allJar
}
My project structure is like this:
Root project 'CoreProject'
\--- Project ':core'
+--- Project ':core:bing'
\--- Project ':core:google'
In this case I want to build a “root subproject” called “core” that contains classes that the other subprojects share, just like a shared project.
The difference is that “core” is a parent project of all the sub-projects.
So, as a result, I need to build a distibution .jar that contains class files from the “core” project as well as all the classes from sub-projects.
Because I think the answer to this question may rely on this information, here is how I was able to get this project to compile in a hierarchy like this:
project(':core') {
project.ext.projTitle = 'WebDriver On Gradle'
project.ext.projVersion = '0.99.0'
}
project(':core:google') {
dependencies {
compile project(':core')
}
project.ext.projVersion = '0.99.2'
project.ext.projTitle = 'WebDriver on Google'
}
project(':core:bing') {
dependencies {
compile project(':core')
}
project.ext.projVersion = '0.99.2'
project.ext.projTitle = 'WebDriver on Bing'
}