用 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>

解决方案 »

  1.   

    上面是你第一个问题的回答。至于第二个,dependency 标签下有个 scope,你把要去掉的 jar 的 scope 设置成 test,这样这些 jar 只会在编译、测试时对你项目有所影响,而不会被打进 war 包。
      

  2.   


    谢!
    有个问题,按你的方法是可以拷贝文档,但是因为我是分开发和生产的,我如何实现开发时,打包开发所Properties,而生产时我打包生产的properties?  用ant我现在的做法是写了两个ant文件,针对开发和生产分开打包,而如果用maven,如何做?是不是写几个ant任务,然后用maven build时 选择一个 ?
      

  3.   

    这个没办法,maven 可不知道你打包是用于测试还是生产的。目前我们是手工去调整的。如果你有更好的办法,可以通知我们
      

  4.   

    对于一般的 web 项目,开发的话,不建议打 war 包进行 debug。
    我们使用的是 tomcat 插件,可以免部署进行开发测试,tomcat 直接指向你编译好的 class 等资源文件。开发测试起来很高效。
    现在把我们的做法分享一下,希望能帮到有需要的朋友:
    http://blog.csdn.net/defonds/article/details/7845961
      

  5.   

    http://maven.apache.org/guides/introduction/introduction-to-profiles.html 这个?
      

  6.   

    http://maven.apache.org/guides/introduction/introduction-to-profiles.html 这个?不错啊,感谢同学分享。
    收藏了,等有空了具体去试试
      

  7.   

    刚发现你这说的不太对,test的话只在测试类的classpath中,源代码没法编译的。这里应该指定为provided
      

  8.   

    刚发现你这说的不太对,test的话只在测试类的classpath中,源代码没法编译的。这里应该指定为provided嗯嗯。谢谢同学指正。
      

  9.   

    这个可以通过warSourceExcludes属性设置吧?
    <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文件没测试过。以上,提供一个思路以供探讨
      

  10.   

    经验证是可行的通过profile,在mvn package 时指定这个profile就可以了