Gradle - jar file name in java plugin

前端 未结 9 1833
借酒劲吻你
借酒劲吻你 2021-02-01 11:46

I am trying with Gradle first time. I am trying with a maven java project to compile and create a jar file. It is compiling and creating the jar file in build/libs directory as

相关标签:
9条回答
  • 2021-02-01 12:40

    Try setting:

    archivesBaseName = 'project1'
    

    or

    jar.baseName = 'project1'
    

    Here is the full solution:

    trunk
    ˪ build
      ˪ libs
        ˪ project1-1.0-SNAPSHOT.jar 
    ˪ build.gradle
    

    build.gradle is:

    apply plugin: 'java'
    apply plugin: 'maven'
    
    archivesBaseName = 'project1'
    version = '1.0-SNAPSHOT'
    group = 'example'
    

    It produces correct ZIPs, POMs and JARs.

    0 讨论(0)
  • If you has some submobule, you can use in build.gradle (for jar)

    configurations {
        jar.archiveName = 'submodule-jar.jar'
    }
    
    0 讨论(0)
  • 2021-02-01 12:44

    I recently migrated to gradle 4.6 (from 3. something) and the

    jar {
        baseName = 'myjarname'
    }
    

    stopped working, gradle named my jar from the folder name.

    So I switched to archivesBaseName = 'myjarname' which works.

    Maybe this helps somebody else too.

    0 讨论(0)
提交回复
热议问题