Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Commit

Permalink
feat: upgrade from java 7 to 8, upgrade to gradle 5.3, remove bintray (
Browse files Browse the repository at this point in the history
  • Loading branch information
melanahammel authored Mar 26, 2021
1 parent f92b075 commit c9a3283
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 108 deletions.
48 changes: 0 additions & 48 deletions .github/workflows/release.yml

This file was deleted.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ enables dynamic runtime properties from multiple configuration sources such as U

To learn more about Cerberus, please visit the [Cerberus website](http://engineering.nike.com/cerberus/).

## Publishing Notice 3/17/2021
As of spring 2021, JFrog has decided to sunset Bintray and JCenter.
Due to this decision, we are pausing our open source publishing of the Cerberus Archaius Client.
However, we will still be updating the source code and making new GitHub releases.

In order to build the jar yourself, run this command:
```bash
./gradlew assemble
```

The jar will be located in `./build/libs/`.

For any questions or concerns, create a Github issue [here](https://github.com/Nike-Inc/cerberus-archaius-client/issues/new).

## Quickstart

### Using the Archaius Provider
Expand Down
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ buildscript {

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
apply plugin: "com.diffplug.gradle.spotless"

Expand All @@ -35,8 +34,8 @@ spotless {
}
}

sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8

task copyProjectVersion() {
def releaseVersion = version
Expand All @@ -49,7 +48,6 @@ tasks.jar.dependsOn copyProjectVersion
apply from: 'gradle/dependencies.gradle'
apply from: 'gradle/check.gradle'
apply from: 'gradle/integration.gradle'
apply from: 'gradle/bintray.gradle'
apply from: 'gradle/owasp-dependency-check.gradle'

group = groupId
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

version=7.1.4
version=8.0.0
groupId=com.nike
artifactId=cerberus-archaius-client

2 changes: 1 addition & 1 deletion gradle/buildscript.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
}

dependencies {
classpath "net.saliman:gradle-cobertura-plugin:2.3.0"
classpath "net.saliman:gradle-cobertura-plugin:2.6.1"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3'
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.30.0"
Expand Down
14 changes: 10 additions & 4 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

repositories {
jcenter()
maven {
url "https://dl.bintray.com/nike/maven"
}
}

def AWS_SDK_VERSION = '1.11.+'

configurations.all {
resolutionStrategy {
force "ch.qos.logback:logback-core:1.2.3"
Expand All @@ -42,9 +41,16 @@ configurations.all {
}

dependencies {
implementation('com.nike:cerberus-client'){
version {
branch = 'master'
}
}
compile "com.amazonaws:aws-java-sdk-core:${AWS_SDK_VERSION}"
compile 'com.netflix.archaius:archaius-aws:0.7.7'
compile 'com.nike:cerberus-client:7.4.0'
compile 'com.netflix.archaius:archaius-core:0.7.7'

compile 'commons-configuration:commons-configuration:1.10'
compile "org.apache.commons:commons-lang3:3.11"
compile "com.squareup.okhttp3:okhttp:3.9.0"

Expand Down
2 changes: 1 addition & 1 deletion gradle/integration.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sourceSets {
}

task integration(type: Test, description: 'Runs integration tests') {
testClassesDir = sourceSets.integration.output.classesDir
testClassesDirs = sourceSets.integration.output.classesDirs
classpath = sourceSets.integration.runtimeClasspath
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#Tue Aug 09 14:40:45 PDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 7 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
* limitations under the License.
*/

rootProject.name = artifactId
rootProject.name = artifactId

sourceControl {
gitRepository("https://github.com/Nike-Inc/cerberus-java-client.git") {
producesModule("com.nike:cerberus-client")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.nike.cerberus.archaius.client;

import com.amazonaws.regions.Regions;
import javax.annotation.Nullable;
import io.github.resilience4j.core.lang.Nullable;
import okhttp3.HttpUrl;
import org.apache.commons.configuration.AbstractConfiguration;
import org.slf4j.Logger;
Expand All @@ -36,7 +36,7 @@ public class ArchaiusCerberusUrlResolver {
private static final String INVALID_PROPERY_VALUE_TEMPLATE =
"Could not find a valid value from the property %s";

private final Logger logger = LoggerFactory.getLogger(getClass());
private static final Logger logger = LoggerFactory.getLogger(ArchaiusCerberusUrlResolver.class);

/**
* Get a valid region name or null given a possible region name
Expand Down
36 changes: 22 additions & 14 deletions src/main/java/com/nike/cerberus/archaius/client/ClientVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.nike.cerberus.archaius.client;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.slf4j.Logger;
Expand All @@ -36,37 +37,44 @@ public class ClientVersion {

public static final String HEADER_VALUE_PREFIX = "CerberusArchaiusClient";

public static final String UNKNOWN = "unknown";

public static String getVersion() {

String clientVersion = "unknown";
InputStream propsStream = null; // NOPMD
try {
InputStream propsStream =
ClientVersion.class
.getClassLoader()
propsStream =
Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream(CLIENT_VERSION_PROPERTY_FILE);
Properties properties = new Properties();
properties.load(propsStream);

clientVersion = properties.getProperty(ARCHAIUS_CLIENT_VERSION_PROPERTY);
return properties.getProperty(ARCHAIUS_CLIENT_VERSION_PROPERTY);
} catch (Exception e) {
LOGGER.error("Failed to load client properties file", e);
return UNKNOWN;
} finally {
try {
if (propsStream != null) {
propsStream.close();
}
} catch (IOException e) {
LOGGER.error("Failed to close input stream", e);
}
}

return clientVersion;
}

public static String getClientHeaderValue() {

String cerberusClientHeaderValue = "unknown";
String version = getVersion();

try {
cerberusClientHeaderValue =
String cerberusClientHeaderValue =
com.nike.cerberus.client.ClientVersion.getClientHeaderValue();
return String.format(
"%s/%s %s", HEADER_VALUE_PREFIX, version, cerberusClientHeaderValue);
} catch (Exception e) {
LOGGER.error("Failed to get Cerberus Client version", e);
return String.format("%s/%s %s", HEADER_VALUE_PREFIX, version, UNKNOWN);
}

return String.format(
"%s/%s %s", HEADER_VALUE_PREFIX, getVersion(), cerberusClientHeaderValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

package com.nike.cerberus.archaius.client.provider;

import com.google.common.collect.Sets;
import com.netflix.config.PolledConfigurationSource;
import com.nike.cerberus.client.CerberusClient;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -30,7 +31,8 @@ public abstract class BaseCerberusConfigurationSource implements PolledConfigura

private final Set<String> paths;

private final Logger logger = LoggerFactory.getLogger(getClass());
private static final Logger logger =
LoggerFactory.getLogger(BaseCerberusConfigurationSource.class);

/**
* Constructor that accepts a Set&lt;String&gt; for paths.
Expand All @@ -48,8 +50,8 @@ public BaseCerberusConfigurationSource(CerberusClient cerberusClient, Set<String
throw new IllegalArgumentException("paths cannot be null or empty");
}
this.cerberusClient = cerberusClient;
this.paths = Sets.newHashSet(paths);
logger.info("paths={}", getPaths());
this.paths = new HashSet<>(paths);
logger.info("paths={}", this.paths);
}

/**
Expand All @@ -68,8 +70,8 @@ public BaseCerberusConfigurationSource(CerberusClient cerberusClient, String...
throw new IllegalArgumentException("paths cannot be null or empty");
}
this.cerberusClient = cerberusClient;
this.paths = Sets.newHashSet(paths);
logger.info("paths={}", getPaths());
this.paths = new HashSet<>(Arrays.asList(paths));
logger.info("paths={}", this.paths);
}

public CerberusClient getCerberusClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

package com.nike.cerberus.archaius.client.provider;

import com.google.common.collect.Maps;
import com.netflix.config.ConcurrentMapConfiguration;
import com.netflix.config.PollResult;
import com.netflix.config.PolledConfigurationSource;
import com.nike.cerberus.client.CerberusClient;
import com.nike.cerberus.client.model.CerberusResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.commons.configuration.AbstractConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -34,7 +33,7 @@
*/
public class CerberusConfigurationSource extends BaseCerberusConfigurationSource {

private final Logger logger = LoggerFactory.getLogger(getClass());
private static final Logger logger = LoggerFactory.getLogger(CerberusConfigurationSource.class);

/**
* Constructor that accepts a Set&lt;String&gt; for paths.
Expand Down Expand Up @@ -73,12 +72,12 @@ public PollResult poll(final boolean initial, final Object checkPoint) {
*
* @return Cerberus config
*/
public AbstractConfiguration getConfig() {
public ConcurrentMapConfiguration getConfig() {
return new ConcurrentMapConfiguration(getMap());
}

private Map<String, Object> getMap() {
final Map<String, Object> config = Maps.newHashMap();
final Map<String, Object> config = new HashMap<>();
for (final String path : getPaths()) {
logger.debug("poll: reading cerberus path '{}'...", path);
final CerberusResponse cerberusResponse = getCerberusClient().read(path);
Expand Down
Loading

0 comments on commit c9a3283

Please sign in to comment.