Warm tip: This article is reproduced from serverfault.com, please click

Skip execution of a maven plugin if a file does not exist in the project

发布于 2020-11-29 11:07:41

I want to skip executing a plugin when a certain file does not exist. Is there a way to do it?

<plugin>                           
    <groupId>org.codehaus.mojo</groupId>             
    <artifactId>build-helper-maven-plugin</artifactId> 
    <version>1.8</version>                                 
    <executions>                                            
        <execution>                                            
            <id>add-test-source</id>                   
                <phase>generate-test-sources</phase>            
                <goals>                                      
                    <goal>add-test-source</goal>               
                </goals>                                
                <configuration>                               
                    <sources>                   
                        <source>${customFolder}</source>     
                    </sources>                         
                </configuration>                           
        </execution>                                      
    </executions>                                             
</plugin>
Questioner
Chaitra_daddolu
Viewed
0
J Fabian Meier 2020-11-29 21:56:36

Surround the plugin definition with profile.

Profiles can be activated depending on the existence/non-existence of a file.

https://maven.apache.org/guides/introduction/introduction-to-profiles.html