Maven release plugin fails : source artifacts getting deployed twice

后端 未结 12 1758
故里飘歌
故里飘歌 2020-11-28 22:04

We are using the maven release plugin on hudson and trying to automate the release process. The release:prepare works fine. When we try to do the release:perform , it fails

12条回答
  •  隐瞒了意图╮
    2020-11-28 22:13

    FWIW this issue was breaking our build for a while and the answer was none-of-the-above. Instead I had foolishly set the seemingly innocuous appendAssemblyId to false in a maven-assembly-plugin for an artifact that gets attached (read deployed, released) with our main artifact. E.g.:

        
            ci-groovy-distrib
            package
            
                single
            
            
                
                    my-extra-assembly
                
    
                
                false
                
                my-extra-assembly-${project.version}
            
        
    

    In summary:

    1. the assembly plugin uses the assemblyId as the classifier for the artifact, hence an essential part of it's unique GAV coordinates in maven terms (actually it's more like GAVC coordinates - C is the classifier).

    2. the name of the file installed, deployed, or released is actually built from these coordinates. It is not the same as the filename you see in your target directory. That's why your local build looks good, but your release will fail.

    3. The stupid element only determines the local build artifact name and plays no part in the rest of it. It's a complete red-herring.

    Summary of the summary: The 400 error from Nexus was because our extra attached artifact was being uploaded over top of the main artifact, since it had the same name as the main artifact, because it had the same GAVC coordinates as the main artifact, because I removed the only distinguishing coordinate: the classifier derived automatically from the assemblyId.

    The investigation to find this was a long and tortuous path the answer was right there all along in the docs for maven-assembly:

    appendAssemblyId

    • boolean

    • Set to false to exclude the assembly id from the assembly final name, and to create the resultant assembly artifacts without classifier. As such, an assembly artifact having the same format as the packaging of the current Maven project will replace the file for this main project artifact.

    • Default value is: true.
    • User property is: assembly.appendAssemblyId.

    From http://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html#attach

    The extra bold is mine. The docs should have a big flashing warning here: "Set this to false and abandon all hope"

    I got some help from this answer about a different problem maven-assembly-plugin: How to use appendAssemblyId The explanation there from tunaki really helped.

提交回复
热议问题