【问题标题】:Skip execution of a maven plugin if a file does not exist in the project如果项目中不存在文件,则跳过执行 maven 插件
【发布时间】:2021-03-11 12:59:12
【问题描述】:

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

<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>

【问题讨论】:

    标签: maven plugins profile


    【解决方案1】:

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

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

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

    【讨论】:

    • 我希望上述插件仅在存在剪切文件时执行,所以我如何用配置文件包围它。放置个人资料时出现错误。
    • 抱歉,“下面”没有任何内容。请编辑问题并在此处添加信息。
    • 1.请不要将 XML 粘贴到 cmets 中,而是编辑问题。 2. 请将其包装在配置文件中。如果这不起作用,请报告确切的错误消息。
    • 那么,将其包装到配置文件中会发生什么?
    • 当我在 执行此操作时,STS 中会显示编译器错误。除了红十字符号之外,它不显示错误是什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    • 2017-01-02
    • 2012-04-19
    • 2014-12-10
    • 1970-01-01
    相关资源
    最近更新 更多