3

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.

2
  • Are the resource files only used within the same build? Do they need to be preprocessed, or do other projects include them as-is? Commented May 16, 2013 at 6:03
  • They are only used for this root project, but shared by subprojects. They don't need to be processed in any way, just added to some JARs during the assemble task for a couple java projects. Commented May 16, 2013 at 12:59

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments