1

当使用 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 文档中理解的内容

  1. 我在如何传递目标名称方面遗漏了什么吗?
  2. 这是最好的方法吗?
  3. 我失踪是逃避的问题吗?我在 Windows 上,这是为 xml (${antTaskJarBuildXML}) 定义的实际值:

    "&lt;target&gt;&lt;ant antfile=\"../build.xml\" target=\"iv_dependency_build\" /&gt;&lt;/target&gt;"

编辑

@carlspring 给出了一些很好的反馈(对他的回答+1),但是,由于问题的性质,并不是所有的东西都被 mavenized 我无法得到这个工作。Maven 期望能够控制整个发布过程,但我需要事先执行一个 ant 任务(它会创建相关构建所需的依赖项)。我还需要确保这个 prework 任务和常规构建是针对相同的 git tag/hash 构建的。我当前的解决方案是按顺序执行发布插件将执行的步骤,如此处所述。通过这个,我可以创建一个 git 标签,然后针对同一个 git 标签进行 maven 构建。如果有更好的想法,请贡献!

4

1 回答 1

2

我的建议是让您定义一个配置文件并在其中包含您的 ant-run 定义。

发布插件分叉,这意味着您的命令行参数将被忽略。

更新: 试试这个:

<?xml version="1.0" encoding="UTF-8"?>
<project ...>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.3.2</version>

                <executions>
                     <execution>
                         <id>execute-prepare</id>
                         <!-- Set up your Ant stuff here -->
                         <goals>
                              <goal>prepare</goal>
                         </goals>
                         <configuration>
                             <!-- If you have args specific for your release, put them here: -->
                             <arguments>-Pant-run-release</arguments>
                             <releaseProfiles>ant-run-release</releaseProfiles>
                             <mavenExecutorId>forked-path</mavenExecutorId>
                         </configuration>
                     </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>ant-run-release</id>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <id>execute-something</id>
                                <!-- Set up your Ant stuff here -->
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
于 2012-12-06T01:24:01.410 回答