当使用 maven 发布插件时,我想做一些前期工作(通过 ant tast)作为发布构建的一部分,并确保使用相同的代码库(因此没有提交潜入)。我有一个要调用的 ant 任务来执行此操作,但遇到以下问题:
在我的 pom 文件中:
<configuration>
<preparationGoals>antrun:run -Dtarget=${antTaskJarBuildXML} clean verify</preparationGoals>
</configuration>
其中 ${antTaskJarBuildXML} 是:
<target><ant antfile=\"../build.xml\" target=\"iv_dependency_build\" /></target>
当我运行 release:perform 这是日志:
...
[INFO] Not generating release POMs
[INFO] Executing goals 'antrun:run -Dtarget="<target><ant antfile=\"../build.xml\" target=\"iv_dependency_build\" /></target>" clean verify'...
[WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] [INFO] Scanning for projects...
[INFO] [WARNING]
[INFO] [WARNING] Some problems were encountered while building the effective model for com.xactsites:iv:war:12.12.4.9
[INFO] [WARNING] The expression ${version} is deprecated. Please use ${project.version} instead.
[INFO] [WARNING]
[INFO] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[INFO] [WARNING]
[INFO] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] [WARNING]
[INFO] [INFO]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building iv 12.12.4.9
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [WARNING] The artifact javax.xml:jaxrpc:jar:1.1 has been relocated to javax.xml:jaxrpc-api:jar:1.1
[INFO] [INFO]
[INFO] [INFO] --- maven-antrun-plugin:1.7:run (default-cli) @ iv ---
[INFO] [INFO] No ant target defined - SKIPPED
[INFO] [INFO]
[INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ iv ---
[INFO] [INFO] Deleting C:\dev\apps\iv\target
[INFO] [INFO]
...
如日志所示,我被告知没有指定目标。我遵循了我从ant run 文档中理解的内容
- 我在如何传递目标名称方面遗漏了什么吗?
- 这是最好的方法吗?
我失踪是逃避的问题吗?我在 Windows 上,这是为 xml (${antTaskJarBuildXML}) 定义的实际值:
"<target><ant antfile=\"../build.xml\" target=\"iv_dependency_build\" /></target>"
编辑
@carlspring 给出了一些很好的反馈(对他的回答+1),但是,由于问题的性质,并不是所有的东西都被 mavenized 我无法得到这个工作。Maven 期望能够控制整个发布过程,但我需要事先执行一个 ant 任务(它会创建相关构建所需的依赖项)。我还需要确保这个 prework 任务和常规构建是针对相同的 git tag/hash 构建的。我当前的解决方案是按顺序执行发布插件将执行的步骤,如此处所述。通过这个,我可以创建一个 git 标签,然后针对同一个 git 标签进行 maven 构建。如果有更好的想法,请贡献!