-
Notifications
You must be signed in to change notification settings - Fork 506
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
Convert root build.gradle to kts #1663
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ce7264d
Convert root build.gradle to kts
Goooler 11c230a
Cleanup
Goooler 91de455
Merge redundant properties
Goooler 48402d7
Lint kts files
Goooler bbd13ed
Cleanup
Goooler 059aba5
Merge remote-tracking branch 'origin/trunk' into root_kts
Goooler 6a67aa7
Cleanup
Goooler 02a515f
Tweak
Goooler fde5499
Defer more configurations
Goooler 083fecf
Cleanup
Goooler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
plugins { | ||
alias(libs.plugins.kotlin.jvm) apply false | ||
alias(libs.plugins.checksum) | ||
alias(libs.plugins.shadow) | ||
alias(libs.plugins.githubRelease) | ||
} | ||
|
||
val isKotlinDev: Boolean = project.hasProperty("isKotlinDev") | ||
|
||
allprojects { | ||
if (isKotlinDev) { | ||
val definedVersion = ext["VERSION_NAME"].toString().removeSuffix("-SNAPSHOT") | ||
ext["VERSION_NAME"] = "$definedVersion-kotlin-dev-SNAPSHOT" | ||
} | ||
|
||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
} | ||
} | ||
|
||
val ktlint: Configuration = configurations.create("ktlint") | ||
|
||
dependencies { | ||
ktlint(projects.ktlint) | ||
} | ||
|
||
tasks.register<JavaExec>("ktlint") { | ||
group = LifecycleBasePlugin.VERIFICATION_GROUP | ||
description = "Check Kotlin code style including experimental rules." | ||
classpath = ktlint | ||
mainClass.set("com.pinterest.ktlint.Main") | ||
args( | ||
"**/src/**/*.kt", | ||
"**.kts", | ||
"!**/build/**", | ||
// Exclude sources which contain lint violations for the purpose of testing. | ||
"!ktlint/src/test/resources/**", | ||
"--baseline=ktlint/src/test/resources/test-baseline.xml", | ||
// Experimental rules run by default run on the ktlint code base itself. Experimental rules should not be released if | ||
// we are not pleased ourselves with the results on the ktlint code base. | ||
"--experimental", | ||
// Do not run with option "--verbose" or "-v" as the lint violations are difficult to spot between the amount of | ||
// debug output lines. | ||
) | ||
} | ||
|
||
// Deployment tasks | ||
val githubToken: String = if (project.hasProperty("servers.github.privKey")) { | ||
project.property("servers.github.privKey").toString() | ||
} else { | ||
logger.warn("No github token specified") | ||
"" | ||
} | ||
|
||
val shadowJarExecutable: TaskProvider<Task> by lazy { | ||
projects.ktlint.dependencyProject.tasks.named("shadowJarExecutable") | ||
} | ||
|
||
// Explicitly adding dependency on "shadowJarExecutable" as Gradle does not it set via "releaseAssets" property | ||
tasks.githubRelease { | ||
dependsOn(provider { shadowJarExecutable }) | ||
} | ||
|
||
githubRelease { | ||
token(githubToken) | ||
owner("pinterest") | ||
repo("ktlint") | ||
tagName(project.property("VERSION_NAME").toString()) | ||
releaseName(project.property("VERSION_NAME").toString()) | ||
targetCommitish("master") | ||
releaseAssets( | ||
project.files( | ||
provider { | ||
// "shadowJarExecutableChecksum" task does not declare checksum files | ||
// as output, only the whole output directory. As it uses the same directory | ||
// as "shadowJarExecutable" - just pass all the files from that directory | ||
shadowJarExecutable.get().outputs.files.files.first().parentFile.listFiles() | ||
}, | ||
), | ||
) | ||
overwrite(true) | ||
dryRun(false) | ||
body { | ||
var changelog = project.file("CHANGELOG.md").readText() | ||
changelog = changelog.substring(changelog.indexOf("## ")) | ||
// 1 in indexOf here to skip first "## [" occurence | ||
changelog.substring(0, changelog.indexOf("## [", 1)) | ||
} | ||
} | ||
|
||
// Put "servers.github.privKey" in "$HOME/.gradle/gradle.properties". | ||
val announceRelease by tasks.registering(Exec::class) { | ||
group = "Help" | ||
description = "Runs .announce script" | ||
subprojects.filter { !it.name.contains("ktlint-ruleset-template") }.forEach { subproject -> | ||
dependsOn(subproject.tasks.named("publishMavenPublicationToMavenCentralRepository")) | ||
} | ||
|
||
commandLine("./.announce", "-y") | ||
environment("VERSION" to "${project.property("VERSION_NAME")}") | ||
environment("GITHUB_TOKEN" to githubToken) | ||
} | ||
|
||
val homebrewBumpFormula by tasks.registering(Exec::class) { | ||
group = "Help" | ||
description = "Runs brew bump-forumula-pr" | ||
commandLine("./.homebrew") | ||
environment("VERSION" to "${project.property("VERSION_NAME")}") | ||
dependsOn(tasks.named("githubRelease")) | ||
} | ||
|
||
tasks.register<DefaultTask>("publishNewRelease") { | ||
group = "Help" | ||
description = "Triggers uploading new archives and publish announcements" | ||
dependsOn(announceRelease, homebrewBumpFormula, tasks.named("githubRelease")) | ||
} | ||
|
||
tasks.wrapper { | ||
gradleVersion = libs.versions.gradle.get() | ||
distributionSha256Sum = libs.versions.gradleSha256.get() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-core | ||
POM_ARTIFACT_ID=ktlint-core | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-reporter-baseline | ||
POM_ARTIFACT_ID=ktlint-reporter-baseline | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-reporter-checkstyle | ||
POM_ARTIFACT_ID=ktlint-reporter-checkstyle | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-reporter-format | ||
POM_ARTIFACT_ID=ktlint-reporter-format | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-reporter-html | ||
POM_ARTIFACT_ID=ktlint-reporter-html | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-reporter-json | ||
POM_ARTIFACT_ID=ktlint-reporter-json | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-reporter-plain | ||
POM_ARTIFACT_ID=ktlint-reporter-plain | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-reporter-sarif | ||
POM_ARTIFACT_ID=ktlint-reporter-sarif | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-ruleset-experimental | ||
POM_ARTIFACT_ID=ktlint-ruleset-experimental | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-ruleset-standard | ||
POM_ARTIFACT_ID=ktlint-ruleset-standard | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-ruleset-test | ||
POM_ARTIFACT_ID=ktlint-ruleset-test | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-test-logging | ||
POM_ARTIFACT_ID=ktlint-test-logging | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
GROUP=com.pinterest.ktlint | ||
POM_NAME=ktlint-test | ||
POM_ARTIFACT_ID=ktlint-test | ||
POM_PACKAGING=jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
GROUP=com.pinterest | ||
POM_NAME=ktlint | ||
POM_ARTIFACT_ID=ktlint | ||
POM_PACKAGING=jar |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1503 (comment)