From 8f9353cfd788508bdcecf6469c0054757afb295b Mon Sep 17 00:00:00 2001 From: Vladimir Sitnikov Date: Sat, 28 Dec 2019 19:10:18 +0300 Subject: [PATCH] Replace Spotless -> Autostyle --- README.md | 3 ++ build.gradle.kts | 33 +++++++------------ buildSrc/build.gradle.kts | 18 ++++++++++ buildSrc/checksum.xml | 16 +++++++++ buildSrc/settings.gradle.kts | 6 ++-- .../gradle/buildtools/CopySpecExtensions.kt | 1 - .../vlsi/gradle/license/EnumGeneratorTask.kt | 3 +- .../vlsi/gradle/license/LicenseTextsPlugin.kt | 1 - checksum.xml | 3 +- gradle/license-header.txt | 29 ++++++++-------- 10 files changed, 67 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 281e556..c02373c 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,9 @@ This library is distributed under terms of Apache License 2.0 Change log ---------- +HEAD +* Replace Spotless -> [Autostyle](https://github.com/autostyle/autostyle) for simpler code style management + v1.53 * stage-vote-release-plugin: expose NexusConfig#mavenCentral to enable publishing to Central diff --git a/build.gradle.kts b/build.gradle.kts index 75ec065..490fe34 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,7 +23,7 @@ plugins { `kotlin-dsl` `maven-publish` id("com.gradle.plugin-publish") version "0.10.1" apply false - id("com.diffplug.gradle.spotless") version "3.25.0" + id("com.github.autostyle") version "3.0" id("org.jetbrains.gradle.plugin.idea-ext") version "0.5" id("com.github.ben-manes.versions") version "0.21.0" id("org.jetbrains.dokka") version "0.9.17" @@ -59,18 +59,22 @@ allprojects { } } -val licenseHeaderFile = file("gradle/license-header.txt") +val licenseHeader = file("gradle/license-header.txt").readText() allprojects { if (project.path != ":plugins:license-gather-plugin") { - apply(plugin = "com.diffplug.gradle.spotless") - spotless { + apply(plugin = "com.github.autostyle") + autostyle { kotlin { + licenseHeader(licenseHeader) + trimTrailingWhitespace() // Generated build/generated-sources/licenses/com/github/vlsi/gradle/license/api/License.kt // has wrong indentation, and it is not clear how to exclude it - ktlint().userData(mapOf("disabled_rules" to "no-wildcard-imports,import-ordering")) + ktlint { + userData(mapOf("disabled_rules" to "no-wildcard-imports,import-ordering")) + } // It prints errors regarding build/generated-sources/licenses/com/github/vlsi/gradle/license/api/License.kt // so comment it for now :( - licenseHeaderFile(licenseHeaderFile) + endWithNewline() } } } @@ -98,22 +102,7 @@ idea { profiles { create("Apache-2.0") { keyword = "Copyright" - notice = """ - Copyright 2019 Vladimir Sitnikov - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - """.trimIndent() + notice = licenseHeader } } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5e5ef07..f63719e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { `java` `kotlin-dsl` apply false + id("com.github.autostyle") version "3.0" } repositories { @@ -27,12 +28,29 @@ repositories { gradlePluginPortal() } +val licenseHeader = file("$rootDir/../gradle/license-header.txt").readText() allprojects { repositories { jcenter() gradlePluginPortal() } applyKotlinProjectConventions() + + apply(plugin = "com.github.autostyle") + autostyle { + kotlin { + licenseHeader(licenseHeader) + trimTrailingWhitespace() + // Generated build/generated-sources/licenses/com/github/vlsi/gradle/license/api/License.kt + // has wrong indentation, and it is not clear how to exclude it + ktlint { + userData(mapOf("disabled_rules" to "no-wildcard-imports,import-ordering")) + } + // It prints errors regarding build/generated-sources/licenses/com/github/vlsi/gradle/license/api/License.kt + // so comment it for now :( + endWithNewline() + } + } } fun Project.applyKotlinProjectConventions() { diff --git a/buildSrc/checksum.xml b/buildSrc/checksum.xml index 5aae61d..ccac5ee 100644 --- a/buildSrc/checksum.xml +++ b/buildSrc/checksum.xml @@ -3,19 +3,35 @@ + + + + + + + + + + + + + + + + diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index 032bebc..55048e5 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -35,7 +35,7 @@ for (project in rootProject.children) { buildscript { dependencies { - classpath("com.github.vlsi.gradle:checksum-dependency-plugin:1.26.0") { + classpath("com.github.vlsi.gradle:checksum-dependency-plugin:1.45.0") { exclude("org.jetbrains.kotlin", "kotlin-stdlib") } } @@ -54,8 +54,8 @@ val expectedSha512 = mapOf( to "okhttp-4.1.0.jar", "93E7A41BE44CC17FB500EA5CD84D515204C180AEC934491D11FC6A71DAEA761FB0EECEF865D6FD5C3D88AAF55DCE3C2C424BE5BA5D43BEBF48D05F1FA63FA8A7" to "okio-2.2.2.jar", - "2AB28DC6026A9CFC869C6287501D1002B8F2B61C7C3896B61A5616CE686DD41FD22EE9FD2D122111E4DABAA8359A4947C3F43B9DF29B1AFC8AA5D809A8188CAD" - to "checksum-dependency-plugin-1.26.0.jar" + "993FD75CCCE1618BBE64BB2ED55242836C2B01442AD0AE98DA03CD672EAFF935567921304B6E8705AAE87367FDF7B8FF684C992A45E8008DDB4EF7E73FEA4DAD" + to "checksum-dependency-plugin-1.45.0.jar" ) fun File.sha512(): String { diff --git a/buildSrc/src/main/kotlin/com/github/vlsi/gradle/buildtools/CopySpecExtensions.kt b/buildSrc/src/main/kotlin/com/github/vlsi/gradle/buildtools/CopySpecExtensions.kt index d81fbc3..a9a17c9 100644 --- a/buildSrc/src/main/kotlin/com/github/vlsi/gradle/buildtools/CopySpecExtensions.kt +++ b/buildSrc/src/main/kotlin/com/github/vlsi/gradle/buildtools/CopySpecExtensions.kt @@ -14,7 +14,6 @@ * limitations under the License. * */ - package com.github.vlsi.gradle.buildtools import org.apache.tools.ant.filters.FixCrLfFilter diff --git a/buildSrc/subprojects/license-texts/src/main/kotlin/com/github/vlsi/gradle/license/EnumGeneratorTask.kt b/buildSrc/subprojects/license-texts/src/main/kotlin/com/github/vlsi/gradle/license/EnumGeneratorTask.kt index 2b00f99..eb76d87 100644 --- a/buildSrc/subprojects/license-texts/src/main/kotlin/com/github/vlsi/gradle/license/EnumGeneratorTask.kt +++ b/buildSrc/subprojects/license-texts/src/main/kotlin/com/github/vlsi/gradle/license/EnumGeneratorTask.kt @@ -14,7 +14,6 @@ * limitations under the License. * */ - package com.github.vlsi.gradle.license import com.fasterxml.jackson.databind.DeserializationFeature @@ -230,4 +229,4 @@ class EnumItem( val name: String, val detailsUrl: String, val seeAlso: List -) \ No newline at end of file +) diff --git a/buildSrc/subprojects/license-texts/src/main/kotlin/com/github/vlsi/gradle/license/LicenseTextsPlugin.kt b/buildSrc/subprojects/license-texts/src/main/kotlin/com/github/vlsi/gradle/license/LicenseTextsPlugin.kt index 48d8ff9..cfc9d3b 100644 --- a/buildSrc/subprojects/license-texts/src/main/kotlin/com/github/vlsi/gradle/license/LicenseTextsPlugin.kt +++ b/buildSrc/subprojects/license-texts/src/main/kotlin/com/github/vlsi/gradle/license/LicenseTextsPlugin.kt @@ -14,7 +14,6 @@ * limitations under the License. * */ - package com.github.vlsi.gradle.license import org.gradle.api.Plugin diff --git a/checksum.xml b/checksum.xml index 6fa4bdf..da7214f 100644 --- a/checksum.xml +++ b/checksum.xml @@ -4,7 +4,7 @@ - + @@ -42,6 +42,7 @@ + diff --git a/gradle/license-header.txt b/gradle/license-header.txt index f878d62..a37404c 100644 --- a/gradle/license-header.txt +++ b/gradle/license-header.txt @@ -1,16 +1,13 @@ -/* - * Copyright 2019 Vladimir Sitnikov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ +Copyright 2019 Vladimir Sitnikov + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.