如何指定在发布期间运行的ant目标:准备目标?

时间:2012-12-05 23:47:57

标签: maven maven-release-plugin

当使用maven发布插件时,我想做一些前期工作(通过ant tast)作为发布版本的一部分,并保证使用相同的代码库(所以没有提交潜入之间)。我有一个蚂蚁任务,我想打电话来做这件事,但我遇到了以下问题:

在我的pom文件中:

            <configuration>
                <preparationGoals>antrun:run -Dtarget=${antTaskJarBuildXML} clean verify</preparationGoals>
            </configuration>

其中$ {antTaskJarBuildXML}是:

<target><ant antfile=\"../build.xml\" target=\"iv_dependency_build\" /></target>

当我运行发布时:执行此操作是日志:

... 
[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 documentation

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

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

  4. 修改

    @carlspring已经给出了一些很好的反馈(他的回答是+1),然而,由于问题的本质,并非所有东西都被mavenized我无法得到这个。 Maven希望能够控制整个发布过程,但我需要事先执行一个ant任务(它会创建相关构建所需的依赖项)。我还需要确保这个预先工作任务和常规构建是针对相同的git标签/哈希构建的。我目前的解决方案是依次执行发布插件执行的步骤here。通过这个我可以创建一个git标签,然后针对相同的git标签进行maven构建。如果有更好的想法,请提供帮助!

1 个答案:

答案 0 :(得分: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>