【发布时间】:2021-08-25 13:48:36
【问题描述】:
我在使用 maven antrun 插件时遇到问题。我可以使用任何开箱即用的 maven 编译我的多项目层 pom.xml,并使用自定义设置(添加私有 nexus 存储库)。
当我尝试使用相同的自定义设置在 Jenkins 构建上构建这个项目时,它总是失败:
main:
[taskdef] Could not load definitions from resource task.properties. It could not be found.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project redacted: An Ant BuildException has occured: Problem: failed to create task or type resourceCheck
[ERROR] Cause: The name is undefined.
[ERROR] Action: Check the spelling.
[ERROR] Action: Check that any custom tasks/types have been declared.
[ERROR] Action: Check that any <presetdef>/<macrodef> declarations have taken place.
所有 StackOverflow 线程都是由于 antrun 插件或 build.xml 文件上的配置错误造成的,但此配置在数百台开发人员的笔记本电脑上,并且都按预期工作。
我在 Jenkins 上尝试了多个 maven 安装,多个版本,但都失败了,因为找不到文件 task.properties。
我问这是否隐藏在默认的 maven 元数据文件夹的某个地方,因为我在本地存储库和所有项目上到处搜索,但找不到这个文件,它仍然在数百台机器上编译(除了这个项目在多个生产系统上)。
有谁知道在与 Maven 相关的任何东西上可以在哪里找到 task.properties 默认文件?
编辑:这是插件在 pom 上的样子:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<taskdef classpathref="maven.compile.classpath"
resource="task.properties" />
<resourceCheck>
<fileset dir="src/main/resources/metainfo">
<include name="i3-label.properties" />
</fileset>
<checks>
<include name="unicode check" />
<include name="line end check" />
<include name="empty key check" />
<include name="placeholder check" />
<include name="duplicate key check" />
<include name="empty value check" />
<include name="cross bundle check" /
</checks>
</resourceCheck>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
【问题讨论】:
-
第一个问题是:为什么要用maven-antrun-plugin?删除并使用默认的 Maven?
-
问候@khmarbaise,感谢您的回复。插件上有一些操作,关于 i3/18n 标签文件,不幸的是这是一个内部的大项目,已经在多个客户的生产系统上。这是 100 多个 pom 中需要的大重构。这里的重点是它适用于开箱即用的 maven 安装,但不知何故它在 jenkins 上就 antrun 插件失败了,而且 Jenkins 上的安装也是标准的开箱即用 maven。
标签: java maven jenkins maven-antrun-plugin