用 maven-antrun-plugin 插件。你可以把 ant 放弃掉了。
maven-antrun-plugin 能让用户在 Maven 项目中运行 Ant 任务。用户可以直接在该插件的配置以 Ant 的方式编写 Target,然后交给该插件的 run 目标去执行。
这里有个指定拷贝 online 这个目录里的甩有文件到 conf 目录,供参考:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy file="${project.build.directory}/${project.artifactId}.jar"
tofile="${env.WMSINSTALL_HOME}/lib/${project.artifactId}.jar"
overwrite="true" /> <copy todir="${env.WMSINSTALL_HOME}/lib/${libFolderName}"
overwrite="true">
<fileset dir="${project.build.directory}/${libFolderName}"
includes="**" />
</copy> </tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
maven-antrun-plugin 能让用户在 Maven 项目中运行 Ant 任务。用户可以直接在该插件的配置以 Ant 的方式编写 Target,然后交给该插件的 run 目标去执行。
这里有个指定拷贝 online 这个目录里的甩有文件到 conf 目录,供参考:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy file="${project.build.directory}/${project.artifactId}.jar"
tofile="${env.WMSINSTALL_HOME}/lib/${project.artifactId}.jar"
overwrite="true" /> <copy todir="${env.WMSINSTALL_HOME}/lib/${libFolderName}"
overwrite="true">
<fileset dir="${project.build.directory}/${libFolderName}"
includes="**" />
</copy> </tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
谢!
有个问题,按你的方法是可以拷贝文档,但是因为我是分开发和生产的,我如何实现开发时,打包开发所Properties,而生产时我打包生产的properties? 用ant我现在的做法是写了两个ant文件,针对开发和生产分开打包,而如果用maven,如何做?是不是写几个ant任务,然后用maven build时 选择一个 ?
我们使用的是 tomcat 插件,可以免部署进行开发测试,tomcat 直接指向你编译好的 class 等资源文件。开发测试起来很高效。
现在把我们的做法分享一下,希望能帮到有需要的朋友:
http://blog.csdn.net/defonds/article/details/7845961
收藏了,等有空了具体去试试
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>utf-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<warSourceExcludes>
WEB-INF/lib/servlet-api-2.4.jar,WEB-INF/lib/jsp-api-2.0.jar,WEB-INF/lib/junit-3.8.1.jar
</warSourceExcludes>
</configuration>
</plugin>
</plugins>
</build>
jar包排除是生效的,perproties文件没测试过。以上,提供一个思路以供探讨