diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..84a98e9 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,96 @@ +version: 2.1 + +orbs: + win: circleci/windows@5.0.0 + +workflows: + test: + jobs: + - build-linux + - test-linux: + name: Java 8 - Linux - OpenJDK + docker-image: cimg/openjdk:8.0 + requires: + - build-linux + - test-linux: + name: Java 11 - Linux - OpenJDK + docker-image: cimg/openjdk:11.0 + requires: + - build-linux + - test-linux: + # current LTS version + name: Java 17 - Linux - OpenJDK + docker-image: cimg/openjdk:17.0 + with-coverage: true + requires: + - build-linux + - test-linux: + name: Java 19 - Linux - OpenJDK + docker-image: cimg/openjdk:19.0 + requires: + - build-linux + - packaging: + requires: + - build-linux + +jobs: + build-linux: + docker: + - image: cimg/openjdk:8.0 + steps: + - checkout + - run: java -version + - run: ./gradlew dependencies + - run: ./gradlew jar + - persist_to_workspace: + root: build + paths: + - classes + + test-linux: + parameters: + docker-image: + type: string + with-coverage: + type: boolean + default: false + docker: + - image: <> + steps: + - checkout + - attach_workspace: + at: build + - run: java -version + - run: + name: Run tests + command: ./gradlew test + - run: + name: Save test results + command: | + mkdir -p ~/junit/ + find . -type f -regex ".*/build/test-results/test/.*xml" -exec cp {} ~/junit/ \; + when: always + + - store_test_results: + path: ~/junit + - store_artifacts: + path: ~/junit + - store_artifacts: + path: ./build/reports/jacoco/test/html + destination: coverage + + packaging: + docker: + - image: cimg/openjdk:8.0 + steps: + - run: java -version + - run: sudo apt-get install make -y -q + - checkout + - attach_workspace: + at: build + - run: + name: checkstyle/javadoc + command: ./gradlew javadoc checkstyleMain + - run: + name: Publish to local maven + command: ./gradlew publishToMavenLocal diff --git a/README.md b/README.md index 6eabb77..7a39f6e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,20 @@ This version of the LaunchDarkly provider works with Java 8 and above. ### Installation -TODO: Implement +First, install the LaunchDarkly OpenFeature provider for the Server-Side SDK for Java as a dependency in your application using your application's dependency manager. + +```xml + + com.launchdarkly + launchdarkly-openfeature-serverprovider + 0.1.0 + +``` + +```groovy +implementation group: 'com.launchdarkly', name: 'launchdarkly-openfeature-serverprovider', version: '0.1.0' +// Use current version number in place of 0.1.0. +``` ### Usage diff --git a/build.gradle b/build.gradle index 2bf0355..e744838 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,93 @@ -/* - * This build file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java Library project to get you started. - * For more details take a look at the Java Libraries chapter in the Gradle - * user guide available at https://docs.gradle.org/4.4.1/userguide/java_library_plugin.html - */ - -// Apply the java-library plugin to add support for Java Library -apply plugin: 'java-library' - -// In this section you declare where to find the dependencies of your project + +plugins { + id "java" + id "java-library" + id "checkstyle" + id "jacoco" + id "signing" + id "com.github.johnrengelman.shadow" version "7.1.2" + id "maven-publish" + id "io.github.gradle-nexus.publish-plugin" version '1.2.0' + id "idea" +} + +java { + withJavadocJar() + withSourcesJar() +} + repositories { - // Use jcenter for resolving your dependencies. - // You can declare any Maven/Ivy/file repository here. - jcenter() + mavenLocal() + mavenCentral() +} + +test { + testLogging { + events "passed", "skipped", "failed", "standardOut", "standardError" + showStandardStreams = true + exceptionFormat = 'full' + } + dependsOn 'cleanTest' + finalizedBy jacocoTestReport // report is always generated after tests run +} + +jacocoTestReport { + dependsOn test // tests are required to run before generating the report +} + +checkstyle { + toolVersion = "9.3" + configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") + checkstyleTest.enabled = false +} + +publishing { + publications { + mavenJava(MavenPublication) { publication -> + from components.java + + artifactId = 'launchdarkly-openfeature-serverprovider' + + pom { + name = 'LaunchDarkly OpenFeature provider for the Server-Side SDK for Java' + packaging = 'jar' + url = 'https://github.com/launchdarkly/openfeature-java-server' + + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + + developers { + developer { + name = 'LaunchDarkly SDK Team' + email = 'sdks@launchdarkly.com' + } + } + + scm { + connection = 'scm:git:git://github.com/launchdarkly/openfeature-java-server' + developerConnection = 'scm:git:ssh:git@github.com:launchdarkly/openfeature-java-server.git' + url = 'https://github.com/launchdarkly/openfeature-java-server' + } + } + } + } + repositories { + mavenLocal() + } +} + +nexusPublishing { + clientTimeout = java.time.Duration.ofMinutes(2) // we've seen extremely long delays in creating repositories + repositories { + sonatype { + username = ossrhUsername + password = ossrhPassword + } + } } dependencies { @@ -23,8 +97,8 @@ dependencies { // This dependency is used internally, and not exposed to consumers on their own compile classpath. implementation 'com.google.guava:guava:23.0' - implementation group: 'com.launchdarkly', name: 'launchdarkly-java-server-sdk', version: '6.0.0' - implementation 'dev.openfeature:sdk:1.2.0' + implementation group: 'com.launchdarkly', name: 'launchdarkly-java-server-sdk', version: '6.+' + implementation 'dev.openfeature:sdk:[1.2.0,2.0.0)' // Use JUnit test framework testImplementation 'junit:junit:4.12' diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000..1292f2e --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..afa7510 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,7 @@ +group = com.launchdarkly +version = 0.1.0-alpha.1 +signing.keyId= +signing.password= +signing.secretKeyRingFile= +ossrhUsername= +ossrhPassword= diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d9b7505..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2c2bbe5..070cb70 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip diff --git a/settings.gradle b/settings.gradle index f801355..65f1c16 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,4 +15,4 @@ include 'api' include 'services:webservice' */ -rootProject.name = 'openfeature-java-server' +rootProject.name = 'launchdarkly-openfeature-serverprovider' diff --git a/src/main/java/com/launchdarkly/openfeature/serverprovider/package-info.java b/src/main/java/com/launchdarkly/openfeature/serverprovider/package-info.java new file mode 100644 index 0000000..54bfb29 --- /dev/null +++ b/src/main/java/com/launchdarkly/openfeature/serverprovider/package-info.java @@ -0,0 +1,9 @@ +/** + * Main package for the LaunchDarkly OpenFeature provider for the Server-Side SDK for Java, containing the provider + * and configuration classes. + *

+ * You will most often use {@link com.launchdarkly.openfeature.serverprovider.Provider} (the provider) and + * {@link com.launchdarkly.openfeature.serverprovider.ProviderConfiguration} (configuration options for the provider). + *

+ */ +package com.launchdarkly.openfeature.serverprovider;