Browse Source

新增项目打包静态文件版本号

yangc 7 years ago
parent
commit
5e4e0a6425
1 changed files with 139 additions and 0 deletions
  1. 139 0
      pom.xml

+ 139 - 0
pom.xml

@@ -77,6 +77,145 @@
 	<build>
 		<finalName>home</finalName>
 		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>buildnumber-maven-plugin</artifactId>
+				<version>1.3</version>
+				<executions>
+					<execution>
+						<phase>validate</phase>
+						<goals>
+							<goal>create-timestamp</goal>
+						</goals>
+					</execution>
+				</executions>
+				<configuration>
+					<configuration>
+						<format>{0,date,yyyy-MM-dd HH:mm:ss}</format>
+						<items>
+							<item>timestamp</item>
+						</items>
+					</configuration>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.7</source>
+					<target>1.7</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>com.samaxes.maven</groupId>
+				<artifactId>minify-maven-plugin</artifactId>
+				<version>1.7.4</version>
+				<!-- 静态文件压缩  -->
+				<executions>
+					<execution>
+						<id>default-minify</id>
+						<phase>prepare-package</phase>
+						<configuration>
+							<charset>UTF-8</charset>
+							<skipMerge>true</skipMerge>
+							<closureLanguage>ECMASCRIPT5</closureLanguage>
+							<closureAngularPass>true</closureAngularPass>
+							<nosuffix>true</nosuffix>
+							<webappTargetDir>${project.build.directory}/minify</webappTargetDir>
+							<cssSourceDir>resources</cssSourceDir>
+							<cssEngine>YUI</cssEngine>
+							<jsSourceDir>resources</jsSourceDir>
+							<jsEngine>CLOSURE</jsEngine>
+							<cssSourceIncludes>
+								<cssSourceInclude>css/**/*.css</cssSourceInclude>
+								<cssSourceInclude>data/**/*.json</cssSourceInclude>
+							</cssSourceIncludes>
+							<cssSourceExcludes>
+								<cssSourceExclude>css/**/*.min.css</cssSourceExclude>
+							</cssSourceExcludes>
+							<jsSourceIncludes>
+								<jsSourceInclude>js/**/*.js</jsSourceInclude>
+							</jsSourceIncludes>
+							<jsSourceExcludes>
+								<jsSourceExclude>js/**/*.min.js</jsSourceExclude>
+							</jsSourceExcludes>
+						</configuration>
+						<goals>
+							<goal>minify</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<artifactId>maven-resources-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>copy-resources</id>
+						<phase>prepare-package</phase>
+						<goals>
+							<goal>copy-resources</goal>
+						</goals>
+						<configuration>
+							<outputDirectory>${project.build.directory}/minify</outputDirectory>
+							<overwrite>false</overwrite>
+							<resources>
+								<resource>
+									<directory>${basedir}/src/main/webapp</directory>
+								</resource>
+							</resources>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>com.uas.plugins</groupId>
+				<artifactId>static-maven-plugin</artifactId>
+				<version>0.0.2-SNAPSHOT</version>
+				<!-- 静态资源分离  -->
+				<executions>
+					<execution>
+						<id>default-static</id>
+						<phase>prepare-package</phase>
+						<configuration>
+							<pathMatcher>static</pathMatcher>
+							<staticUrl>static</staticUrl>
+							<webappDir>${project.build.directory}/minify</webappDir>
+							<sourceDir>/</sourceDir>
+							<targetDir>${project.build.directory}/statics</targetDir>
+							<staticDir>/</staticDir>
+							<sourceIncludes>
+								<sourceInclude>resources/js/**/*.js</sourceInclude>
+								<sourceInclude>resources/data/**/*.json</sourceInclude>
+								<sourceInclude>resources/tpl/**/*.html</sourceInclude>
+								<sourceInclude>WEB-INF/views/**/*.html</sourceInclude>
+							</sourceIncludes>
+							http://static.ubtob.com/css/index.css?_v=1450321871828
+							<versionSuffix>
+								<suffix>?_v=${timestamp}</suffix>
+								<exclude>*/require.js,*.min.js,*.min.css</exclude>
+							</versionSuffix>
+						</configuration>
+						<goals>
+							<goal>static</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-war-plugin</artifactId>
+				<version>2.4</version>
+				<configuration>
+					<webResources>
+						<resource>
+							<directory>${project.build.directory}/statics</directory>
+						</resource>
+						<resource>
+							<directory>${project.build.directory}/minify</directory>
+						</resource>
+					</webResources>
+				</configuration>
+			</plugin>
 			<plugin>
 				<groupId>org.apache.tomcat.maven</groupId>
 				<artifactId>tomcat7-maven-plugin</artifactId>