Skip to content

Commit

Permalink
update to ktlint 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ToppleTheNun committed Sep 23, 2023
1 parent 7b10ba8 commit 4a7dc9b
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 40 deletions.
17 changes: 11 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ gradlePlugin {
}
}

ktlint {
version.set("1.0.0")
}

tasks {
// get dokkaJavadoc task and make javadocJar depend on it
val dokkaJavadoc by this
Expand Down Expand Up @@ -121,16 +125,17 @@ tasks {
"javadocJar",
"sourcesJar",
"generateMetadataFileForPluginMavenPublication",
"generatePomFileForPluginMavenPublication"
"generatePomFileForPluginMavenPublication",
)
}

// Make GitHub release depend on generating a changelog
val generateChangelog = getByName<org.shipkit.changelog.GenerateChangelogTask>("generateChangelog") {
previousRevision = project.ext.get("shipkit-auto-version.previous-tag")?.toString()
githubToken = System.getenv("GITHUB_TOKEN")
repository = "MythicDrops/mythicdrops-gradle-plugin"
}
val generateChangelog =
getByName<org.shipkit.changelog.GenerateChangelogTask>("generateChangelog") {
previousRevision = project.ext.get("shipkit-auto-version.previous-tag")?.toString()
githubToken = System.getenv("GITHUB_TOKEN")
repository = "MythicDrops/mythicdrops-gradle-plugin"
}
getByName<org.shipkit.github.release.GithubReleaseTask>("githubRelease") {
dependsOn(generateChangelog)
repository = generateChangelog.repository
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pluginManagement {
plugins {
// See https://jmfayard.github.io/refreshVersions
id("de.fayard.refreshVersions") version "0.60.2"
id("com.gradle.enterprise") version "3.14.1"
id("com.gradle.enterprise") version "3.15"
}

gradleEnterprise {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import org.gradle.api.logging.LogLevel
*/
abstract class DependentPlugin(
private val pluginDescription: String,
private val prerequisitePluginId: String
private val prerequisitePluginId: String,
) : Plugin<Project> {
override fun apply(target: Project) {
target.pluginManager.withPlugin(prerequisitePluginId) {
target.logger.log(
LogLevel.INFO,
"Applying MythicDrops {} plugin as the \"{}\" plugin is applied",
pluginDescription,
prerequisitePluginId
prerequisitePluginId,
)
configureProject(target)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ val DEFAULT_JAVA_VERSION = JavaVersion.VERSION_17
*/
open class MythicDropsJavaPlugin : DependentPlugin("Java", "java") {
override fun configureProject(target: Project) {
val javaExtension = target.extensions.create<MythicDropsJavaExtension>("mythicDropsJava").apply {
// default to Java 17
javaVersion.convention(DEFAULT_JAVA_VERSION)
}
val javaExtension =
target.extensions.create<MythicDropsJavaExtension>("mythicDropsJava").apply {
// default to Java 17
javaVersion.convention(DEFAULT_JAVA_VERSION)
}

target.configure<JavaPluginExtension> {
toolchain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class MythicDropsKotlinJvmPlugin : DependentPlugin("Kotlin JVM", "org.jetbr

// exclude files from the build directory from being linted or formatted
target.configure<KtlintExtension> {
version.set("0.50.0")
version.set("1.0.0")
filter {
exclude { entry ->
entry.file.toString().contains("generated")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ open class MythicDropsMavenPublishPlugin : DependentPlugin("Maven Publish", "mav
// we only add compileOnly dependencies if the configuration even exists
val dependencies = project.configurations.findByName("compileOnly")?.dependencies ?: return@withXml
if (dependencies.size > 0) {
val deps = root.children().find {
it is groovy.util.Node && it.name().toString()
.endsWith("dependencies")
} as groovy.util.Node? ?: root.appendNode("dependencies")
val deps =
root.children().find {
it is groovy.util.Node &&
it.name().toString()
.endsWith("dependencies")
} as groovy.util.Node? ?: root.appendNode("dependencies")
dependencies.forEach { dependency ->
deps.appendNode("dependency").apply {
appendNode("groupId", dependency.group)
Expand All @@ -72,23 +74,24 @@ open class MythicDropsMavenPublishPlugin : DependentPlugin("Maven Publish", "mav

private data class SigningParams(
val pgpKey: String,
val pgpPwd: String
val pgpPwd: String,
)

/**
* Gets the nullable params needed for signing and configuring Sonatype.
*/
private data class SigningNullableParams(
val pgpKey: String? = System.getenv("PGP_KEY"),
val pgpPwd: String? = System.getenv("PGP_PWD")
val pgpPwd: String? = System.getenv("PGP_PWD"),
) {
/**
* Converts to a non-nullable version of the params, returning null if any values are null.
*/
fun toSigningParams(): SigningParams? = when {
pgpKey == null -> null
pgpPwd == null -> null
else -> SigningParams(pgpKey, pgpPwd)
}
fun toSigningParams(): SigningParams? =
when {
pgpKey == null -> null
pgpPwd == null -> null
else -> SigningParams(pgpKey, pgpPwd)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ abstract class MythicDropsGitHubReleaseAssetUploadTask : DefaultTask() {
}

val github = GitHubBuilder().withOAuthToken(githubToken.get()).build()
val githubRepository = github.getRepository(repository.get())
?: throw IllegalArgumentException("${repository.get()} does not exist")
val githubRelease = githubRepository.getReleaseByTagName(releaseTag.get())
?: throw IllegalArgumentException("Release by tag name ${releaseTag.get()} does not exist")
val githubRepository =
github.getRepository(repository.get())
?: throw IllegalArgumentException("${repository.get()} does not exist")
val githubRelease =
githubRepository.getReleaseByTagName(releaseTag.get())
?: throw IllegalArgumentException("Release by tag name ${releaseTag.get()} does not exist")

assets.forEach {
val contentType = Files.probeContentType(it.toPath())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open class MythicDropsNexusStagingPlugin : Plugin<Project> {

private fun enableSonatypePublishing(
sonatypeParams: SonatypeParams?,
target: Project
target: Project,
) {
if (sonatypeParams == null) {
// if any environment variables are null, do not enable Sonatype publishing or signing
Expand All @@ -41,23 +41,24 @@ open class MythicDropsNexusStagingPlugin : Plugin<Project> {

private data class SonatypeParams(
val sonatypeUser: String,
val sonatypePwd: String
val sonatypePwd: String,
)

/**
* Gets the nullable params needed for signing and configuring Sonatype.
*/
private data class SonatypeNullableParams(
val sonatypeUser: String? = System.getenv("SONATYPE_USER"),
val sonatypePwd: String? = System.getenv("SONATYPE_PWD")
val sonatypePwd: String? = System.getenv("SONATYPE_PWD"),
) {
/**
* Converts to a non-nullable version of the params, returning null if any values are null.
*/
fun toSonatypeParams(): SonatypeParams? = when {
sonatypeUser == null -> null
sonatypePwd == null -> null
else -> SonatypeParams(sonatypeUser, sonatypePwd)
}
fun toSonatypeParams(): SonatypeParams? =
when {
sonatypeUser == null -> null
sonatypePwd == null -> null
else -> SonatypeParams(sonatypeUser, sonatypePwd)
}
}
}
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=6.0.*
version=6.1.*
4 changes: 2 additions & 2 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.23.1

plugin.org.jetbrains.dokka=1.9.0

plugin.org.jlleitschuh.gradle.ktlint=11.5.1
plugin.org.jlleitschuh.gradle.ktlint=11.6.0

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

Expand All @@ -37,7 +37,7 @@ version.com.netflix.nebula..nebula-project-plugin=10.1.5

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

version.org.jlleitschuh.gradle..ktlint-gradle=11.5.1
version.org.jlleitschuh.gradle..ktlint-gradle=11.6.0

version.io.github.gradle-nexus..publish-plugin=1.3.0
## # available=2.0.0-rc-1
Expand Down

0 comments on commit 4a7dc9b

Please sign in to comment.