Gradle: how do I configure the jar location to be in the parent directory of the project?

谁说胖子不能爱 提交于 2019-12-21 07:55:53

问题


I'm trying to build a Gradle JAR project that is a subproject of another and would like the output JAR file to be in a parent directory (to be specific in the "lib" directory of the parent, or sibling). How do I configure Gradle for this and where is this documented?


回答1:


In build.gradle, add:

libsDirName = '../../lib'

The config settings are shown in the official Gradle docs for the java plugin.

BTW, I fully agree with the intent behind the comments and answers given by Peter and Hiery, but sometimes the simplest solution is the best one.




回答2:


Agreed with the comment Peter typed. However I think you want to express that the parent project depends on the output of the submodule. Expressing that and ensuring that the parent copies the output of the submodule to its 'lib' directory makes more sense.

task assembleSubModules(type: Copy) {
  destinationDir = file("lib")

  into("lib") {
    project.subprojects.each { p ->
      from(p.tasks.withType(Jar)*.outputs)
    }
  }
}


来源:https://stackoverflow.com/questions/18583896/gradle-how-do-i-configure-the-jar-location-to-be-in-the-parent-directory-of-the

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