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

Publish ktlint CLI signature to Github release. #903

Merged
merged 1 commit into from
Sep 11, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Do not report when string-template expression is a keyword ([#883](https://github.com/pinterest/ktlint/issues/883))
- False positive for subclass imports in `no-unused-imports` ([#845](https://github.com/pinterest/ktlint/issues/845))
- False positive for static java function imports in `no-unused-imports` ([#872](https://github.com/pinterest/ktlint/issues/872))
- Missing signature for KtLint CLI artifact published to Github release ([#895](https://github.com/pinterest/ktlint/issues/895))

### Changed
- `Ktlint` object internal code cleanup
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/ktlint-publication.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ publishing {
* ```
*/
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
//useGpgCmd()

sign(publishing.publications["maven"])
setRequired({
!version.toString().endsWith("SNAPSHOT")
Expand Down
13 changes: 10 additions & 3 deletions ktlint/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'ktlint-publication'
id 'com.github.johnrengelman.shadow'
id 'org.gradle.crypto.checksum'
id 'signing'
}

jar {
Expand Down Expand Up @@ -47,15 +48,21 @@ def shadowJarExecutableTask = tasks.register("shadowJarExecutable", DefaultTask.
group = "Distribution"

inputs.files tasks.named("shadowJar")
outputs.file "$buildDir/run/ktlint"
outputs.files("$buildDir/run/ktlint")
if (!version.toString().endsWith("SNAPSHOT")) {
outputs.files("$buildDir/run/ktlint.asc")
}

doLast {
File execFile = outputs.files.singleFile
File execFile = outputs.files.getFiles().first()
execFile.withOutputStream {
it.write "#!/bin/sh\n\nexec java -Xmx512m -jar \"\$0\" \"\$@\"\n\n".bytes
it.write inputs.files.singleFile.bytes
}
execFile.setExecutable(true, false)
if (!version.toString().endsWith("SNAPSHOT")) {
signing.sign(execFile)
}
}
finalizedBy tasks.named("shadowJarExecutableChecksum")
}
Expand All @@ -66,7 +73,7 @@ tasks.register("shadowJarExecutableChecksum", Checksum.class) {

files = shadowJarExecutableTask.get().outputs.files
// put the checksums in the same folder with the executable itself
outputDir = shadowJarExecutableTask.get().outputs.files.singleFile.parentFile
outputDir = shadowJarExecutableTask.get().outputs.files.getFiles().first().parentFile

algorithm = Checksum.Algorithm.MD5
}