Why are gradle jars written in `build / libs`?

According to the documentation of the Jar plugin, the output directory is controlled by the property destinationDir:

  • File destinationDir

    The directory in which the archive is created.

    By default with the java plugin: project.distsDir

Looking at the documentation for the Project class , the same property is mentioned:

Properties added by the plugin java

  • distsDir: directory for creating TAR and ZIP archives.
  • distsDirName: name of the distribution directory. This is interpreted relative to the project build directory.

And take a little walk. I find a document defining their default values :

  • File distsDir (read only)

    Directory for creating TAR and ZIP archives.

    By default with the java plugin: ${project.buildDir}/${project.distsDirName}

  • Line distsDirName

    The name of the distribution directory. This is interpreted relative to the project assembly directory.

    By default with the java plugin: 'distributions'

Gradle, , .

build.gradle :

println("distsDirName = " + project.distsDirName)
println("distsDir = " + project.distsDir.toString())

jar {
    println("jar.destinationDir = " + destinationDir)
}

, , ./gradlew :

distsDirName = distributions
distsDir = /home/ntrrgc/myProject/build/distributions
jar.destinationDir = /home/ntrrgc/myProject/build/libs

jar.destinationDir ?

+4
1

, @Alicia , , Gradle Jar File destinationDir:

Dir

, .

java:

project.distsDir

default distsDir - 'build/distributions', .

-,

Dir

, .

java:

project.libsDir

default libsDir - 'build/libs', .

Gradle issue # 1086 . , .

+2

Source: https://habr.com/ru/post/1664734/


All Articles