How do I disable the maven-compiler-plugin?

前端 未结 4 2013
南笙
南笙 2021-01-03 20:53

I have a maven project that uses the aspectj-compiler-plugin. I use intertype declarations so there are references to Aspect code in my Java code. Because of this, the mav

相关标签:
4条回答
  • 2021-01-03 21:00

    You can disable the a plugin by set the phase of the plugin to none.

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    
    0 讨论(0)
  • 2021-01-03 21:12

    In Maven 3, the following will do this, for example disabling the clean plugin:

       <build>
          <plugins>
             <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4.1</version>
                <executions>
                   <execution>
                      <id>default-clean</id>
                      <phase>none</phase>
                   </execution>
                </executions>
             </plugin>
          </plugins>
       </build>
    

    The same technique can be used for any other plugin defined in the super-POM, the packaging type, or the parent POM. The key point is that you must copy the <id> shown by help:effective-pom, and change the <phase> to an invalid value (e.g. "none"). If you don't have the <id> (as e.g. in Jintian DENG's original answer – it has since been edited to add one), it will not work, as you have discovered.

    0 讨论(0)
  • 2021-01-03 21:19

    Either configure the skipMain parameter:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <skipMain>true</skipMain>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    Or pass the maven.main.skip property:

    mvn install -Dmaven.main.skip=true
    
    0 讨论(0)
  • 2021-01-03 21:20

    The reason maven-compiler-plugin executes in the first place is because you trigger one of the default lifecycle bindings. For example if you're packaging jar using mvn package, it will trigger compile:compile at compile phase.

    Maybe try not to use the default lifecycle, but use mvn aspectj:compile instead.

    http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html has more information about maven default lifecycle bindings

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