Skip to content

Commit

Permalink
Merge pull request #106 from ekino/feat/gradle-8
Browse files Browse the repository at this point in the history
chore: upgrade to Gradle 8
  • Loading branch information
celcius112 authored Mar 10, 2023
2 parents 7d31717 + 9ca7fac commit 92526c8
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[*.{kt,kts}]
indent_size=2
max_line_length=180
disabled_rules=import-ordering
ktlint_disabled_rules=import-ordering
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This plugin configures the following tasks for any ekino Kotlin project :

You need to have a JDK 11 at least.

It requires Gradle 7.0.2 or later.
It requires Gradle 7.6.2 or later.

## Usage

Expand Down
20 changes: 8 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ plugins {
`kotlin-dsl`
`java-gradle-plugin`

id("org.sonarqube") version "3.5.0.2730"
jacoco

id("org.jlleitschuh.gradle.ktlint") version "11.1.0"
id("org.jlleitschuh.gradle.ktlint") version "11.3.1"
id("io.gitlab.arturbosch.detekt") version "1.22.0"
id("com.gradle.plugin-publish") version "1.1.0"
}

group = "com.ekino.oss.plugin"
version = "3.3.1"
version = "4.0.0"
findProperty("releaseVersion")?.let { version = it }

repositories {
Expand All @@ -22,8 +21,8 @@ repositories {
}

dependencies {
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3")
implementation("org.jlleitschuh.gradle:ktlint-gradle:10.1.0")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.0.0.2929")
implementation("org.jlleitschuh.gradle.ktlint:org.jlleitschuh.gradle.ktlint.gradle.plugin:11.0.0")
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.22.0")

testImplementation(gradleTestKit())
Expand Down Expand Up @@ -51,11 +50,15 @@ configure<DetektExtension> {
}

gradlePlugin {
website.set("https://github.com/ekino/kotlin-quality-plugin")
vcsUrl.set("https://github.com/ekino/kotlin-quality-plugin")
plugins {
create("kotlin-quality") {
id = "com.ekino.oss.plugin.kotlin-quality"
implementationClass = "com.ekino.oss.plugin.KotlinQualityPlugin"
displayName = "Kotlin Quality plugin"
description = "Kotlin Quality plugin for Ekino projects"
tags.set(listOf("ekino", "kotlin", "quality", "ktlint", "detekt", "sonarqube"))
}
}
}
Expand All @@ -65,10 +68,3 @@ ktlint {
include("src/**/*.kt")
}
}

pluginBundle {
website = "https://github.com/ekino/kotlin-quality-plugin"
vcsUrl = "https://github.com/ekino/kotlin-quality-plugin"
description = "Kotlin Quality plugin for Ekino projects"
tags = listOf("ekino", "kotlin", "quality", "ktlint", "detekt", "sonarqube")
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
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"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
24 changes: 9 additions & 15 deletions src/main/kotlin/com/ekino/oss/plugin/KotlinQualityPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,45 @@ import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.gradle.testing.jacoco.plugins.JacocoPlugin
import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
import org.gradle.testing.jacoco.plugins.JacocoReportAggregationPlugin
import org.gradle.testing.jacoco.tasks.JacocoReport
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import org.jlleitschuh.gradle.ktlint.KtlintPlugin
import org.sonarqube.gradle.SonarQubeExtension
import org.sonarqube.gradle.SonarExtension
import org.sonarqube.gradle.SonarQubePlugin
import java.nio.file.Files
import java.nio.file.StandardCopyOption

/**
* Kotlin Quality plugin.
*/
class KotlinQualityPlugin : Plugin<Project> {
override fun apply(project: Project) {

with(project) {

val extension = extensions.create<KotlinQualityPluginExtension>("kotlinQuality")

apply<JavaPlugin>()
apply<JacocoPlugin>()
apply<SonarQubePlugin>()
apply<KtlintPlugin>()
apply<DetektPlugin>()
apply<JacocoReportAggregationPlugin>()

val jacocoXmlReportPath = "$buildDir/reports/jacoco/test/jacocoTestReport.xml"

tasks.withType<JacocoReport> {
val jacocoTestReports = tasks.withType<JacocoReport> {
reports {
xml.outputLocation.set(file(jacocoXmlReportPath))
xml.required.set(true)
csv.required.set(false)
html.required.set(false)
html.required.set(true)
}
}

configure<JacocoPluginExtension> {
toolVersion = "0.8.8"
}

configure<SonarQubeExtension> {
configure<SonarExtension> {
properties {
property("sonar.projectName", project.name)
property("sonar.sourceEncoding", "UTF-8")
property("sonar.host.url", extension.sonarUrl)
property("sonar.coverage.jacoco.xmlReportPaths", jacocoXmlReportPath)
property("sonar.coverage.jacoco.xmlReportPaths", "$buildDir/reports/jacoco/test/jacocoTestReport.xml")
}
}

Expand All @@ -73,7 +67,7 @@ class KotlinQualityPlugin : Plugin<Project> {
}

tasks.named(BUILD_GROUP) {
dependsOn("jacocoTestReport")
dependsOn(jacocoTestReports)
}
}
}
Expand All @@ -82,7 +76,7 @@ class KotlinQualityPlugin : Plugin<Project> {
with(project) {
val configTempFile = Files.createTempFile("detekt-config-", ".yml")
Files.copy(
KotlinQualityPlugin::class.java.getResourceAsStream("/detekt-config.yml"),
KotlinQualityPlugin::class.java.getResourceAsStream("/detekt-config.yml")!!,
configTempFile,
StandardCopyOption.REPLACE_EXISTING
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/detekt-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
maxIssues: 0

complexity:
ComplexMethod:
CyclomaticComplexMethod:
ignoreSimpleWhenEntries: true
threshold: 11
LongParameterList:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GradleVersionsCompatibilityTest {
@TempDir
lateinit var tempDir: File

@ValueSource(strings = ["7.0.2", "7.1.1", "7.2", "7.3.3", "7.4.2", "7.5.1"])
@ValueSource(strings = ["7.6.1", "8.0.2"])
@ParameterizedTest(name = "Gradle {0}")
@DisplayName("Should work in Gradle version")
fun shouldWorkInGradleVersion(gradleVersion: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class KotlinQualityPluginTest {

@Test
fun `Should contain configured tasks`() {

val project: Project = ProjectBuilder.builder().build()

project.plugins.apply("com.ekino.oss.plugin.kotlin-quality")
Expand Down

0 comments on commit 92526c8

Please sign in to comment.