Skip to content

Commit

Permalink
Merge pull request #88 from ekino/chore/up
Browse files Browse the repository at this point in the history
upgrade to gradle 8.1 + use configuration avoidance api
  • Loading branch information
celcius112 authored Apr 20, 2023
2 parents 2525f8c + 176b4cd commit c490041
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ Add the plugin in your Gradle build script:
Groovy
```groovy
plugins {
id "com.ekino.oss.gradle.plugin.quality" version "2.0.0"
id "com.ekino.oss.gradle.plugin.quality" version "2.1.0"
}
```

Kotlin
```kotlin
plugins {
id("com.ekino.oss.gradle.plugin.quality") version "2.0.0"
id("com.ekino.oss.gradle.plugin.quality") version "2.1.0"
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Project information
group = com.ekino.oss.gradle.plugin
description = Gradle Plugin for Quality management
version = 2.0.0
version = 2.1.0
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 4 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.gradle.testing.jacoco.tasks.JacocoReport
import org.sonarqube.gradle.SonarExtension
import org.sonarqube.gradle.SonarQubePlugin

class QualityPlugin: Plugin<Project> {
class QualityPlugin : Plugin<Project> {

override fun apply(project: Project) {
with(project) {
Expand All @@ -50,14 +50,16 @@ class QualityPlugin: Plugin<Project> {
}

// Jacoco configuration
val jacocoTestReports = tasks.withType<JacocoReport> {
doFirst {
println("Generating jacoco coverage report in HTML ...")
}
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(true)
val jacocoTestReports = tasks.withType<JacocoReport>().also {
it.configureEach {
doFirst {
println("Generating jacoco coverage report in HTML ...")
}
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(true)
}
}
}

Expand All @@ -66,12 +68,10 @@ class QualityPlugin: Plugin<Project> {
mustRunAfter(jacocoTestReports)
}

tasks.named("build") {
dependsOn(jacocoTestReports, printCoverage)
}

if (project.hasProperty("sonarCoverageExclusions")) {
val excludes = (findProperty("sonarCoverageExclusions") as String).replace(".java", ".class").split(",\\s*".toRegex())
val excludes = (findProperty("sonarCoverageExclusions") as String)
.replace(".java", ".class")
.split(",\\s*".toRegex())
afterEvaluate {
jacocoTestReports.configureEach {
classDirectories.setFrom(sourceSets["main"].output.classesDirs.asFileTree.matching {
Expand All @@ -81,6 +81,10 @@ class QualityPlugin: Plugin<Project> {
}
}

tasks.named("build") {
dependsOn(jacocoTestReports, printCoverage)
}

// Sonar configuration
configure<SonarExtension> {
properties {
Expand All @@ -96,7 +100,7 @@ class QualityPlugin: Plugin<Project> {
}

internal fun getCheckstyleConfig() = getFilePath()?.use { String(it.readBytes()) }
?: throw MissingResourceException("The checkstyle config file cannot be found")
?: throw MissingResourceException("The checkstyle config file cannot be found")

internal fun getFilePath() = QualityPlugin::class.java.classLoader?.getResourceAsStream("checkstyle.xml")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GradleVersionsCompatibilityTest {
@TempDir
private lateinit var tempDir: File

@ValueSource(strings = ["7.6.1", "8.0.2"])
@ValueSource(strings = ["7.6.1", "8.1"])
@ParameterizedTest(name = "Gradle {0}")
fun `Should work in gradle version`(gradleVersion: String) {
val buildScript =
Expand All @@ -30,7 +30,7 @@ class GradleVersionsCompatibilityTest {
.withProjectDir(tempDir)
.withGradleVersion(gradleVersion)
.withPluginClasspath()
.withArguments("build", "--stacktrace")
.withArguments("build")
.forwardOutput()
.build()

Expand Down

0 comments on commit c490041

Please sign in to comment.