Update build scripts, Automate version number

This commit is contained in:
Manfred Karrer 2015-03-05 20:36:42 +01:00
parent 35f45138d2
commit 5a6c7ee89d
24 changed files with 257 additions and 830 deletions

View file

@ -18,6 +18,7 @@
package io.bitsquare.app;
import io.bitsquare.BitsquareException;
import io.bitsquare.app.gui.BitsquareAppMain;
import io.bitsquare.btc.UserAgent;
import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.main.MainView;
@ -43,8 +44,6 @@ 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();
@ -131,7 +130,7 @@ public class BitsquareEnvironment extends StandardEnvironment {
setProperty(APP_NAME_KEY, appName);
setProperty(UserAgent.NAME_KEY, appName);
setProperty(UserAgent.VERSION_KEY, BitsquareEnvironment.this.getRequiredProperty(APP_VERSION_KEY));
setProperty(UserAgent.VERSION_KEY, BitsquareAppMain.getVersion());
setProperty(WalletService.DIR_KEY, appDataDir);
setProperty(WalletService.PREFIX_KEY, appName);

View file

@ -42,6 +42,12 @@ import static java.util.Arrays.asList;
public class BitsquareAppMain extends BitsquareExecutable {
private static final Logger log = LoggerFactory.getLogger(BitsquareAppMain.class);
private static final String VERSION = "0.1";
public static String getVersion() {
return VERSION + "." + UpdateProcess.getBuildVersion();
}
public static void main(String[] args) throws Exception {
// We don't want to do the full argument parsing here as that might easily change in update versions
// So we only handle the absolute minimum which is APP_NAME, APP_DATA_DIR_KEY and USER_DATA_DIR
@ -50,8 +56,6 @@ public class BitsquareAppMain extends BitsquareExecutable {
.withRequiredArg();
parser.accepts(APP_NAME_KEY, description("Application name", DEFAULT_APP_NAME))
.withRequiredArg();
parser.accepts(APP_DATA_DIR_KEY, description("Application data directory", DEFAULT_APP_DATA_DIR))
.withRequiredArg();
OptionSet options;
try {

View file

@ -52,15 +52,18 @@ public class UpdateProcess {
private static final Logger log = LoggerFactory.getLogger(UpdateProcess.class);
// Edit version for updateFX
private static final int VERSION = 1;
private static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode("032D7B4073B0B94F0B0AAD72D4CC2B86FDDE7AAE334DE4BE448B0983D887975289");
private static final String UPDATES_BASE_URL = "http://localhost:8000/";
private static final int BUILD_VERSION = 2;
private static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode("025AA74490F66D195D42D49070D821C96A137496C070A924E5AAB0D6EE8549457E");
private static final String UPDATES_BASE_URL = "http://bitsquare.io/updateFX/";
private static final int UPDATE_SIGNING_THRESHOLD = 1;
private static final Path ROOT_CLASS_PATH = UpdateFX.findCodePath(BitsquareAppMain.class);
private Environment environment;
public static int getBuildVersion() {
return BUILD_VERSION;
}
private Environment environment;
public enum State {
CHECK_FOR_UPDATES,
@ -93,7 +96,7 @@ public class UpdateProcess {
}
public void init() {
log.info("UpdateFX current version " + VERSION);
log.info("UpdateFX current version " + BUILD_VERSION);
// process.timeout() will cause an error state back but we don't want to break startup in case of an timeout
timeoutTimer = Utilities.setTimeout(10000, new Function<AnimationTimer, Void>() {
@ -105,9 +108,9 @@ public class UpdateProcess {
});
timeoutTimer.start();
String agent = environment.getProperty(BitsquareEnvironment.APP_NAME_KEY) + VERSION;
String agent = environment.getProperty(BitsquareEnvironment.APP_NAME_KEY) + BUILD_VERSION;
Path dataDirPath = new File(environment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY)).toPath();
Updater updater = new Updater(UPDATES_BASE_URL, agent, VERSION, dataDirPath, ROOT_CLASS_PATH,
Updater updater = new Updater(UPDATES_BASE_URL, agent, BUILD_VERSION, dataDirPath, ROOT_CLASS_PATH,
UPDATE_SIGNING_KEYS, UPDATE_SIGNING_THRESHOLD) {
@Override
protected void updateProgress(long workDone, long max) {
@ -132,14 +135,14 @@ public class UpdateProcess {
log.info("One liner: {}", summary.descriptions.get(0).getOneLiner());
log.info("{}", summary.descriptions.get(0).getDescription());
}
if (summary.highestVersion > VERSION) {
if (summary.highestVersion > BUILD_VERSION) {
log.info("UPDATE_AVAILABLE");
state.set(State.UPDATE_AVAILABLE);
// We stop the timeout and treat it not completed.
// The user should click the restart button manually if there are updates available.
timeoutTimer.stop();
}
else if (summary.highestVersion == VERSION) {
else if (summary.highestVersion == BUILD_VERSION) {
log.info("UP_TO_DATE");
state.set(State.UP_TO_DATE);
timeoutTimer.stop();

View file

@ -1 +0,0 @@
app.version=@app.version@

View file

@ -17,18 +17,15 @@
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.*;
import static org.hamcrest.CoreMatchers.equalTo;
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;
@ -65,15 +62,4 @@ 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)));
}
}