Maven: The packaging for this project did not assign a file to the build artifact

前端 未结 8 1576
误落风尘
误落风尘 2020-11-30 18:25

I\'m using Maven 3.0.3 on Mac 10.6.6. I have a JAR project and when I run the command \"mvn clean install:install\", I\'m getting the error,

[ERROR] Failed         


        
8条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 18:45

    While @A_Di-Matteo answer does work for non multimodule I have a solution for multimodules.

    The solution is to override every plugin configuration so that it binds to the phase of none with the exception of the jar/war/ear plugin and of course the deploy plugin. Even if you do have a single module my rudimentary tests show this to be a little faster (for reasons I don't know) performance wise.

    Thus the trick is to make a profile that does the above that is activated when you only want to deploy.

    Below is an example from one of my projects which uses the shade plugin and thus I had to re-override the jar plugin not to overwrite:

        
          deploy
          
            
              buildStep
              deploy
            
          
          
            
              
                org.apache.maven.plugins
                maven-compiler-plugin
                
                  
                    default-compile
                    none
                  
                  
                    default-testCompile
                    none
                  
                  
                    test-compile
                    none
                  
                
              
              
                org.apache.maven.plugins
                maven-surefire-plugin
                
                  
                    default-test
                    none
                  
                
              
              
                org.apache.maven.plugins
                maven-install-plugin
                
                  
                    default-install
                    none
                  
                
              
              
                org.apache.maven.plugins
                maven-resources-plugin
                
                  
                    default-resources
                    none
                  
                  
                    default-testResources
                    none
                  
                
              
              
                org.apache.maven.plugins
                maven-shade-plugin
                
                  
                    default
                    none
                  
                
              
              
                org.apache.maven.plugins
                maven-jar-plugin
                
                  
                    default-jar
                    
                      false
                    
                  
                
              
            
          
        
    

    Now if I run mvn deploy -Pdeploy it will only run the jar and deploy plugins.

    How you can figure out which plugins you need to override is to run deploy and look at the log to see which plugins are running. Make sure to keep track of the id of the plugin configuration which is parens after the name of the plugin.

提交回复
热议问题