Add external resources to jar in gradle from another project

你。 提交于 2021-02-07 22:56:35

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!