maven管理ssh项目

使用Maven管理项目

1.  静态资源的合并和压缩

 

      pom.xml中继续配置:

  

  

<plugin>
    <!-- YUI Compressor Maven压缩插件 执行命令 mvn yuicompressor:compress -->
    <groupId>net.alchim31.maven</groupId>
    <artifactId>yuicompressor-maven-plugin</artifactId>
    <version>1.3.0</version>
    <inherited>true</inherited>
    <configuration>
     <!-- 读取js,css文件采用UTF-8编码 -->
     <encoding>UTF-8</encoding>
     <!-- 不显示js可能的错误 -->
     <jswarn>false</jswarn>
     <!-- 若存在已压缩的文件,会先对比源文件是否有改动 有改动便压缩,无改动就不压缩 -->
     <force>true</force>
     <!-- 在指定的列号后插入新行 -->
     <linebreakpos>-1</linebreakpos>
     <!-- 压缩之前先执行聚合文件操作 -->
     <preProcessAggregates>true</preProcessAggregates>
     <!-- 压缩后保存文件后缀 -->
     <suffix>.min</suffix>
     <!-- 源目录,即需压缩的根目录 -->
     <sourceDirectory>${project.build.directory}/classes/static/</sourceDirectory>
     <!-- 压缩js和css文件 -->
     <includes>
           <include>market/css/market.css</include>
         <include>market/js/**/*.js</include>
     </includes>
     <!-- 以下目录和文件不会被压缩 -->
     <excludes>
      <exclude>**/*.min.js</exclude>
      <exclude>**/*.min.css</exclude>
     </excludes>
     <!-- 压缩后输出文件目录 -->
     <outputDirectory>${project.build.directory}/classes/static</outputDirectory>
    </configuration>
    <executions>

      <!--加入生命周期-->
     <execution>
      <id>yuicompressor</id>
      <phase>prepare-package</phase>
      <goals>
       <goal>compress</goal>
      </goals>
     </execution>
    </executions>
  </plugin>

2. maven管理项目,打jar包的配置处理:

   

<plugin>    
       <groupId>org.apache.maven.plugins</groupId>    
       <artifactId>maven-jar-plugin</artifactId>   
       <version>2.3.1</version> 
       <configuration>
        <warSourceDirectory>target/pure</warSourceDirectory>
         <packagingExcludes>
         WEB-INF/classes/static/**/*.css,
         </packagingExcludes>    
       </configuration>  
       <executions>
     <execution>
      <id>pure-jar</id>
      <phase>package</phase>
      <goals>
       <goal>jar</goal>
      </goals>
     </execution>
    </executions>
   </plugin>

相关推荐