Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

2.2.4 #94

Merged
merged 6 commits into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
.gradle/
build/
bin/
gradle.properties

classes/
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -19,7 +20,7 @@ repositories {

allprojects {
group = 'com.launchdarkly'
version = "2.2.3"
version = "{$version}"
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
Expand Down Expand Up @@ -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"
}
}

Expand Down Expand Up @@ -186,6 +188,10 @@ idea {
}
}

nexusStaging {
packageGroup = "com.launchdarkly"
}

uploadArchives {
repositories {
mavenDeployer {
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version=2.2.3
ossrhUsername=
ossrhPassword=
20 changes: 20 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -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."
25 changes: 14 additions & 11 deletions src/main/java/com/launchdarkly/client/FeatureFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ class FeatureFlag {
private static final Type mapType = new TypeToken<Map<String, FeatureFlag>>() {
}.getType();

private final String key;
private final int version;
private final boolean on;
private final List<Prerequisite> prerequisites;
private final String salt;
private final List<Target> targets;
private final List<Rule> rules;
private final VariationOrRollout fallthrough;
private final Integer offVariation; //optional
private final List<JsonElement> variations;
private final boolean deleted;
private String key;
private int version;
private boolean on;
private List<Prerequisite> prerequisites;
private String salt;
private List<Target> targets;
private List<Rule> rules;
private VariationOrRollout fallthrough;
private Integer offVariation; //optional
private List<JsonElement> variations;
private boolean deleted;

static FeatureFlag fromJson(String json) {
return LDConfig.gson.fromJson(json, FeatureFlag.class);
Expand All @@ -36,6 +36,9 @@ static Map<String, FeatureFlag> 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<Prerequisite> prerequisites, String salt, List<Target> targets, List<Rule> rules, VariationOrRollout fallthrough, Integer offVariation, List<JsonElement> variations, boolean deleted) {
this.key = key;
this.version = version;
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/launchdarkly/client/Prerequisite.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/launchdarkly/client/Rule.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
* Invariant: one of the variation or rollout must be non-nil.
*/
class Rule extends VariationOrRollout {
private final List<Clause> clauses;
private List<Clause> clauses;

// We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation
Rule() {
super();
}

Rule(List<Clause> clauses, Integer variation, Rollout rollout) {
super(variation, rollout);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/launchdarkly/client/Target.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import java.util.List;

class Target {
private final List<String> values;
private final int variation;
private List<String> values;
private int variation;

// We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation
Target() {}

Target(List<String> values, int variation) {
this.values = values;
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/com/launchdarkly/client/VariationOrRollout.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,8 +59,11 @@ private float bucketUser(LDUser user, String key, String attr, String salt) {
}

static class Rollout {
private final List<WeightedVariation> variations;
private final String bucketBy;
private List<WeightedVariation> variations;
private String bucketBy;

// We need this so Gson doesn't complain in certain java environments that restrict unsafe allocation
Rollout() {}

Rollout(List<WeightedVariation> variations, String bucketBy) {
this.variations = variations;
Expand All @@ -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;
Expand Down