首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >maven java maven antrun插件

maven java maven antrun插件
EN

Stack Overflow用户
提问于 2012-02-09 16:33:20
回答 2查看 2.5K关注 0票数 1

我有一个问题:

我已经为验证阶段在我的pom.xml文件中配置了一个ant插件。任务就是简单地回显一些字符串到控制台。问题是,我看到我的执行被带到了accoutn,但是没有任务被执行。有人遇到过类似的问题吗?下面是我的pom.xml文件的代码:

代码语言:javascript
复制
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mp</groupId>
<artifactId>parentApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parentApp</name>
<description>This is just to test pom inheritance</description>


<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <defaultGoal>package</defaultGoal>
    <plugins>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <id>echodir</id>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <phase>verify</phase>
                    <inherited>true</inherited>
                    <configuration>
                        <task>
                            <echo>*************************************************** Build Dir</echo>
                            <mkdir>./hey</mkdir>
                        </task>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-core</artifactId>
            <version>5.1.0</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
    </dependencies>
</dependencyManagement>

运行mvn验证时获得的输出如下:

代码语言:javascript
复制
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building parentApp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-antrun-plugin:1.1:run (echodir) @ parentApp ---
[INFO] Executing tasks
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.321s
[INFO] Finished at: Thu Feb 09 17:28:01 CET 2012
[INFO] Final Memory: 2M/121M
[INFO] ------------------------------------------------------------------------

因此,执行任务执行任务之间最终没有输出,但是插件本身被考虑在内。知道为什么吗?

EN

回答 2

Stack Overflow用户

发布于 2012-02-09 16:54:17

在验证过程中尝试执行其他任务,例如:“将某个文件复制到某个目录”。

代码语言:javascript
复制
<copy file="${project.build.directory}/somefile" todir="some dir" 
 overwrite="true" />
票数 0
EN

Stack Overflow用户

发布于 2012-02-09 21:25:47

正如在一些注释中提到的,使用插件的最新版本(1.7)。另外,将<task>标记替换为<target>标记。例如:

代码语言:javascript
复制
<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>echodir</id>
            <goals>
                <goal>run</goal>
            </goals>
            <phase>verify</phase>
            <inherited>true</inherited>
            <configuration>
                <target>
                    <echo>*************************************************** Build Dir</echo>
                </target>
            </configuration>
        </execution>
    </executions>
</plugin>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9214835

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档