I'm trying to create a group of four jars with the following pattern (each jar has its own project. helpRootDir
is shared between all four jars. If somebody knows of a way to make one task that does all four, that'd be awesome)
def helpRootDir = 'runtime/datafiles/help/'
project(':schedwinclihelp') {
def helpDir = 'schedwincli'
//Include no classes. This is strictly a resource jar
sourceSets.main.java {
exclude 'com/**'
}
jar {
from '${helpRootDir}/${helpDir}'
include '**/*.*'
}
}
Anyway as you can see from the above, I want no classes in the jar, and that's working. Unfortunately, all I'm actually getting in the jar is a MANIFEST.MF file. None of the files in the jar definition are getting added. I want the full file tree in ${helpRootDir}/${helpDir}
added to the root of the jar. How do I accomplish this?
Figured out I was referencing my variables incorrectly.
The correct syntax is:
def helpRootDir = 'runtime/datafiles/help/'
project(':schedwinclihelp') {
def helpDir = 'schedwincli'
//Include no classes. This is strictly a resource jar
sourceSets.main {
java {
exclude 'com/**'
}
resources {
srcDir helpRootDir + '/' + helpDir
}
}
}
Note srcDir helpRootDir + '/' + helpDir
rather than '${helpRootDir}/${helpDir}'
. Also, I just made my help dir a resource dir and let the java plugin do its thing automatically.
The following task will create a JAR file named resources.jar
with main resource files only (those are placed under src/main/resoures
directory).
Kotlin DSL:
tasks {
task<Jar>("resourcesJar") {
from(sourceSets["main"].resources)
archiveFileName.set("resources.jar")
}
}
Groovy DSL:
tasks.create("resourcesJar", Jar.class) {
from sourceSets.main.resources
archiveFileName = "resources.jar"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With