What is the best way to avoid maven-jar?

后端 未结 9 2196
后悔当初
后悔当初 2020-11-27 05:40

I am using a different plugin (ant4eclipse) to jar my files. What is the best way to avoid the maven-jar plugin from executing?

  • I tried to remove the <
9条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 06:13

    In Maven 3.0.x (I tried 3.0.2) you can disable maven-jar-plugin by binding the default-jar execution to a nonexistent phase, as @bmargulies suggested. Unfortunately that doesn't work in 2.2.1, but you can prevent it from interfering with your own jar by setting an alternative and for the default-jar execution; it will still create a jar, but it will be set as a secondary artifact for the project and won't overwrite the one you've created. Here's an example that should work in both Maven 2 and Maven 3:

    
      4.0.0
    
      test
      test
      0.1-SNAPSHOT
    
      
        
          
            maven-jar-plugin
            
              
                default-jar
                none
                
                  unwanted
                  unwanted
                
              
            
          
        
      
    
    

    Once you've disabled maven-jar-plugin, maven-install-plugin may give you trouble too. In Maven 3 it can be disabled the same as maven-jar-plugin: bind default-install to a nonexistent phase. However, in Maven 2 maven-install-plugin requires that the target/classes directory exist, and it will install the dummy jar when there isn't a primary artifact present.

提交回复
热议问题