Skip to content

Commit

Permalink
refactor: Consolidate versions and gradle builds (#143)
Browse files Browse the repository at this point in the history
*Issue #, if available:*
- Some of our dependencies need to be kept in sync
(hadoop/spark/freefair/etc). Dependabot doesn't update more than one at
a time unless the version is parameterized.

*Description of changes:*
- Consolidates `gradle.build` file similarities
- Migrates versions that are coupled to parameters
- Based on behavior mentioned in the comments here:
dependabot/dependabot-core#1618

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
  • Loading branch information
Snidd111 authored Mar 31, 2023
1 parent ae21a54 commit 2e2ab12
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 322 deletions.
94 changes: 94 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
subprojects {
/*
Applies core Gradle plugins, which are ones built into Gradle itself.
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

apply plugin: 'java'

// JaCoCo for coverage metrics and reports of Java source files. Read more at:
// https://docs.gradle.org/current/userguide/jacoco_plugin.html
apply plugin: 'jacoco'

// Checkstyle for style checks and reports on Java source files. Read more at:
// https://docs.gradle.org/current/userguide/checkstyle_plugin.html
apply plugin: 'checkstyle'

ext.freefair_version = '8.0.1'
ext.junit_version = '5.9.2'
ext.log4j_version = '2.20.0'
ext.mockito_version = '5.2.0'

dependencies {
// Logging
implementation "org.apache.logging.log4j:log4j-api:$log4j_version"
implementation "org.apache.logging.log4j:log4j-core:$log4j_version"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"

// Test infrastructure
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"

// Test mocking
testImplementation "org.mockito:mockito-core:$mockito_version"
testImplementation "org.mockito:mockito-inline:$mockito_version"
}


check.dependsOn jacocoTestCoverageVerification
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.85
}
}
}
}

jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
csv.required = true
html.required = true
}
}

/*
Configures the Checkstyle "checkstyle" plugin. Remove this and the plugin if
you want to skip these checks and report generation.
*/
checkstyle {
sourceSets = [sourceSets.main, sourceSets.test]
configFile = file('../config/checkstyle/checkstyle.xml')
configProperties.put('checkstyle.suppression.filter', '../config/checkstyle/suppressions.xml')
configDirectory.set(file('../config/checkstyle'))
ignoreFailures = false
}

tasks.withType(JavaCompile) {
options.release = 11
}

tasks.withType(Javadoc) {
options.addBooleanOption("Xdoclint:-missing", true)
}

jar {
manifest {
attributes('Multi-Release': true)
}
}
}
90 changes: 2 additions & 88 deletions c3r-cli/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
/*
Applies core Gradle plugins, which are ones built into Gradle itself.
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
}

plugins {
// Java for compile and unit test of Java source files. Read more at:
// https://docs.gradle.org/current/userguide/java_plugin.html
id 'java'

// Checkstyle for style checks and reports on Java source files. Read more at:
// https://docs.gradle.org/current/userguide/checkstyle_plugin.html
id 'checkstyle'

// JaCoCo for coverage metrics and reports of Java source files. Read more at:
// https://docs.gradle.org/current/userguide/jacoco_plugin.html
id 'jacoco'

// Support using this application on the CLI
id 'application'

Expand All @@ -34,35 +11,18 @@ plugins {

// Vanilla code generation. Read more at:
// https://projectlombok.org/
id "io.freefair.lombok" version "8.0.1"
id "io.freefair.lombok" version "$freefair_version"

// Aggregate Javadoc generation. Read more at:
// https://docs.freefair.io/gradle-plugins/6.6.1/reference/#_io_freefair_javadocs
id 'io.freefair.javadocs' version "8.0.1"
id 'io.freefair.javadocs' version "$freefair_version"
}

// SpotBugs for quality checks and reports of source files. Read more at:
// https://spotbugs.readthedocs.io/en/stable/gradle.html
apply plugin: 'com.github.spotbugs'
apply plugin: 'com.github.johnrengelman.shadow'

/*
Configures the Checkstyle "checkstyle" plugin. Remove this and the plugin if
you want to skip these checks and report generation.
*/
checkstyle {
sourceSets = [sourceSets.main, sourceSets.test]
configFile = file('../config/checkstyle/checkstyle.xml')
configProperties.put('checkstyle.suppression.filter', '../config/checkstyle/suppressions.xml')
configDirectory.set(file('../config/checkstyle'))
ignoreFailures = false
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

/*
Configures the SpotBugs "com.github.spotbugs" plugin. Remove this and the
plugin to skip these checks and report generation.
Expand All @@ -78,11 +38,6 @@ dependencies {
implementation project(":c3r-sdk-core")
implementation project(":c3r-sdk-parquet")

// Logging
implementation 'org.apache.logging.log4j:log4j-api:2.20.0'
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'

// CLI
implementation 'info.picocli:picocli:4.7.1'

Expand All @@ -97,14 +52,6 @@ dependencies {
// Parsing - CSV
testImplementation 'com.univocity:univocity-parsers:2.9.1'

// Mocks
testImplementation 'org.mockito:mockito-core:5.2.0'

// Test infrastructure
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'

// Logging test tools
testImplementation 'io.github.hakky54:logcaptor:2.9.0'
}
Expand Down Expand Up @@ -156,35 +103,6 @@ tasks.register('badEnvironmentVariableTest', Test) {

check.dependsOn badEnvironmentVariableTest

jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
csv.required = true
html.required = true
}
}

check.dependsOn jacocoTestCoverageVerification
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.85
}
}
}
}

tasks.withType(JavaCompile) {
options.release = 11
}

jar {
manifest {
attributes('Multi-Release': true)
}
}

configurations {
testImplementation {
exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
Expand All @@ -197,7 +115,3 @@ shadowJar {
zip64 = true
mergeServiceFiles()
}

tasks.withType(Javadoc) {
options.addBooleanOption("Xdoclint:-missing", true)
}
83 changes: 1 addition & 82 deletions c3r-sdk-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
/*
Applies core Gradle plugins, which are ones built into Gradle itself.
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
}

plugins {
// Java compilation, unit tests, and library distribution needs. Read more at:
// https://docs.gradle.org/current/userguide/java_library_plugin.html
id 'java-library'

// Checkstyle for style checks and reports on Java source files. Read more at:
// https://docs.gradle.org/current/userguide/checkstyle_plugin.html
id 'checkstyle'

// JaCoCo for coverage metrics and reports of Java source files. Read more at:
// https://docs.gradle.org/current/userguide/jacoco_plugin.html
id 'jacoco'

// Maven publishing needs
id 'maven-publish'

Expand All @@ -34,28 +15,11 @@ plugins {

// Vanilla code generation. Read more at:
// https://projectlombok.org/
id "io.freefair.lombok" version "8.0.1"
id "io.freefair.lombok" version "$freefair_version"
}

apply plugin: 'com.github.spotbugs'

/*
Configures the Checkstyle "checkstyle" plugin. Remove this and the plugin if
you want to skip these checks and report generation.
*/
checkstyle {
sourceSets = [sourceSets.main, sourceSets.test]
configFile = file('../config/checkstyle/checkstyle.xml')
configProperties.put('checkstyle.suppression.filter', '../config/checkstyle/suppressions.xml')
configDirectory.set(file('../config/checkstyle'))
ignoreFailures = false
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

/*
Configures the SpotBugs "com.github.spotbugs" plugin. Remove this and the
plugin to skip these checks and report generation.
Expand All @@ -67,11 +31,6 @@ spotbugs {
}

dependencies {
// Logging
implementation 'org.apache.logging.log4j:log4j-api:2.20.0'
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'

// AWS Clean Rooms
implementation 'software.amazon.awssdk:cleanrooms:2.20.35'

Expand All @@ -87,12 +46,6 @@ dependencies {
// https://mvnrepository.com/artifact/com.github.spotbugs/spotbugs-annotations
implementation 'com.github.spotbugs:spotbugs-annotations:4.7.3'

// Testing
testImplementation 'org.mockito:mockito-core:5.2.0'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'

// Logging test tools
testImplementation 'io.github.hakky54:logcaptor:2.9.0'
}
Expand Down Expand Up @@ -139,36 +92,6 @@ tasks.register('checkFileUtilTest', Test) {

check.dependsOn checkFileUtilTest


jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
csv.required = true
html.required = true
}
}

check.dependsOn jacocoTestCoverageVerification
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.85
}
}
}
}

tasks.withType(JavaCompile) {
options.release = 11
}

jar {
manifest {
attributes('Multi-Release': true)
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = "sources"
from sourceSets.main.allSource
Expand Down Expand Up @@ -246,7 +169,3 @@ publishing {
signing {
sign publishing.publications.maven
}

tasks.withType(Javadoc) {
options.addBooleanOption("Xdoclint:-missing", true)
}
Loading

0 comments on commit 2e2ab12

Please sign in to comment.