Use build version for static assets
This commit is contained in:
Vendored
+1
-1
@@ -102,7 +102,7 @@ pipeline {
|
|||||||
def buildDir = cfg.buildDir ?: params.PROJECT_NAME
|
def buildDir = cfg.buildDir ?: params.PROJECT_NAME
|
||||||
dir("deliverables/${buildDir}") {
|
dir("deliverables/${buildDir}") {
|
||||||
withMaven(globalMavenSettingsConfig: '426b9a25-aa0d-47d3-a24c-8abdfc4421ff', jdk: "JDK8") {
|
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"'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,22 @@
|
|||||||
<name>fangjia-coresite</name>
|
<name>fangjia-coresite</name>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
|
||||||
|
<asset.version>${maven.build.timestamp}</asset.version>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<finalName>fangjia-coresite</finalName>
|
<finalName>fangjia-coresite</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<excludes><exclude>asset-version.properties</exclude></excludes>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<includes><include>asset-version.properties</include></includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.fangjia.coresite.model;
|
package com.fangjia.coresite.model;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@@ -9,6 +11,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.sothis.core.util.Pager;
|
import org.sothis.core.util.Pager;
|
||||||
@@ -37,6 +40,25 @@ public class BaseModel extends ModelAndViewSupport {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private String debugFtl;
|
private String debugFtl;
|
||||||
private final static FangjiaConfig CONFIG = FangjiaConfig.getConfig();
|
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()
|
private final static String STATIC_URL = "http://" + CONFIG.getStaticDomainName()
|
||||||
+ (CONFIG.isDevelopmentEnvironment() ? "/fangjia-static" : "/stc");
|
+ (CONFIG.isDevelopmentEnvironment() ? "/fangjia-static" : "/stc");
|
||||||
@@ -216,7 +238,7 @@ public class BaseModel extends ModelAndViewSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final String getVersion() {
|
public final String getVersion() {
|
||||||
return String.valueOf(System.currentTimeMillis());
|
return ASSET_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getHisCityUrl() {
|
public final String getHisCityUrl() {
|
||||||
@@ -638,4 +660,4 @@ public class BaseModel extends ModelAndViewSupport {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
asset.version=${asset.version}
|
||||||
Reference in New Issue
Block a user