Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare for kotlin 1.8 usage #60

Merged
merged 2 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 16
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
`maven-publish`
id("org.jmailen.kotlinter")
id("org.jlleitschuh.gradle.ktlint")
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
id("com.gradle.plugin-publish")
Expand All @@ -18,7 +18,7 @@ group = "dev.mythicdrops"

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
languageVersion.set(JavaLanguageVersion.of(17))
}
withJavadocJar()
withSourcesJar()
Expand Down Expand Up @@ -132,7 +132,7 @@ dependencies {
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:_")

// ktlint plugin
implementation("org.jmailen.gradle:kotlinter-gradle:_")
implementation("org.jlleitschuh.gradle:ktlint-gradle:_")

// gradle nexus publish plugin
implementation("io.github.gradle-nexus:publish-plugin:_")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ import org.gradle.testing.jacoco.plugins.JacocoPlugin
import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
import org.gradle.testing.jacoco.tasks.JacocoReport

val DEFAULT_JAVA_VERSION = JavaVersion.VERSION_17

/**
* Plugin that configures Java for JDK 16 and enables JaCoCo.
* Plugin that configures Java for JDK 17 and enables JaCoCo.
*/
open class MythicDropsJavaPlugin : DependentPlugin("Java", "java") {
override fun configureProject(target: Project) {
val javaExtension = target.extensions.create<MythicDropsJavaExtension>("mythicDropsJava")
javaExtension.apply {
javaVersion.convention(JavaVersion.VERSION_16)
// default to Java 17
javaVersion.convention(DEFAULT_JAVA_VERSION)
}

// target JDK 16
target.configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaExtension.javaVersion.get().majorVersion))
Expand All @@ -40,7 +42,7 @@ open class MythicDropsJavaPlugin : DependentPlugin("Java", "java") {
// enable and configure JaCoCo
target.pluginManager.apply(JacocoPlugin::class.java)
target.configure<JacocoPluginExtension> {
toolVersion = "0.8.7"
toolVersion = "0.8.8"
}
target.tasks.withType<JacocoReport> {
reports {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,37 @@ import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.konan.file.File
import org.jmailen.gradle.kotlinter.KotlinterPlugin
import org.jmailen.gradle.kotlinter.tasks.FormatTask
import org.jmailen.gradle.kotlinter.tasks.LintTask
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import org.jlleitschuh.gradle.ktlint.KtlintPlugin

/**
* Plugin that configures Kotlin for JDK 16, enables Detekt, and enables/configures KTLint to use 0.46.0.
* Plugin that configures Kotlin for JDK 17, enables Detekt, and enables/configures KTLint to use 0.48.1.
*/
open class MythicDropsKotlinJvmPlugin : DependentPlugin("Kotlin JVM", "org.jetbrains.kotlin.jvm") {
override fun configureProject(target: Project) {
val javaExtension = target.extensions.getByType<MythicDropsJavaExtension>()
val javaExtension =
target.extensions.getByType<MythicDropsJavaExtension>().apply {
javaVersion.convention(DEFAULT_JAVA_VERSION)
}

// apply plugins
target.pluginManager.apply(DetektPlugin::class.java)
target.pluginManager.apply(DokkaPlugin::class.java)
target.pluginManager.apply(KotlinterPlugin::class.java)
target.pluginManager.apply(KtlintPlugin::class.java)

// configure kotlin to use JDK 16
target.configure<KotlinJvmProjectExtension> {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(javaExtension.javaVersion.get().majorVersion))
}
}

// exclude files from the build directory from being linted or formatted
target.tasks.withType<FormatTask> {
exclude { fte -> fte.file.absolutePath.contains("${File.separator}build${File.separator}") }
}
target.tasks.withType<LintTask> {
exclude { fte -> fte.file.absolutePath.contains("${File.separator}build${File.separator}") }
target.configure<KtlintExtension> {
// ktlint version that supports kotlin 1.8.0
version.set("0.48.1")
filter {
exclude("**/build/**")
}
}

target.tasks.withType<KotlinCompile> {
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=3.3.*
version=4.0.*
6 changes: 3 additions & 3 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugin.io.gitlab.arturbosch.detekt=1.22.0

plugin.org.jetbrains.dokka=1.7.20

plugin.org.jmailen.kotlinter=3.12.0
plugin.org.jlleitschuh.gradle.ktlint=11.2.0

plugin.org.shipkit.shipkit-auto-version=1.2.2

Expand All @@ -33,11 +33,11 @@ version.org.jetbrains.dokka..dokka-core=1.7.20

version.org.jetbrains.dokka..dokka-gradle-plugin=1.7.20

version.com.netflix.nebula..nebula-project-plugin=10.0.1
version.com.netflix.nebula..nebula-project-plugin=10.1.2

version.io.gitlab.arturbosch.detekt..detekt-gradle-plugin=1.22.0

version.org.jmailen.gradle..kotlinter-gradle=3.12.0
version.org.jlleitschuh.gradle..ktlint-gradle=11.2.0

version.io.github.gradle-nexus..publish-plugin=1.1.0

Expand Down