mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 07:15:54 -04:00
Introduce 'app.version' property and remove hardcoded version
This commit is contained in:
parent
15a6d8a295
commit
9adc41e23f
@ -1,3 +1,4 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
plugins {
|
||||
@ -25,6 +26,13 @@ run {
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include '**/*.properties'
|
||||
filter(ReplaceTokens, tokens: [ 'app.version': project.version ])
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url 'http://partnerdemo.artifactoryonline.com/partnerdemo/libs-snapshots-local' }
|
||||
|
@ -42,6 +42,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class BitsquareEnvironment extends StandardEnvironment {
|
||||
|
||||
public static final String APP_VERSION_KEY = "app.version";
|
||||
|
||||
public static final String USER_DATA_DIR_KEY = "user.data.dir";
|
||||
public static final String DEFAULT_USER_DATA_DIR = defaultUserDataDir();
|
||||
|
||||
@ -96,7 +98,7 @@ public class BitsquareEnvironment extends StandardEnvironment {
|
||||
setProperty(APP_NAME_KEY, appName);
|
||||
|
||||
setProperty(UserAgent.NAME_KEY, appName);
|
||||
setProperty(UserAgent.VERSION_KEY, "0.1");
|
||||
setProperty(UserAgent.VERSION_KEY, BitsquareEnvironment.this.getRequiredProperty(APP_VERSION_KEY));
|
||||
|
||||
setProperty(WalletFacade.DIR_KEY, appDataDir);
|
||||
setProperty(WalletFacade.PREFIX_KEY, appName);
|
||||
|
@ -1 +1 @@
|
||||
# Empty for now; see ConfigLoader
|
||||
app.version=@app.version@
|
@ -17,15 +17,18 @@
|
||||
|
||||
package io.bitsquare.app;
|
||||
|
||||
import io.bitsquare.btc.UserAgent;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.mock.env.MockPropertySource;
|
||||
|
||||
import static io.bitsquare.app.BitsquareEnvironment.*;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.core.env.PropertySource.named;
|
||||
import static org.springframework.core.env.StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME;
|
||||
@ -58,4 +61,15 @@ public class BitsquareEnvironmentTests {
|
||||
assertThat(env.getProperty("key.x"), equalTo("x.commandline")); // commandline value wins due to precedence
|
||||
assertThat(env.getProperty("key.y"), equalTo("y.env")); // env value wins because it's the only one available
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bitsquareVersionShouldBeAvailable() {
|
||||
// we cannot actually test for the value because (a) it requires Gradle's
|
||||
// processResources task filtering (which does not happen within IDEA) and
|
||||
// (b) because we do not know the specific version to test for. Instead just
|
||||
// test that the property has been made available.
|
||||
Environment env = new BitsquareEnvironment(new MockPropertySource());
|
||||
assertThat(env.containsProperty(APP_VERSION_KEY), is(true));
|
||||
assertThat(env.getProperty(UserAgent.VERSION_KEY), equalTo(env.getProperty(APP_VERSION_KEY)));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user