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

prepare 1.0.0-rc1 release #1

Merged
merged 32 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
db568d4
initial implementation of Java common SDK code (#1)
eli-darkly Mar 20, 2020
374e08e
stick with Java 7 for Android compatibility (#2)
eli-darkly Apr 15, 2020
f1b9cb4
add getters to EvaluationReason and hide its subclasses
eli-darkly Apr 20, 2020
e86ced3
completely remove EvaluationReason subclasses
eli-darkly Apr 20, 2020
a8d1a91
Merge pull request #3 from launchdarkly/eb/ch74282/hide-reason-subcla…
eli-darkly Apr 20, 2020
0ff060b
Merge pull request #4 from launchdarkly/eb/ch74282/remove-reason-subc…
eli-darkly Apr 20, 2020
d440fd0
add JSON helpers, better serialization logic, and Gson adapter
eli-darkly Apr 20, 2020
04eaf1a
javadoc fixes
eli-darkly Apr 21, 2020
433a1e7
remove @since tags, misc doc fixes, add note about changelogging
eli-darkly Apr 21, 2020
55e3c1b
Merge branch 'eb/ch74370/javadoc-since' into eb/ch73994/gson-interop
eli-darkly Apr 21, 2020
fe6f0eb
fix sample code
eli-darkly Apr 22, 2020
97a8fa3
rename Gson adapter, use factory method
eli-darkly Apr 22, 2020
2c5cc2b
Merge pull request #5 from launchdarkly/eb/ch74370/javadoc-since
eli-darkly Apr 22, 2020
511c9e2
improve and rigorously test equals() for all immutable types
eli-darkly Apr 24, 2020
525daa6
simplifying
eli-darkly Apr 24, 2020
3e222c3
simplifying
eli-darkly Apr 24, 2020
d003179
make EvaluationDetail non-nullable + use boolean singletons
eli-darkly Apr 24, 2020
b810cd7
hide Gson in pom
eli-darkly Apr 24, 2020
129d5b6
doc additions
eli-darkly Apr 24, 2020
0ab6d7c
Merge pull request #8 from launchdarkly/eb/ch74915/non-null-index
eli-darkly Apr 27, 2020
36d3fba
Merge pull request #6 from launchdarkly/eb/ch73994/gson-interop
eli-darkly Apr 27, 2020
939b879
Merge branch 'master' into eb/ch68094/test-equals
eli-darkly Apr 27, 2020
6136698
javadoc fixes
eli-darkly Apr 27, 2020
fa2dd6c
Merge branch 'master' into eb/ch68094/test-equals
eli-darkly Apr 27, 2020
9bd6dbb
Merge pull request #7 from launchdarkly/eb/ch68094/test-equals
eli-darkly Apr 28, 2020
5458738
add Jackson adapter (#9)
eli-darkly Apr 28, 2020
5635a1d
more predictable exception behavior for LDValue.parse()
eli-darkly Apr 28, 2020
4ac7396
Merge pull request #11 from launchdarkly/eb/ch73994/parse-exception
eli-darkly Apr 28, 2020
21e9167
fix the JSON behavior of EvaluationDetail (#10)
eli-darkly Apr 28, 2020
7c29e7b
maximize and enforce test coverage (#12)
eli-darkly Apr 28, 2020
7a2aa77
build and test in Android! (#13)
eli-darkly Apr 29, 2020
119256f
1.0.0-rc1
eli-darkly Apr 29, 2020
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
166 changes: 166 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
version: 2.1

orbs:
win: circleci/windows@1.0.0

workflows:
test:
jobs:
- build-linux
- test-linux:
name: Java 8 - Linux - OpenJDK
docker-image: circleci/openjdk:8
requires:
- build-linux
- test-linux:
name: Java 9 - Linux - OpenJDK
docker-image: circleci/openjdk:9
requires:
- build-linux
- test-linux:
name: Java 10 - Linux - OpenJDK
docker-image: circleci/openjdk:10
requires:
- build-linux
- test-linux:
name: Java 11 - Linux - OpenJDK
docker-image: circleci/openjdk:11
with-coverage: true
requires:
- build-linux
- build-test-windows:
name: Java 11 - Windows - OpenJDK
- build-test-android:
name: Android

jobs:
build-linux:
docker:
- image: circleci/openjdk:8u131-jdk # To match the version pre-installed in Ubuntu 16 and used by Jenkins for releasing
steps:
- checkout
- run: cp gradle.properties.example gradle.properties
- run: java -version
- run: ./gradlew dependencies
- run: ./gradlew jar
- run: ./gradlew checkstyleMain
- persist_to_workspace:
root: build
paths:
- classes

test-linux:
parameters:
docker-image:
type: string
with-coverage:
type: boolean
default: false
docker:
- image: <<parameters.docker-image>>
steps:
- checkout
- run: cp gradle.properties.example gradle.properties
- attach_workspace:
at: build
- run: java -version
- run: ./gradlew test
- when:
condition: <<parameters.with-coverage>>
steps:
- run:
name: Generate test coverage report
command: ./gradlew jacocoTestReport
- run:
name: Enforce test coverage
command: ./gradlew jacocoTestCoverageVerification
- run:
name: Save test results
command: |
mkdir -p ~/junit/;
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
when: always
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
- when:
condition: <<parameters.with-coverage>>
steps:
- store_artifacts:
path: build/reports/jacoco

build-test-windows:
executor:
name: win/vs2019
shell: powershell.exe
steps:
- checkout
- run:
name: install OpenJDK
command: |
$ProgressPreference = "SilentlyContinue" # prevents console errors from CircleCI host
iwr -outf openjdk.msi https://developers.redhat.com/download-manager/file/java-11-openjdk-11.0.5.10-2.windows.redhat.x86_64.msi
Start-Process msiexec.exe -Wait -ArgumentList '/I openjdk.msi /quiet'
- run:
name: build and test
command: |
cp gradle.properties.example gradle.properties
.\gradlew.bat --no-daemon test # must use --no-daemon because CircleCI in Windows will hang if there's a daemon running
- run:
name: save test results
command: |
mkdir .\junit
cp build/test-results/test/*.xml junit
- store_test_results:
path: .\junit
- store_artifacts:
path: .\junit

build-test-android:
# This is adapted from the CI build for android-client-sdk
macos:
xcode: "10.3.0"
shell: /bin/bash --login -eo pipefail
working_directory: ~/launchdarkly/android-client-sdk-private
environment:
TERM: dumb
QEMU_AUDIO_DRV: none
_JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -Xms2048m -Xmx4096m"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
JVM_OPTS: -Xmx3200m
ANDROID_HOME: "/usr/local/share/android-sdk"
ANDROID_SDK_HOME: "/usr/local/share/android-sdk"
ANDROID_SDK_ROOT: "/usr/local/share/android-sdk"
steps:
- checkout
- run:
name: Install Android tools
command: ./scripts/install-android-tools.sh
- run:
name: Start Android environment
command: ./scripts/start-android-env.sh
background: true
timeout: 1200
no_output_timeout: 20m
- run:
name: Wait for Android environment
command: ./scripts/started-android-env.sh
- run:
name: Run tests
command: ./scripts/run-android-tests.sh
no_output_timeout: 20m
- run:
name: Save test results
command: |
mkdir -p ~/test-results
cp -r ./build/outputs/androidTest-results/* ~/test-results/
when: always
- run:
name: Stop Android environment
command: ./scripts/stop-android-env.sh
when: always
- store_test_results:
path: ~/test-results
- store_artifacts:
path: ~/artifacts
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ bin/
out/
classes/

packaging-test/temp/
# Test code that gets temporarily copied by our Android CI build
src/androidTest/java/com/launchdarkly/sdk/**/*.java
!src/androidTest/java/com/launchdarkly/sdk/BaseTest.java
15 changes: 15 additions & 0 deletions .ldrelease/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repo:
public: java-sdk-common
private: java-sdk-common-private

publications:
- url: https://oss.sonatype.org/content/groups/public/com/launchdarkly/launchdarkly-java-sdk-common/
description: Sonatype
- url: https://javadoc.io/doc/com.launchdarkly/launchdarkly-java-sdk-common
description: documentation (javadoc.io)

template:
name: gradle

documentation:
githubPages: true
7 changes: 7 additions & 0 deletions .ldrelease/publish-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -ue

# Publish to Github Pages
echo "Publishing to Github Pages"
./gradlew gitPublishPush
7 changes: 7 additions & 0 deletions .ldrelease/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -ue

# Publish to Sonatype
echo "Publishing to Sonatype"
./gradlew publishToSonatype closeAndReleaseRepository || { echo "Gradle publish/release failed" >&2; exit 1; }
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Change log

All notable changes to the project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [1.0.0-rc1] - 2020-04-29

Initial beta release, for the 5.0.0-rc1 release of the Java SDK.
68 changes: 68 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Contributing to the LaunchDarkly SDK Java Common Code

LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this project.

## Submitting bug reports and feature requests

The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/java-sdk-common/issues) in the GitHub repository. Bug reports and feature requests specific to this project should be filed in this issue tracker. The SDK team will respond to all newly filed issues within two business days.

## Submitting pull requests

We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days.

## Release notes and `@since`

Since this project is meant to be used from multiple LaunchDarkly SDKs and its Javadoc documentation will also appear in the Javadocs for those SDKs, please use the following conventions:

1. All changes and fixes should be documented in the changelog and release notes for this project as part of the usual release process.
2. They should _also_ be documented in the changelogs and release notes for the next Java/Android SDK releases that incorporate the new `java-sdk-common` release. Users of those should not be expected to monitor this repository; its existence as a separate project is an implementation detail.
3. When adding a new public type or method, include a `@since` tag in its Javadoc comment, in the following format: `@since Java server-side SDK $NEXT_JAVA_VERSION / Android SDK $NEXT_ANDROID_VERSION`, where `$NEXT_JAVA_VERSION` and `$NEXT_ANDROID_VERSION` are the next minor version releases of those SDKs that will incorporate this feature-- even though those have not been released yet.


## Build instructions

### Prerequisites

The project builds with [Gradle](https://gradle.org/) and should be built against Java 8.

### Building

To build the project without running any tests:
```
./gradlew jar
```

If you wish to clean your working directory between builds, you can clean it by running:
```
./gradlew clean
```

If you wish to use your generated SDK artifact by another Maven/Gradle project such as [java-server-sdk](https://github.com/launchdarkly/java-server-sdk), you will likely want to publish the artifact to your local Maven repository so that your other project can access it.
```
./gradlew publishToMavenLocal
```

### Testing

To build the project and run all unit tests:
```
./gradlew test
```

## Note on Java version and Android support

This project is limited to Java 7 because it is used in both the LaunchDarkly server-side Java SDK and the LaunchDarkly Android SDK. Android only supports Java 8 to a limited degree, depending on both the version of the Android developer tools and the Android API version. Since this is a small code base, we have decided to use Java 7 for it despite the minor inconveniences that this causes in terms of syntax.

## Code coverage

It is important to keep unit test coverage as close to 100% as possible in this project, since the SDK projects will not exercise every `java-sdk-common` method in their own unit tests.

Sometimes a gap in coverage is unavoidable, usually because the compiler requires us to provide a code path for some condition that in practice can't happen and can't be tested, or because of a known issue with the code coverage tool. Please handle all such cases as follows:

* Mark the code with an explanatory comment beginning with "COVERAGE:".
* Run the code coverage task with `./gradlew jacocoTestCoverageVerification`. It should fail and indicate how many lines of missed coverage exist in the method you modified.
* Add an item in the `knownMissedLinesForMethods` map in `build.gradle` that specifies that number of missed lines for that method signature.

## Note on dependencies

This project's `build.gradle` contains special logic to exclude dependencies from `pom.xml`. This is because it is meant to be used as part of one of the LaunchDarkly SDKs, and the different SDKs have different strategies for either exposing or embedding these dependencies. Therefore, it is the responsibility of each SDK to provide its own dependency for any module that is actually required in order for `java-sdk-common` to work; currently that is only Gson.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2020 Catamorphic, Co.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# LaunchDarkly SDK Java Common Code

[![Circle CI](https://circleci.com/gh/launchdarkly/java-sdk-common.svg?style=shield)](https://circleci.com/gh/launchdarkly/java-sdk-common)
[![Javadocs](http://javadoc.io/badge/com.launchdarkly/launchdarkly-java-sdk-common.svg)](http://javadoc.io/doc/com.launchdarkly/launchdarkly-java-sdk-common)

This project contains Java classes and interfaces that are shared between the LaunchDarkly server-side Java SDK and the LaunchDarkly Android SDK. Code that is specific to one or the other is in [java-server-sdk](https://github.com/launchdarkly/java-server-sdk) or [android-client-sdk](https://github.com/launchdarkly/android-client-sdk).

## Supported Java versions

This version of the library works with Java 7 and above.

## Contributing

See [Contributing](https://github.com/launchdarkly/dotnet-sdk-common/blob/master/CONTRIBUTING.md).

## About LaunchDarkly

* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list.
* Explore LaunchDarkly
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
* [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies
66 changes: 66 additions & 0 deletions build-android.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apply plugin: 'com.android.library'
//apply plugin: 'com.github.dcendents.android-maven'

buildscript {
repositories {
mavenCentral()
mavenLocal()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
// This Gradle script is used only when we are running tests in an Android environment to verify
// that the project is Android-compatible. We do not publish an Android build - that is done in
// the android-client-sdk project.

repositories {
mavenLocal()
// Before LaunchDarkly release artifacts get synced to Maven Central they are here along with snapshots:
maven { url "https://oss.sonatype.org/content/groups/public/" }
mavenCentral()
google()
}

apply from: 'build-shared.gradle'

android {
compileSdkVersion 26
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName version
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-proguard-rules.pro'

// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

packagingOptions {
exclude 'META-INF/**'
exclude 'META-INF/**'
}

dexOptions {
javaMaxHeapSize "4g"
}
}

dependencies {
androidTestImplementation "junit:junit:4.12"
androidTestImplementation "org.hamcrest:hamcrest-library:1.3"
androidTestImplementation "com.android.support.test:runner:1.0.2"
}
Loading