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

其他-如果项目中不存在文件,则跳过Maven插件的执行

(其他 - Skip execution of a maven plugin if a file does not exist in the project)

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

当某个文件不存在时,我想跳过执行插件。有办法吗?

<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
11
J Fabian Meier 2020-11-29 21:56:36

用配置文件包围插件定义。

可以根据文件的存在/不存在来激活配置文件。

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