Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 777
Ken Liu Avatar asked Sep 03 '13 04:09

Ken Liu


2 Answers

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.

like image 95
Ken Liu Avatar answered Nov 02 '22 12:11

Ken Liu


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)
    }
  }
}
like image 40
Hiery Nomus Avatar answered Nov 02 '22 12:11

Hiery Nomus