Use build version for static assets

This commit is contained in:
王文艳
2026-10-27 21:00:13 +08:00
parent b6166e2e79
commit 721277a84b
4 changed files with 39 additions and 3 deletions
Vendored
+1 -1
View File
@@ -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"'
}
}
}
+13
View File
@@ -8,9 +8,22 @@
<name>fangjia-coresite</name>
<properties>
<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>
<build>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -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 {
}
}
@@ -0,0 +1 @@
asset.version=${asset.version}