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

Chore/update gradle version #118

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

version: 2
updates:
# Enable version updates for Gradle
- package-ecosystem: "gradle"
# Enable version updates for Gradle
# Look for `build.gradle` files in the `root` directory
directory: "/"
target-branch: "dep/dependency_upgrade_staging"
Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ buildscript {
apply from: file('gradle/buildscript.gradle'), to: buildscript
}

plugins {
id "jacoco"
id "com.github.spotbugs" version "5.0.13"
}

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: "com.github.johnrengelman.shadow"

Expand Down
4 changes: 1 addition & 3 deletions gradle/buildscript.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
*/

repositories {
jcenter()
mavenCentral()
}

dependencies {
classpath "net.saliman:gradle-cobertura-plugin:2.6.1"
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.6.3'
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.3"
classpath 'org.owasp:dependency-check-gradle:5.3.2'
}
62 changes: 36 additions & 26 deletions gradle/check.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
* limitations under the License.
*/

apply plugin: 'findbugs'
apply plugin: 'pmd'
apply plugin: 'cobertura'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'org.owasp.dependencycheck'

dependencyCheck {
Expand All @@ -26,41 +23,54 @@ dependencyCheck {
failBuildOnCVSS = 11
}

findbugs {
ignoreFailures = false
pmd {
sourceSets = [ project.sourceSets.main ]
excludeFilter = file("codequality/findbugs.xml")
rulesMinimumPriority = 2
ignoreFailures = false
}

pmd {
sourceSets = [ project.sourceSets.main ]
test {
finalizedBy jacocoTestReport // report is always generated after tests run
}

tasks.withType(FindBugs) {
jacocoTestReport {
reports {
xml.withMessages = true
xml.required = false
csv.required = false
}
dependsOn test // tests are required to run before generating the report
}

jacoco {
toolVersion = "0.8.8"
}

cobertura {
// https://github.com/stevesaliman/gradle-cobertura-plugin/blob/master/usage.md
coverageReportDir = new File("$buildDir/reports/cobertura")
coverageFormats = ['html', 'xml']
coverageIgnoreTrivial = true
coverageExcludes = []
spotbugs {
ignoreFailures = true
showStackTraces = false
showProgress = true
effort = 'default'
reportLevel = 'default'
reportsDir = file("$buildDir/reports/spotbugs")
//visitors = [ 'FindSqlInjection', 'SwitchFallthrough' ]
//omitVisitors = [ 'FindNonShortCircuit' ]
//includeFilter = file("include.xml")
//excludeFilter = file("exclude.xml")
//baselineFile = file("baseline.xml")
//onlyAnalyze = [ 'com.foobar.MyClass', 'com.foobar.mypkg.*' ]
//maxHeapSize = '1g'
//extraArgs = [ '-nested:false' ]
//jvmArgs = [ '-Duser.language=ja' ]
}
test.finalizedBy(project.tasks.coberturaReport)

task findbugsHtml {
group = "Verification"
description = "Creates a human readable Findbugs report"
doLast {
ant.xslt(in: file("$buildDir/reports/findbugs/main.xml"),
style: file('codequality/findbugs_default.xsl'),
out: new File("$buildDir/reports/findbugs/main.html"))
spotbugsMain {
reports {
html {
required = true
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
//stylesheet = 'fancy-hist.xsl'
}
}
}
findbugsMain.finalizedBy findbugsHtml

tasks.check.dependsOn dependencyCheckAnalyze
tasks.coveralls.dependsOn check
39 changes: 19 additions & 20 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

repositories {
jcenter()
mavenCentral()
}

def AWS_SDK_VERSION = '1.11.+'
Expand Down Expand Up @@ -59,36 +59,35 @@ dependencies {
shadow "org.slf4j:slf4j-api:1.7.25"
shadow "com.google.code.gson:gson:2.5"

compile "com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}"
compile "org.apache.commons:commons-lang3:3.4"
compile "com.google.code.gson:gson:2.5"
compile "org.slf4j:slf4j-api:1.7.25"
compile "io.github.resilience4j:resilience4j-all:1.7.1"
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
compileOnly 'com.google.code.findbugs:annotations:3.0.1'
implementation "com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}"
implementation "org.apache.commons:commons-lang3:3.4"
implementation "com.google.code.gson:gson:2.5"
implementation "org.slf4j:slf4j-api:1.7.25"
implementation "io.github.resilience4j:resilience4j-all:1.7.0"
testImplementation "com.google.code.findbugs:jsr305:3.0.2"
testImplementation 'com.google.code.findbugs:annotations:3.0.1'

compile "com.amazonaws:aws-java-sdk-core:${AWS_SDK_VERSION}"
compile "com.amazonaws:aws-java-sdk-sts:${AWS_SDK_VERSION}"
implementation "com.amazonaws:aws-java-sdk-core:${AWS_SDK_VERSION}"
implementation "com.amazonaws:aws-java-sdk-sts:${AWS_SDK_VERSION}"

testRuntime 'org.slf4j:slf4j-simple:1.7.25'
testCompile "junit:junit:4.12"
testCompile ("org.mockito:mockito-core:1.10.19") {
testImplementation 'org.slf4j:slf4j-simple:1.7.25'
testImplementation "junit:junit:4.12"
testImplementation('org.mockito:mockito-core:3.12.4') {
exclude group: 'org.hamcrest'
}
testCompile ("org.powermock:powermock-api-mockito:1.6.4") {
testImplementation ('org.powermock:powermock-api-mockito2:2.0.9') {
exclude group: 'org.hamcrest'
}
testCompile ("org.powermock:powermock-module-junit4:1.6.4") {
testImplementation ('org.powermock:powermock-module-junit4:2.0.9') {
exclude group: 'org.hamcrest'
}
testCompile "org.assertj:assertj-core:2.3.0"
testCompile "com.squareup.okhttp3:mockwebserver:${OKHTTP_VERSION}"
testCompile "commons-io:commons-io:2.4"
testCompile group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.10.0'
testImplementation "org.assertj:assertj-core:2.3.0"
testImplementation "com.squareup.okhttp3:mockwebserver:${OKHTTP_VERSION}"
testImplementation "commons-io:commons-io:2.4"
testImplementation group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.10.0'
}

shadowJar {
classifier = ''
dependencies {
// exclude these from the shadow jar
project.configurations.shadow.each {
Expand Down
14 changes: 6 additions & 8 deletions gradle/integration.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ sourceSets {

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

dependencies {
integrationCompile sourceSets.main.output
integrationCompile configurations.testCompile
integrationCompile sourceSets.test.output
integrationCompile 'com.fieldju:commons:1.1.0'

integrationRuntime configurations.testRuntime
}
integrationCompileClasspath sourceSets.main.output
integrationCompileClasspath configurations.testImplementation
integrationCompileClasspath sourceSets.test.output
integrationCompileClasspath configurations.testImplementation
}
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 @@
#Mon Aug 29 15:51:55 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-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

package com.nike.cerberus.client.auth.aws;

import com.fieldju.commons.EnvUtils;
import com.zookit.commons.EnvUtils;
import com.nike.cerberus.client.CerberusClient;
import com.nike.cerberus.client.CerberusServerApiException;
import com.nike.cerberus.client.CerberusServerException;
import com.nike.cerberus.client.model.CerberusListFilesResponse;
import com.nike.cerberus.client.model.CerberusListResponse;
import com.nike.cerberus.client.model.CerberusResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.nike.cerberus.client.auth.aws;

import com.fieldju.commons.EnvUtils;
import com.zookit.commons.EnvUtils;
import com.nike.cerberus.client.auth.CerberusCredentials;
import org.apache.commons.lang3.StringUtils;
import org.junit.Before;
Expand Down
60 changes: 60 additions & 0 deletions src/integration/java/com/zookit/commons/EnvUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.zookit.commons;

import org.apache.commons.lang3.StringUtils;

/**
* Environment Utilities
* From a trimmed version of com.fieldju.commons.EnvUtils
* https://github.com/fieldju
*/
public class EnvUtils {

/**
* <p>Fetches a required environment variable</p>
*
* @throws IllegalStateException if the required environment variable is unset or blank
* @param key the name of the required environment variable
* @return {@code String} the value of the environment variable
*/
public static String getRequiredEnv(String key) {
return getRequiredEnv(key, null);
}

/**
* <p>Fetches a required environment variable</p>
*
* @throws IllegalStateException if the required environment variable is unset or blank
* @param key the name of the required environment variable
* @param msg the message to include of the environment variable is unset or blank
* @return {@code String} the value of the environment variable
*/
public static String getRequiredEnv(String key, String msg) {
String value = System.getenv(key);
if (StringUtils.isBlank(value)) {
StringBuilder sb = new StringBuilder("The required environment variable ")
.append(key)
.append(" was not set or is blank.");

if (StringUtils.isNotBlank(msg)) {
sb.append(" Msg: ").append(msg);
}

throw new IllegalStateException(sb.toString());
}
return value;
}

/**
* <p>Fetches a required environment variable</p>
*
* @throws IllegalStateException if the required environment variable is unset or blank
* @param key the name of the environment variable to attempt to fetch
* @param defaultValue the default value to use if the environment variable is unset or empty
* @return {@code String} the value of the environment variable or the default, if the environment variable is unset or empty.
*/
public static String getEnvWithDefault(String key, String defaultValue) {
String value = System.getenv(key);
return StringUtils.isNotBlank(value) ? value : defaultValue;
}

}
18 changes: 14 additions & 4 deletions src/main/java/com/nike/cerberus/client/CerberusApiError.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,28 @@
*/

package com.nike.cerberus.client;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public class CerberusApiError {
private int code;
private String message;

/**
* Dummy constructor. This shouldn't be necessary because,
* let's face it, this whole durned class is unnecessary.
* We need to get rid of this class entirely but that's a
* task fo a different day. #codingwhiledrunk
* @param code
* @param message
*/
public CerberusApiError(int code, String message)
{
this.code = code;
this.message = message;
}

public int getCode() {
return code;
}

@SuppressFBWarnings("UWF_UNWRITTEN_FIELD")
public String getMessage() {
return message;
}
Expand Down
Loading