Skip to content

Commit

Permalink
Build: Streamlined dependency and plugin management (#4)
Browse files Browse the repository at this point in the history
* Streamlined dependency and plugin management
- moved code coverage to the common-convertions so it would cover all java libraries
- moved library dependnecy management to libs.toml

* Configuted code coverage

* Code coverage action

* Removed CC
  • Loading branch information
oleg-lvovitch-aws authored Apr 18, 2024
1 parent c329580 commit 7473b1c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 38 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,4 @@ jobs:
- name: Build with Gradle Wrapper
run: ./gradlew build

# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
#
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
# with:
# gradle-version: '8.5'
#
# - name: Build with Gradle 8.5
# run: gradle build

Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@
* This file was generated by the Gradle 'init' task.
*/

val codeCoverageToolVersion = "0.8.11"
val codeCoverageReports = "reports/codeCoverage"
val codeCoverageThreshold = "0.95".toBigDecimal()

plugins {
// Apply the java Plugin to add support for Java.
java

// Code coverage
jacoco
}

jacoco {
toolVersion = codeCoverageToolVersion
reportsDirectory = layout.buildDirectory.dir(codeCoverageReports)
}

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

dependencies {
// Use JUnit Jupiter for testing.
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
testImplementation("org.mockito:mockito-core:4.11.0")
testImplementation("org.mockito:mockito-junit-jupiter:4.11.0")

testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
Expand All @@ -32,3 +35,27 @@ tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

tasks.test {
// Report is generated and verification is run after tests
finalizedBy(tasks.jacocoTestReport, tasks.jacocoTestCoverageVerification)
}

tasks.jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = codeCoverageThreshold
}
}
}
}

tasks.jacocoTestReport {
reports {
xml.required = true
csv.required = false
}

dependsOn(tasks.test) // tests are required to run before generating the report
}
13 changes: 13 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[versions]
junit = "5.10.1"
mockito = "4.11.0"

[libraries]
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
junit-jupiter-launcher = { module = "org.junit.platform:junit-platform-launcher" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }




23 changes: 4 additions & 19 deletions input-stream/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,14 @@

plugins {
id("buildlogic.java-library-conventions")
id("jacoco")
}

dependencies {
api(project(":object-client"))
}

tasks.test {
// Report is generated and verification is run after tests
finalizedBy(tasks.jacocoTestReport, tasks.jacocoTestCoverageVerification)
}

tasks.jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = "0.95".toBigDecimal()
}
}
}
}

tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
testImplementation(libs.junit.jupiter)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.junit.jupiter)
testRuntimeOnly(libs.junit.jupiter.launcher)
}

8 changes: 8 additions & 0 deletions object-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
plugins {
id("buildlogic.java-library-conventions")
}

dependencies {

testImplementation(libs.junit.jupiter)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.junit.jupiter)
testRuntimeOnly(libs.junit.jupiter.launcher)
}

0 comments on commit 7473b1c

Please sign in to comment.