Is it possible to rename a maven jar-with-dependencies?

后端 未结 6 667
一整个雨季
一整个雨季 2021-01-29 19:47

I\'m currently using the jar-with-dependencies assembly to create such a jar. However, the name of my jar is a bit long.

Since this jar is being used by RPG programs

6条回答
  •  -上瘾入骨i
    2021-01-29 20:43

    You can specify the finalName property to give the jar the name you want, and specify that appendAssemblyId should be false to avoid the "jar-with-dependencies" suffix.

    The configuration below will output a jar called "test.jar"

    
      maven-assembly-plugin
      2.2-beta-4
      
        
          jar-with-dependencies
          package
          
            single
          
          
            
              jar-with-dependencies
            
            test
            false
          
        
      
    
    

    Update: based on your comments, using the built-in descriptor won't work . I believe this is down to a bug in the recent versions of the assembly-plugin - they've removed support for classifiers, but the id is fixed if you use a built-in descriptor, so you end up with a big daft name.

    As a workaround, you can copy the assembly descriptor used by the jar-with-dependencies descriptor and modify the id.

    This example would result in the assembly id being appended to the finalName, so if you need to have a name of region-full.jar, you can specify the finalName as region and the assembly id as full. This will result in a file in target called region-full.jar, but note it will still be installed to the Maven repository as an attached artifact with full used as the classifier. As long as this id is different to that for your other assembly there should be no collision though.

    The pom configuration would look like this.

    
      maven-assembly-plugin
      2.2-beta-4
      
        
          jar-with-dependencies
          prepare-package
          
            single
          
          
            
              src/main/assembly/jar-assembly.xml
            
            region
          
        
      
    
    

    and the jar-assembly.xml in src/main/assembly like this:

    
      full
      
        jar
      
      false
      
        
          true
          runtime
        
      
      
        
          ${project.build.outputDirectory}
        
      
    
    

提交回复
热议问题