gpt4 book ai didi

maven 程序集,如果找不到文件则失败

转载 作者:行者123 更新时间:2023-12-05 04:11:45 28 4
gpt4 key购买 nike

构建 maven assembly ,我留下了这样的东西:

<fileSets>
<fileSet>

<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>

<includes>

<include>LICENSE.md</include>
...

How can I enforce the existence of LICENSE.md?

在给定的示例中,如果此文件不存在,则不会抛出警告,理想情况下,我希望构建失败。

最佳答案

每当您想根据不同的约束使构建失败时,您应该查看 Maven Enforcer Plugin .这个插件允许配置被检查的规则,如果其中任何一个没有通过,它会使构建失败。

有一个内置规则来检查文件是否存在,称为 requireFilesExist :

This rule checks that the specified list of files exist.

因此,如果文件 LICENSE.md 不存在,为了使构建失败,您可以:

<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-license</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesExist>
<files>
<file>${project.basedir}/LICENSE.md</file>
</files>
</requireFilesExist>
</rules>
</configuration>
</execution>
</executions>
</plugin>

这默认在validate 阶段运行,which is the first phase invoked在构建中,因此如果文件不存在,构建将很快失败。

关于maven 程序集,如果找不到文件则失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42060335/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com