From 589d1d00afc3f6f106bc0459ebf70364ff8374e8 Mon Sep 17 00:00:00 2001 From: Dan Richelson Date: Thu, 1 Jun 2017 13:14:26 -0700 Subject: [PATCH 1/4] Better release process- no more clicking around Nexus web ui. --- build.gradle | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 651318369..b85877fa5 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ apply plugin: 'org.ajoberstar.github-pages' apply plugin: 'signing' apply plugin: 'idea' apply plugin: 'com.github.johnrengelman.shadow' +apply plugin: 'io.codearte.nexus-staging' configurations.all { // check for updates every build for dependencies with: 'changing: true' @@ -19,7 +20,7 @@ repositories { allprojects { group = 'com.launchdarkly' - version = "2.2.3" + version = "2.2.4-SNAPSHOT" sourceCompatibility = 1.7 targetCompatibility = 1.7 } @@ -60,6 +61,7 @@ buildscript { dependencies { classpath 'org.ajoberstar:gradle-git:1.5.0-rc.1' classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3' + classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.8.0" } } @@ -181,11 +183,14 @@ signing { idea { module { downloadJavadoc = true - downloadSources = true } } +nexusStaging { + packageGroup = "com.launchdarkly" +} + uploadArchives { repositories { mavenDeployer { From 8fcea43f9fba709e024a920455751307f5f1c319 Mon Sep 17 00:00:00 2001 From: Dan Richelson Date: Thu, 1 Jun 2017 19:53:26 -0700 Subject: [PATCH 2/4] Add no-arg constructors for things we deserialize from json. --- .../com/launchdarkly/client/FeatureFlag.java | 25 +++++++++++-------- .../com/launchdarkly/client/Prerequisite.java | 7 ++++-- .../java/com/launchdarkly/client/Rule.java | 7 +++++- .../java/com/launchdarkly/client/Target.java | 7 ++++-- .../client/VariationOrRollout.java | 21 +++++++++++----- 5 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/launchdarkly/client/FeatureFlag.java b/src/main/java/com/launchdarkly/client/FeatureFlag.java index 5fd556a97..e141bdbc4 100644 --- a/src/main/java/com/launchdarkly/client/FeatureFlag.java +++ b/src/main/java/com/launchdarkly/client/FeatureFlag.java @@ -16,17 +16,17 @@ class FeatureFlag { private static final Type mapType = new TypeToken>() { }.getType(); - private final String key; - private final int version; - private final boolean on; - private final List prerequisites; - private final String salt; - private final List targets; - private final List rules; - private final VariationOrRollout fallthrough; - private final Integer offVariation; //optional - private final List variations; - private final boolean deleted; + private String key; + private int version; + private boolean on; + private List prerequisites; + private String salt; + private List targets; + private List rules; + private VariationOrRollout fallthrough; + private Integer offVariation; //optional + private List variations; + private boolean deleted; static FeatureFlag fromJson(String json) { return LDConfig.gson.fromJson(json, FeatureFlag.class); @@ -36,6 +36,9 @@ static Map fromJsonMap(String json) { return LDConfig.gson.fromJson(json, mapType); } + // We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation + FeatureFlag() {} + FeatureFlag(String key, int version, boolean on, List prerequisites, String salt, List targets, List rules, VariationOrRollout fallthrough, Integer offVariation, List variations, boolean deleted) { this.key = key; this.version = version; diff --git a/src/main/java/com/launchdarkly/client/Prerequisite.java b/src/main/java/com/launchdarkly/client/Prerequisite.java index d934b7c22..8df50ea56 100644 --- a/src/main/java/com/launchdarkly/client/Prerequisite.java +++ b/src/main/java/com/launchdarkly/client/Prerequisite.java @@ -1,8 +1,11 @@ package com.launchdarkly.client; class Prerequisite { - private final String key; - private final int variation; + private String key; + private int variation; + + // We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation + Prerequisite() {} Prerequisite(String key, int variation) { this.key = key; diff --git a/src/main/java/com/launchdarkly/client/Rule.java b/src/main/java/com/launchdarkly/client/Rule.java index b2095452d..f240a9741 100644 --- a/src/main/java/com/launchdarkly/client/Rule.java +++ b/src/main/java/com/launchdarkly/client/Rule.java @@ -8,7 +8,12 @@ * Invariant: one of the variation or rollout must be non-nil. */ class Rule extends VariationOrRollout { - private final List clauses; + private List clauses; + + // We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation + Rule() { + super(); + } Rule(List clauses, Integer variation, Rollout rollout) { super(variation, rollout); diff --git a/src/main/java/com/launchdarkly/client/Target.java b/src/main/java/com/launchdarkly/client/Target.java index a6c5a648e..57e6f6598 100644 --- a/src/main/java/com/launchdarkly/client/Target.java +++ b/src/main/java/com/launchdarkly/client/Target.java @@ -3,8 +3,11 @@ import java.util.List; class Target { - private final List values; - private final int variation; + private List values; + private int variation; + + // We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation + Target() {} Target(List values, int variation) { this.values = values; diff --git a/src/main/java/com/launchdarkly/client/VariationOrRollout.java b/src/main/java/com/launchdarkly/client/VariationOrRollout.java index c1696c8ae..d0e666982 100644 --- a/src/main/java/com/launchdarkly/client/VariationOrRollout.java +++ b/src/main/java/com/launchdarkly/client/VariationOrRollout.java @@ -13,8 +13,11 @@ class VariationOrRollout { private static final float long_scale = (float) 0xFFFFFFFFFFFFFFFL; - private final Integer variation; - private final Rollout rollout; + private Integer variation; + private Rollout rollout; + + // We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation + VariationOrRollout() {} VariationOrRollout(Integer variation, Rollout rollout) { this.variation = variation; @@ -56,8 +59,11 @@ private float bucketUser(LDUser user, String key, String attr, String salt) { } static class Rollout { - private final List variations; - private final String bucketBy; + private List variations; + private String bucketBy; + + // We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation + Rollout() {} Rollout(List variations, String bucketBy) { this.variations = variations; @@ -66,8 +72,11 @@ static class Rollout { } static class WeightedVariation { - private final int variation; - private final int weight; + private int variation; + private int weight; + + // We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation + WeightedVariation() {} WeightedVariation(int variation, int weight) { this.variation = variation; From 3796a6623956c2387a4d711b8d4fea61c9007f6a Mon Sep 17 00:00:00 2001 From: Dan Richelson Date: Fri, 2 Jun 2017 07:51:50 -0700 Subject: [PATCH 3/4] Add release.sh script --- .gitignore | 1 - build.gradle | 3 ++- scripts/release.sh | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100755 scripts/release.sh diff --git a/.gitignore b/.gitignore index a123472de..6999e62b3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,5 @@ .gradle/ build/ bin/ -gradle.properties classes/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index b85877fa5..1c8a2a7ec 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ repositories { allprojects { group = 'com.launchdarkly' - version = "2.2.4-SNAPSHOT" + version = "{$version}" sourceCompatibility = 1.7 targetCompatibility = 1.7 } @@ -183,6 +183,7 @@ signing { idea { module { downloadJavadoc = true + downloadSources = true } } diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 000000000..0e5608433 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# This script updates the version for the java-client library and releases the artifact + javadoc +# It will only work if you have the proper credentials set up in ~/.gradle/gradle.properties + +# It takes exactly one argument: the new version. +# It should be run from the root of this git repo like this: +# ./scripts/release.sh 4.0.9 + +# When done you should commit and push the changes made. + +set -uxe +echo "Starting java-client release." + +VERSION=$1 + +#Update version in gradle.properties file: +sed -i '' "s/^version.*$/version=${VERSION}/" gradle.properties +./gradlew clean test install sourcesJar javadocJar uploadArchives closeAndReleaseRepository +./gradlew publishGhPages +echo "Finished java-client release." From 682b015af8ef8a0afe2a3fc9ccc1f60f80028b61 Mon Sep 17 00:00:00 2001 From: Dan Richelson Date: Fri, 2 Jun 2017 07:52:20 -0700 Subject: [PATCH 4/4] Add gradle.properties --- gradle.properties | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 gradle.properties diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..0e71cb518 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +version=2.2.3 +ossrhUsername= +ossrhPassword= \ No newline at end of file