Maven 打包时排除不想打包的文件&跳过测试

Maven 打包时排除不想打包的文件&跳过测试

打包时不将资源文件夹下的文件打入包中 

pom.xml

<build>   
  <plugins>
   <plugin>   
    <groupId>org.apache.maven.plugins</groupId>   
    <artifactId>maven-war-plugin</artifactId>   
    <version>2.0.2</version>   
    <configuration>   
     <warSourceExcludes>src/main/resources/**</warSourceExcludes>   
    </configuration>   
   </plugin>   
  </plugins>   
 </build>

 

跳过测试

1. pom.xml

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId>  
    <configuration>  
        <skip>true</skip>  
    </configuration> 
</plugin>

2. 命令

mvn test -Dmaven.test.failure.ignore=true
mvn install -Dmaven.test.skip=true

     

 

按不同的配置参数打包:

mvn clean package -PtestServer

mvn clean package -Pdevelop

pom.xml

  <profiles>
   <profile>
    <id>develop</id>
    <activation>
   <activeByDefault>true</activeByDefault>
  </activation>
  <properties>
  <!-- local -->
   <com.xxx.xxx.log.dir>D:\apache-tomcat-6.0.18\logs\</com.xxx.xxx.log.dir>
   <com.xxx.xxx.upload.temp.dir>C:/temp</com.xxx.xxx.upload.temp.dir>
   <com.xxx.xxx.node.image.root.url>http://127.0.0.1:8080/xxx_war/images/node/banner/</com.xxx.xxx.node.image.root.url>
   <com.xxx.xxx.upload.node.image.savePath>D:/xxx/upload/images/node/banner/</com.xxx.xxx.upload.node.image.savePath>
  </properties>
   </profile>
   <profile>
    <id>testServer</id>
    <activation>
   <activeByDefault>false</activeByDefault>
  </activation>
  <properties>  
  <!-- test server -->
   <com.xxx.xxx.log.dir>/home/xxx/logs/</com.xxx.xxx.log.dir>
   <com.xxx.xxx.upload.temp.dir>/home/xxx/upload/temp</com.unionread.publish.upload.temp.dir>
   <com.xxx.xxx.node.image.root.url>http://192.168.1.1:8091/xxx_war/images/node/banner/</com.xxx.xxx.node.image.root.url>
   <com.xxx.xxx.upload.node.image.savePath>/home/xxx/upload/images/node/banner/</com.xxx.xxx.upload.node.image.savePath>
  </properties>
   </profile>
  </profiles>

你可能感兴趣的:(Maven 打包时排除不想打包的文件&跳过测试)