问题
I have a project that has a "resources" library (not java based). It simply contains a hierarchy of files that are used by multiple java projects
library
files
binaries
etc
In one of my java projects, I want to include these files in the assembled jar file
// current definition of a sample project
project("java_project") {
// dependencies omitted
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest {
attributes("Main-Class": "mymainclass")
}
}
}
project("library") {
// is in settings.gradle
}
How would I update the jar with the other project resources? I need them outside of the project because the same resources are shared by multiple projects.
回答1:
Perhaps someone will have a better solution but I added the following to the jar closure:
from { fileTree(dir: "library") }
I then can control the files with the exclude and include filters:
http://www.gradle.org/docs/current/userguide/working_with_files.html
来源:https://stackoverflow.com/questions/16574924/add-external-resources-to-jar-in-gradle-from-another-project