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

Use Autostyle for formatting #12

Closed
wants to merge 1 commit into from
Closed
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
37 changes: 31 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
/*
* Copyright 2019 the original author or authors.
*
* 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.
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
`kotlin-dsl`
`maven-publish`
id("com.gradle.plugin-publish") version "0.10.1"
id("com.diffplug.gradle.spotless") version "3.27.0"
id("com.github.autostyle") version "3.0"
id("com.github.johnrengelman.shadow") version "5.2.0"
id("org.jetbrains.gradle.plugin.idea-ext")
id("com.github.ben-manes.versions") version "0.27.0"
Expand Down Expand Up @@ -41,11 +57,21 @@ repositories {
jcenter()
}

val licenseHeaderFile = file("gradle/license-header.txt")
spotless {
val licenseHeader = file("gradle/license-header.txt").readText().trimEnd()
autostyle {
kotlin {
ktlint()
licenseHeaderFile(licenseHeaderFile)
licenseHeader(licenseHeader) {
addBlankLineAfter.set(true)
}
trimTrailingWhitespace()
}
kotlinGradle {
ktlint()
licenseHeader(licenseHeader) {
addBlankLineAfter.set(true)
}
trimTrailingWhitespace()
}
}

Expand All @@ -56,7 +82,7 @@ idea {
useDefault = "Apache-2.0"
profiles {
create("Apache-2.0") {
notice = readCopyrightHeader(licenseHeaderFile)
notice = licenseHeader
keyword = "Copyright"
}
}
Expand Down Expand Up @@ -209,4 +235,3 @@ publishing {
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}

27 changes: 12 additions & 15 deletions gradle/license-header.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
/*
* Copyright 2019 the original author or authors.
*
* 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 the original author or authors.

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.
16 changes: 16 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2019 the original author or authors.
*
* 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.
*/

plugins {
id("com.gradle.enterprise") version "3.1.1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class NexusPublishPluginTests {
""")
projectDir.resolve("build.gradle").write("""
import java.time.Duration

plugins {
id('java-library')
id('io.github.gradle-nexus.publish-plugin')
Expand Down Expand Up @@ -485,7 +485,7 @@ class NexusPublishPluginTests {
""")
projectDir.resolve("build.gradle").write("""
import java.time.Duration

plugins {
id('java-library')
id('io.github.gradle-nexus.publish-plugin')
Expand Down