Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
293 views
in Technique[技术] by (71.8m points)

java - conditionally execute maven plugins

I have some Maven plugins configured in my pom.xml. I only want to execute these plugins if the tests are being run (tests may be skipped using either -Dmaven.test.skip=true or -DskipTests).

One of these plugins is bound to the process-classes build lifecycle phase and the other is bound to the pre-integration-test phase.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use profile with special activation conditions like this:

<project>
  ...
  <profiles>
    <profile>
      <id>my-test-plugins</id>

      <activation>
        <property><name>!maven.test.skip</name></property>
        <property><name>!skipTests</name></property>
      </activation>
      <build>
        <plugins>

      <!-- define your plugins here -->

        </plugins>
      </build>
    </profile>
  </profiles>
</project>

More info you can find here:

http://books.sonatype.com/mvnref-book/reference/profiles-sect-activation.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...