use*_*374 7 maven maven-antrun-plugin
我刚刚将一个ant项目翻译成了maven,但是由于maven没有真正处理部署,所以我在构建中引入了一些antrun.但是,当我尝试执行它时,插件会跳过我的任务.例如,当我运行mvn clean antrun时:运行我得到以下消息:没有定义蚂蚁目标 - 跳过.同样的情况发生在我试图覆盖部署阶段以进行实际部署而不是上传到存储库的第二阶段.
请在下面找到我的pom.xml的摘录(类型:pom):
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>clean</id>
<configuration>
<task>
<echo>Cleaning deployed website</echo>
</task>
<tasks>
<delete dir="${deployRoot}/mydir/${env}"/>
</tasks>
</configuration>
<phase>clean</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>deployment</id>
<configuration>
<task>
<echo>Deploying website</echo>
</task>
<tasks>
<echo>Copying website artifact to deployment </echo>
<mkdir dir="${deployRoot}/mydir/${env}" />
<unzip
src="${project.basedir}/target/${env}.${project.version}.zip"
dest="${deployRoot}/mydir/${env}" />
<chmod perm="ugo+rx">
<fileset dir="${deployRoot}/mydir/${env}/web-exploded/bin">
<include name="**/*.sh" />
<include name="**/*.bat" />
</fileset>
</chmod>
</tasks>
</configuration>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
Rom*_*las 11
在您的中pom.xml,您定义了两种类型的执行:
clean阶段有关deploy阶段有关.请注意,顺便说一下,对于Maven的,deploy并不能意味着部署在服务器上我的(基于web)应用程序,但部署在远程存储库中的神器.请阅读deploy插件信息以获取更多详细信息.因此,如果您运行命令mvn deploy,当Maven生命周期到达deploy阶段时,它将运行插件执行(您的第二个pom.xml).
但是,在您的情况下,您没有运行默认的Maven生命周期,因为您的命令是mvn antrun:run(我不考虑clean此处的目标,因为它与问题无关).这可以在Maven中翻译,以运行目标运行antrun插件.问题在于您没有为直接调用Ant插件定义任何配置(包含Ant任务).
两个解决方案:
install阶段,然后运行mvn clean install而不是mvn antrun:run.请注意,在这种情况下,您将运行整个Maven生命周期(即编译,测试,打包).<configuration>块作为<plugin>定义的子代.如果你选择第二个解决方案,你会有pom.xml这样一个:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<!-- For cleaning -->
<executions>
<execution>
<id>clean</id>
<configuration>
<task>
<echo>Cleaning deployed website</echo>
</task>
<tasks>
<delete dir="${deployRoot}/mydir/${env}"/>
</tasks>
</configuration>
<phase>clean</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<tasks>
<echo>Copying website artifact to deployment </echo>
...
</tasks>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14173 次 |
| 最近记录: |