diff --git a/.circleci/config.yml b/.circleci/config.yml index 8503da459..cdc8a7dbb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,9 +29,10 @@ workflows: - benchmarks: requires: - build-linux - - build-test-windows: - name: Java 11 - Windows - OpenJDK - openjdk-version: 11.0.2.01 +# Windows Java 11 build is temporarily disabled - see story 171428 +# - test-windows: +# name: Java 11 - Windows - OpenJDK +# openjdk-version: 11.0.2.01 - build-test-windows: name: Java 17 - Windows - OpenJDK openjdk-version: 17.0.1 diff --git a/README.md b/README.md index 402fa37a2..d24105a2e 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ This version of the LaunchDarkly SDK works with Java 8 and above. Three variants of the SDK jar are published to Maven: -* The default uberjar - this is accessible as `com.launchdarkly:launchdarkly-java-server-sdk:jar` and is the dependency used in the "[Getting started](https://docs.launchdarkly.com/sdk/server-side/java#getting-started)" section of the SDK reference guide as well as in the [`hello-java`](https://github.com/launchdarkly/hello-java) sample app. This variant contains the SDK classes, and all of the SDK's dependencies except for SLF4J, which must be provided by the host application. The bundled dependencies have shaded package names (and are not exported in OSGi), so they will not interfere with any other versions of the same packages. +* The default uberjar - this is accessible as `com.launchdarkly:launchdarkly-java-server-sdk:jar` and is the dependency used in the "[Getting started](https://docs.launchdarkly.com/sdk/server-side/java#getting-started)" section of the SDK reference guide as well as in the [`hello-java`](https://github.com/launchdarkly/hello-java) sample app. This variant contains the SDK classes, and all of the SDK's dependencies except for SLF4J (the SLF4J API is assumed to be brought in automatically as Maven dependencies, or otherwise made available in the classpath of the host application). All third-party bundled dependencies have shaded package names (and are not exported in OSGi), so they will not interfere with any other versions of the same packages. * The extended uberjar - add `all` in Maven, or `:all` in Gradle. This is the same as the default uberjar except that SLF4J is also bundled, without shading (and is exported in OSGi). -* The "thin" jar - add `thin` in Maven, or `:thin` in Gradle. This contains _only_ the SDK classes. +* The "thin" jar - add `thin` in Maven, or `:thin` in Gradle. This contains _only_ the SDK classes. Applications using this jar must provide all of the dependencies that are in the SDK's `build.gradle`, so it is intended for use only in special cases. ## Getting started diff --git a/build.gradle b/build.gradle index 9a2bf13a8..acac74318 100644 --- a/build.gradle +++ b/build.gradle @@ -81,15 +81,17 @@ ext.versions = [ "jedis": "2.9.0" ] -// Add dependencies to "libraries.internal" that we use internally but do not expose in -// our public API. Putting dependencies here has the following effects: +// Add dependencies to "libraries.internal" that we use internally but do not necessarily +// expose in our public API. Putting dependencies here has the following effects: // // 1. Those classes will be embedded in the default uberjar // (launchdarkly-java-server-sdk-n.n.n.jar), and also in the "all" jar // (launchdarkly-java-server-sdk-n.n.n.jar). // // 2. The classes are renamed (shaded) within those jars, and all references to them are -// updated to use the shaded names. +// updated to use the shaded names. The only exception to this is classes from +// launchdarkly-java-sdk-common and launchdarkly-logging, which are meant to be part of +// the public API. // // 3. The "thin" jar does not contain those classes, and references to them from the code // in the "thin" jar are *not* renamed. If an application is using the "thin" jar, it is @@ -110,6 +112,7 @@ ext.versions = [ // headers for it. libraries.internal = [ "com.launchdarkly:launchdarkly-java-sdk-common:${versions.launchdarklyJavaSdkCommon}", + "com.launchdarkly:launchdarkly-logging:${versions.launchdarklyLogging}", "commons-codec:commons-codec:${versions.commonsCodec}", "com.google.code.gson:gson:${versions.gson}", "com.google.guava:guava:${versions.guava}", @@ -132,7 +135,6 @@ libraries.internal = [ // also as package exports (i.e. it provides them if a newer version is not available // from an import). libraries.external = [ - "com.launchdarkly:launchdarkly-logging:${versions.launchdarklyLogging}", "org.slf4j:slf4j-api:${versions.slf4j}" ] @@ -229,8 +231,9 @@ jar { } } -// This builds the default uberjar that contains all of our dependencies except Gson and -// SLF4j, in shaded form. The user is expected to provide Gson and SLF4j. +// This builds the default uberjar that contains all of our dependencies in shaded form, +// as well as com.launchdarkly.logging in unshaded form, but does not contain SLF4J. The +// user is expected to provide SLF4J. shadowJar { // No classifier means that the shaded jar becomes the default artifact classifier = '' @@ -265,7 +268,7 @@ shadowJar { } // This builds the "-all"/"fat" jar, which is the same as the default uberjar except that -// Gson and SLF4j are bundled and exposed (unshaded). +// SLF4J is also bundled and exposed (unshaded). task shadowJarAll(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { classifier = 'all' group = "shadow" @@ -290,9 +293,9 @@ task shadowJarAll(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJ // configuration phase; this is necessary because they access the build products doFirst { shadeDependencies(project.tasks.shadowJarAll) - // The "all" jar exposes its bundled SLF4j dependency as an export - but, like the - // default jar, it *also* imports it ("self-wiring"), which allows the bundle to use a - // higher version if one is provided by another bundle. + // The "all" jar exposes its bundled SLF4j and launchdarkly-logging dependencies as + // exports - but, like the default jar, it *also* imports them ("self-wiring"), which + // allows the bundle to use a higher version if one is provided by another bundle. addOsgiManifest(project.tasks.shadowJarAll, [ project.configurations.imports ], [ project.configurations.imports ]) } @@ -351,7 +354,7 @@ if (JavaVersion.current().isJava8Compatible()) { // enclosing packages like "com" that don't have any classes in them. def getAllSdkPackages() { // base package classes come from launchdarkly-java-sdk-common - def names = [ "com.launchdarkly.sdk", "com.launchdarkly.sdk.json" ] + def names = [ "com.launchdarkly.sdk", "com.launchdarkly.sdk.json", "com.launchdarkly.logging" ] project.convention.getPlugin(JavaPluginConvention).sourceSets.main.output.each { baseDir -> if (baseDir.getPath().contains("classes" + File.separator + "java" + File.separator + "main")) { baseDir.eachFileRecurse { f -> @@ -505,7 +508,7 @@ def forEachArtifactAndVisiblePackage(configs, closure) { configs.collectMany { it.resolvedConfiguration.resolvedArtifacts } .collectMany { a -> def exportedPackages = getOsgiPackageExportsFromJar(a.file) - if (exportedPackages == null) { + if (exportedPackages == null || exportedPackages.size == 0) { // This dependency didn't specify OSGi exports, so we'll just have to assume that // we might need to use any package that's in this jar (with a little special-casing // to exclude things we probably should not be importing). diff --git a/packaging-test/Makefile b/packaging-test/Makefile index 972a82506..32dafe245 100644 --- a/packaging-test/Makefile +++ b/packaging-test/Makefile @@ -87,6 +87,7 @@ test-all-jar-classes: $(SDK_ALL_JAR) $(TEMP_DIR) @$(call caption,$@) @$(call classes_prepare,$<) @$(call verify_sdk_classes) + @$(call classes_should_contain,com/launchdarkly/logging,unshaded com.launchdarkly.logging classes) @$(call classes_should_contain,org/slf4j,unshaded SLF4j) @$(call classes_should_not_contain,com/launchdarkly/shaded/com/launchdarkly/sdk,shaded SDK classes) @$(call classes_should_contain,com/launchdarkly/shaded/com/google/gson,shaded Gson) @@ -101,6 +102,7 @@ test-default-jar-classes: $(SDK_DEFAULT_JAR) $(TEMP_DIR) @$(call caption,$@) @$(call classes_prepare,$<) @$(call verify_sdk_classes) + @$(call classes_should_contain,com/launchdarkly/logging,unshaded com.launchdarkly.logging classes) @$(call classes_should_not_contain,com/launchdarkly/shaded/com/launchdarkly/sdk,shaded SDK classes) @$(call classes_should_contain,com/launchdarkly/shaded/com/google/gson,shaded Gson) @$(call classes_should_not_contain,com/launchdarkly/shaded/org/slf4j,shaded SLF4j)