1。 测试用例
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.5</version>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.5</version>
- <configuration>
- <includes>
- <include>**/*Tests.java</include>
- </includes>
- <excludes>
- <exclude>**/*ServiceTest.java</exclude>
- <exclude>**/TempDaoTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
2. 拷贝依赖
<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>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
3. 指定编译版本
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<verbose>true</verbose>
<encoding>UTF-8</encoding>
<compilerArguments>
<sourcepath>${project.build.sourceDirectory}</sourcepath>
</compilerArguments>
</configuration>
</plugin>
4. 资源打包
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<include>${project.build.sourceDirectory}</include>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
5. 指定资源
<resources>
<resource>
<directory>src/main/java/</directory>
<excludes>
<exclude>.svn</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources/</directory>
</resource>
</resources>
6. 拷贝资源文件到指定文职
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/extra-resources</outputDirectory>
<resources>
<resource>
<directory>src/non-packaged-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
本文深入解析了Maven插件的配置,包括测试用例的跳过与指定,依赖的拷贝,指定编译版本,资源打包与指定资源拷贝至特定目录的方法。
4528

被折叠的 条评论
为什么被折叠?



