1 maven编译后希望将生产的jar包拷贝到指定目录
在pom中配置maven插件
maven-antrun-plugin
<build > <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>copy-lib-src-webapps</id> <phase>package</phase> <configuration> <tasks> <!-- <delete dir="src/main/webapp/WEB-INFb" />--> <copy todir="F:jarlibs"> <fileset dir="${env.ACCOUNTINGDOCUMENT_JAVA_PATH}fi-gl-accountingdocument-core arget"> <include name="fi-gl-accountingdocument-core-1.0-SNAPSHOT.jar" /> </fileset> </copy> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
2 希望使用内置属性 ${properties.property} 方便项目协作
但不清楚有哪些properties 没找到简单的查看properties的方法
增加配置节点 执行validate 控制台会打印具体的properties
<execution> <phase>validate</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <echoproperties /> </tasks> </configuration> </execution>
如 想将生成的jar包拷贝到F:jarlibs
<build >
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-lib-src-webapps</id>
<phase>package</phase>
<configuration>
<tasks>
<!-- <delete dir="src/main/webapp/WEB-INFb" />-->
<copy todir="F:jarlibs">
<fileset dir="${project.build.directory}">
<include name="${project.artifactId}-${project.version}.jar" />
</fileset>
</copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<!-- <execution>-->
<!-- <phase>validate</phase>-->
<!-- <goals>-->
<!-- <goal>run</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <tasks>-->
<!-- <echoproperties />-->
<!-- </tasks>-->
<!-- </configuration>-->
<!-- </execution>-->
</executions>
</plugin>
</plugins>
</build>
3 拷贝依赖到制定文件夹
includeGroupIds过滤拷贝的groupid
<properties> <project.targetDir>D:jar</project.targetDir> <project.targetServerDir>\localhostc$jar</project.targetServerDir> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <includeGroupIds>com.inspur.gs</includeGroupIds> <outputDirectory>${project.targetDir}</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins>
参考:
1 https://stackoverflow.com/questions/12317609/maven-overview-for-the-values-of-maven-properties
2 https://books.sonatype.com/mvnref-book/reference/resource-filtering-sect-properties.html
3 http://www.avajava.com/tutorials/lessons/how-do-i-display-the-value-of-a-property.html