diff --git a/Jenkinsfile b/Jenkinsfile
index 04a1692c4..b1e686542 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -102,7 +102,7 @@ pipeline {
def buildDir = cfg.buildDir ?: params.PROJECT_NAME
dir("deliverables/${buildDir}") {
withMaven(globalMavenSettingsConfig: '426b9a25-aa0d-47d3-a24c-8abdfc4421ff', jdk: "JDK8") {
- sh 'mvn clean package -Dmaven.test.skip=true'
+ sh 'mvn clean package -Dmaven.test.skip=true -Dasset.version="$BUILD_TAG"'
}
}
}
diff --git a/projects/fangjia-coresite/pom.xml b/projects/fangjia-coresite/pom.xml
index 099947dfe..a3da544c1 100644
--- a/projects/fangjia-coresite/pom.xml
+++ b/projects/fangjia-coresite/pom.xml
@@ -8,9 +8,22 @@
fangjia-coresite
UTF-8
+ yyyyMMddHHmmss
+ ${maven.build.timestamp}
fangjia-coresite
+
+
+ src/main/resources
+ asset-version.properties
+
+
+ src/main/resources
+ true
+ asset-version.properties
+
+
org.apache.maven.plugins
diff --git a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/BaseModel.java b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/BaseModel.java
index e83379257..3db13c497 100644
--- a/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/BaseModel.java
+++ b/projects/fangjia-coresite/src/main/java/com/fangjia/coresite/model/BaseModel.java
@@ -1,6 +1,8 @@
package com.fangjia.coresite.model;
import java.io.UnsupportedEncodingException;
+import java.io.InputStream;
+import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Calendar;
@@ -9,6 +11,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.sothis.core.util.Pager;
@@ -37,6 +40,25 @@ public class BaseModel extends ModelAndViewSupport {
private static final long serialVersionUID = 1L;
private String debugFtl;
private final static FangjiaConfig CONFIG = FangjiaConfig.getConfig();
+ private static final String ASSET_VERSION = loadAssetVersion();
+
+ private static String loadAssetVersion() {
+ InputStream input = BaseModel.class.getResourceAsStream("/asset-version.properties");
+ if (input != null) {
+ try {
+ Properties properties = new Properties();
+ properties.load(input);
+ String version = properties.getProperty("asset.version");
+ if (version != null && version.length() > 0 && !version.startsWith("${")) {
+ return version;
+ }
+ } catch (IOException ignored) {
+ } finally {
+ try { input.close(); } catch (IOException ignored) { }
+ }
+ }
+ return String.valueOf(System.currentTimeMillis());
+ }
private final static String STATIC_URL = "http://" + CONFIG.getStaticDomainName()
+ (CONFIG.isDevelopmentEnvironment() ? "/fangjia-static" : "/stc");
@@ -216,7 +238,7 @@ public class BaseModel extends ModelAndViewSupport {
}
public final String getVersion() {
- return String.valueOf(System.currentTimeMillis());
+ return ASSET_VERSION;
}
public final String getHisCityUrl() {
@@ -638,4 +660,4 @@ public class BaseModel extends ModelAndViewSupport {
-}
\ No newline at end of file
+}
diff --git a/projects/fangjia-coresite/src/main/resources/asset-version.properties b/projects/fangjia-coresite/src/main/resources/asset-version.properties
new file mode 100644
index 000000000..27cee6666
--- /dev/null
+++ b/projects/fangjia-coresite/src/main/resources/asset-version.properties
@@ -0,0 +1 @@
+asset.version=${asset.version}