changed system to load build properties

pull/533/head
Michael Christen 2 years ago
parent c36bdbf78d
commit 347b676b76

2
.gitignore vendored

@ -20,7 +20,7 @@ yacy.log
/test/DATA/
/javadoc/
/build/
source/net/yacy/peers/operation/yacyBuildProperties.java
/defaults/yacyBuild.properties
/.idea/
.idea/
*.iws

@ -105,8 +105,8 @@
<filter token="REPL_REVISION_NR" value="${releaseNr}"/>
<!-- apply replacments -->
<copy file="${src}/net/yacy/peers/operation/yacyBuildProperties.java.template" tofile="${src}/net/yacy/peers/operation/yacyBuildProperties.java" overwrite="true" filtering="true" />
<copy file="${defaults}/yacyBuild.properties.template" tofile="${defaults}/yacyBuild.properties" overwrite="true" filtering="true" />
<!-- copy log4j config file -->
<copy file="${src}/log4j.properties" tofile="${build}/log4j.properties" overwrite="true" filtering="false" /> <!-- @TODO: obsolete, contains no replace/filter pattern -->

@ -0,0 +1,3 @@
SVNRevision = @REPL_REVISION_NR@
Version = @REPL_VERSION@

@ -0,0 +1,40 @@
package net.yacy.peers.operation;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Locale;
import java.util.Properties;
import java.util.regex.Pattern;
public final class yacyBuildProperties {
private static Properties props = new Properties();
static {
try {
props.load(new FileInputStream("defaults/yacyBuild.properties"));
} catch (IOException e) {
e.printStackTrace();
props = null;
}
}
public static String getSVNRevision() {
if (props == null) return "0";
final String revision = props.getProperty("SVNRevision");
return revision.contains("@") || revision.contains("$") ? "0" : revision;
}
public static String getVersion() {
if (props == null) return "0.1";
final String version = props.getProperty("Version");
return version.contains("@") ? "0.1" : version;
}
public static final Pattern versionMatcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z");
public static String getLongVersion() {
return String.format(Locale.US, "%.3f%05d", Float.valueOf(getVersion()), Integer.valueOf(getSVNRevision()));
}
}

@ -1,43 +0,0 @@
package net.yacy.peers.operation;
import java.util.Locale;
import java.util.regex.Pattern;
/**
* Properties set when compiling this release/version
*/
public final class yacyBuildProperties {
private yacyBuildProperties() {
}
/**
* returns the SVN-Revision Number as a String
*/
public static String getSVNRevision() {
final String revision = "@REPL_REVISION_NR@";
if (revision.contains("@") || revision.contains("$")) {
return "0";
}
return revision;
}
/**
* returns the version String (e. g. 0.9)
*/
public static String getVersion() {
if ("@REPL_VERSION@".contains("@") ) {
return "0.1";
}
return "@REPL_VERSION@";
}
public static final Pattern versionMatcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z");
/**
* returns the long version String (e. g. 0.9106712)
*/
public static String getLongVersion() {
return String.format(Locale.US, "%.3f%05d", Float.valueOf(getVersion()), Integer.valueOf(getSVNRevision()));
}
}
Loading…
Cancel
Save