Skip to content

Commit

Permalink
Merge branch 'main' into android-kotlin-sourceset
Browse files Browse the repository at this point in the history
  • Loading branch information
wakingrufus authored Nov 28, 2023
2 parents d2b2712 + 6e9e6a1 commit 34eeeae
Show file tree
Hide file tree
Showing 71 changed files with 773 additions and 1,337 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps: # https://michaelheap.com/dynamic-matrix-generation-github-actions/
- id: set-matrix
run: echo "::set-output name=version_matrix::$(curl https://endoflife.date/api/java.json | jq -c '[.[] | select(.eol > (now | strftime("%Y-%m-%d"))) | .cycle]' | sed 's/ //g')"
run: echo "::set-output name=version_matrix::$(curl https://endoflife.date/api/oracle-jdk.json | jq -c '[.[] | select(.extendedSupport > (now | strftime("%Y-%m-%d"))) | .cycle]' | sed 's/ //g')"
- name: verify-matrix
run: echo "The selected java versions are ${{ steps.set-matrix.outputs.version_matrix }}"
outputs:
Expand Down
72 changes: 72 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '40 1 * * 0'
push:
branches: [ "main" ]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read

steps:
- name: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}

# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
with:
sarif_file: results.sarif
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

## [12.0.0] - 2023-11-28

- update latest version text file manually [#716](https://github.com/JLLeitschuh/ktlint-gradle/pull/716)
- Fix configuration cache for relative paths [#722](https://github.com/JLLeitschuh/ktlint-gradle/pull/722)
- Drop support for Gradle 6 and ktlint < 0.47.1 [#720](https://github.com/JLLeitschuh/ktlint-gradle/pull/720)

## [11.6.1] - 2023-10-10

- fix "additionalEditorconfig not supported until ktlint 0.49" warning [#712](https://github.com/JLLeitschuh/ktlint-gradle/pull/712)
- update latest version text file manually [#709](https://github.com/JLLeitschuh/ktlint-gradle/pull/709)
- Improve error logging [#711](https://github.com/JLLeitschuh/ktlint-gradle/pull/711)

## [11.6.0] - 2023-09-18

- ktlint 1.0 support [#708](https://github.com/JLLeitschuh/ktlint-gradle/pull/708)
- Allow editorconfig overrides in ktlint 0.49+ [#708](https://github.com/JLLeitschuh/ktlint-gradle/pull/708)
- update latest version text file manually [#700](https://github.com/JLLeitschuh/ktlint-gradle/pull/700)

## [11.5.1] - 2023-08-07
Expand Down Expand Up @@ -684,7 +700,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Renamed task with name `ktlint` to `ktlintCheck` (#3)
- Renamed tasks with names `ktlint[source set name]` to `ktlint[source set name]Check` (#3)

[Unreleased]: https://github.com/JLLeitschuh/ktlint-gradle/compare/v11.5.1...HEAD
[Unreleased]: https://github.com/JLLeitschuh/ktlint-gradle/compare/v12.0.0...HEAD

[12.0.0]: https://github.com/JLLeitschuh/ktlint-gradle/compare/v11.6.1...v12.0.0

[11.6.1]: https://github.com/JLLeitschuh/ktlint-gradle/compare/v11.6.0...v11.6.1

[11.6.0]: https://github.com/JLLeitschuh/ktlint-gradle/compare/v11.5.1...v11.6.0

[11.5.1]: https://github.com/JLLeitschuh/ktlint-gradle/compare/v11.5.0...v11.5.1

Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
**Provides a convenient wrapper plugin over the [ktlint](https://github.com/pinterest/ktlint) project.**

<!-- Note: if changing the line below, the `sed` command in the perform-release.yaml needs to be updated too -->
Latest plugin version: [11.5.1](/CHANGELOG.md#---20230807)
Latest plugin version: [12.0.0](/CHANGELOG.md#---20231128)

[![Join the chat at https://kotlinlang.slack.com](https://img.shields.io/badge/slack-@kotlinlang/ktlint-yellow.svg?logo=slack)](https://kotlinlang.slack.com/messages/CKS3XG0LS)
[![Build and Check](https://github.com/JLLeitschuh/ktlint-gradle/actions/workflows/build-and-check.yml/badge.svg)](https://github.com/JLLeitschuh/ktlint-gradle/actions/workflows/build-and-check.yml)
[![ktlint](https://img.shields.io/badge/code%20style-%E2%9D%A4-FF4081.svg)](https://ktlint.github.io/)
[![Gradle Plugin Portal](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/org/jlleitschuh/gradle/ktlint/org.jlleitschuh.gradle.ktlint.gradle.plugin/maven-metadata.xml.svg?colorB=007ec6&label=gradlePluginPortal)](https://plugins.gradle.org/plugin/org.jlleitschuh.gradle.ktlint)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/JLLeitschuh/ktlint-gradle/badge)](https://securityscorecards.dev/viewer/?uri=github.com/JLLeitschuh/ktlint-gradle)

This plugin creates convenient tasks in your Gradle project
that run [ktlint](https://github.com/pinterest/ktlint) checks or do code
Expand Down Expand Up @@ -63,12 +64,11 @@ open a [new issue](https://github.com/JLLeitschuh/ktlint-gradle/issues/new).
This plugin was written using the new API available for the Gradle script Kotlin builds.
This API is available in new versions of Gradle.

Minimal supported [Gradle](https://www.gradle.org) version: `6.8`
Minimal supported [Gradle](https://www.gradle.org) version: `7.4`

Minimal supported [Kotlin](https://kotlinlang.org) version: `1.4`

Minimal supported [ktlint](https://github.com/pinterest/ktlint) version: `0.34.0`
(additionally excluding `0.37.0` on Windows OS and `0.38.0`, `0.43.0`, `0.43.1` on all OS types)
Minimal supported [ktlint](https://github.com/pinterest/ktlint) version: `0.47.1`

### Ktlint plugin

Expand Down Expand Up @@ -271,6 +271,8 @@ object will be used.

The version of ktlint used by default _may change_ between patch versions of this plugin.
If you don't want to inherit these changes then make sure you lock your version here.
Consult the [ktlint release notes](https://github.com/pinterest/ktlint/releases) for more information about the differences between ktlint versions.

<details>
<summary>Groovy</summary>

Expand All @@ -287,6 +289,9 @@ ktlint {
ignoreFailures = true
enableExperimentalRules = true
additionalEditorconfigFile = file("/some/additional/.editorconfig") // not supported with ktlint 0.47+
additionalEditorconfig = [ // not supported until ktlint 0.49
"max_line_length": "20"
]
disabledRules = ["final-newline"] // not supported with ktlint 0.48+
baseline = file("my-project-ktlint-baseline.xml")
reporters {
Expand Down Expand Up @@ -339,6 +344,11 @@ configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
ignoreFailures.set(true)
enableExperimentalRules.set(true)
additionalEditorconfigFile.set(file("/some/additional/.editorconfig")) // not supported with ktlint 0.47+
additionalEditorconfig.set( // not supported until ktlint 0.49
mapOf(
"max_line_length" to "20"
)
)
disabledRules.set(setOf("final-newline")) // not supported with ktlint 0.48+
baseline.set(file("my-project-ktlint-baseline.xml"))
reporters {
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion plugin/VERSION_CURRENT.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.5.1
12.0.0
2 changes: 1 addition & 1 deletion plugin/VERSION_LATEST_RELEASE.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.5.1
11.6.1
74 changes: 17 additions & 57 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.gradle.enterprise.gradleplugin.testretry.retry
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.util.prefixIfNot

plugins {
kotlin("jvm")
id("com.gradle.plugin-publish")
`java-gradle-plugin`
`kotlin-dsl`
`maven-publish`
id("org.jlleitschuh.gradle.ktlint")
id("com.github.johnrengelman.shadow")
id("com.github.breadmoirai.github-release")
id("org.gradle.test-retry")
}

val pluginGroup = "org.jlleitschuh.gradle"
Expand Down Expand Up @@ -60,22 +59,6 @@ configurations["testImplementation"].extendsFrom(shadowImplementation)
sourceSets {
val adapter by creating {
}
val adapter34 by creating {
compileClasspath += adapter.output
}
val adapter34Test by creating {
compileClasspath += adapter.output + adapter34.output
runtimeClasspath += adapter.output + adapter34.output
}
val adapter41 by creating {
compileClasspath += adapter.output
}
val adapter45 by creating {
compileClasspath += adapter.output
}
val adapter46 by creating {
compileClasspath += adapter.output
}
val adapter47 by creating {
compileClasspath += adapter.output
}
Expand All @@ -88,16 +71,16 @@ sourceSets {
val adapter50 by creating {
compileClasspath += adapter.output
}
val adapter100 by creating {
compileClasspath += adapter.output
}
val adapters = listOf(
adapter,
adapter34,
adapter41,
adapter45,
adapter46,
adapter47,
adapter48,
adapter49,
adapter50
adapter50,
adapter100
)
val main by getting {
kotlin {
Expand All @@ -114,37 +97,21 @@ sourceSets {
}
val adapterSources = listOf(
sourceSets.named("adapter"),
sourceSets.named("adapter34"),
sourceSets.named("adapter41"),
sourceSets.named("adapter45"),
sourceSets.named("adapter46"),
sourceSets.named("adapter47"),
sourceSets.named("adapter48"),
sourceSets.named("adapter49"),
sourceSets.named("adapter50")
sourceSets.named("adapter50"),
sourceSets.named("adapter100")
)
tasks.named<Jar>("shadowJar") {
this.from(adapterSources.map { sourceSet -> sourceSet.map { it.output.classesDirs } })
}

val test34Task = tasks.register<Test>("test34") {
classpath = sourceSets.named("adapter34Test").get().runtimeClasspath
testClassesDirs = sourceSets.named("adapter34Test").get().output.classesDirs
}
tasks.named("test") {
dependsOn(test34Task)
}

dependencies {
compileOnly(gradleApi())
add("adapterCompileOnly", "com.pinterest.ktlint:ktlint-core:0.34.0")
add("adapterImplementation", libs.commons.io)
add("adapterImplementation", libs.semver)
add("adapter34Implementation", kotlin("reflect"))
add("adapter34CompileOnly", "com.pinterest.ktlint:ktlint-core:0.34.0")
add("adapter41CompileOnly", "com.pinterest.ktlint:ktlint-core:0.41.0")
add("adapter45CompileOnly", "com.pinterest.ktlint:ktlint-core:0.45.2")
add("adapter46CompileOnly", "com.pinterest.ktlint:ktlint-core:0.46.1")

add("adapter47CompileOnly", "com.pinterest.ktlint:ktlint-core:0.47.1")
add("adapter48CompileOnly", "com.pinterest.ktlint:ktlint-core:0.48.2")

Expand All @@ -159,6 +126,11 @@ dependencies {
add("adapter50CompileOnly", "com.pinterest.ktlint:ktlint-ruleset-standard:0.50.0")
add("adapter50CompileOnly", "com.pinterest.ktlint:ktlint-reporter-baseline:0.50.0")

add("adapter100CompileOnly", "com.pinterest.ktlint:ktlint-cli-reporter-core:1.0.0")
add("adapter100CompileOnly", "com.pinterest.ktlint:ktlint-rule-engine:1.0.0")
add("adapter100CompileOnly", "com.pinterest.ktlint:ktlint-ruleset-standard:1.0.0")
add("adapter100CompileOnly", "com.pinterest.ktlint:ktlint-cli-reporter-baseline:1.0.0")

compileOnly(libs.kotlin.gradle.plugin)
compileOnly(libs.android.gradle.plugin)
compileOnly(kotlin("stdlib-jdk8"))
Expand All @@ -174,19 +146,11 @@ dependencies {
* https://github.com/JLLeitschuh/ktlint-gradle/issues/9
*/

testImplementation(gradleTestKit())
testImplementation(libs.junit.jupiter)
testImplementation(libs.assertj.core)
testImplementation(libs.kotlin.reflect)
testImplementation(libs.ktlint.core)
testImplementation(libs.archunit.junit5)

add("adapter34TestImplementation", "com.pinterest.ktlint:ktlint-core:0.34.0")
add("adapter34TestImplementation", libs.commons.io)
add("adapter34TestImplementation", gradleTestKit())
add("adapter34TestImplementation", libs.junit.jupiter)
add("adapter34TestImplementation", libs.assertj.core)
add("adapter34TestImplementation", libs.kotlin.reflect)
}

kotlin {
Expand All @@ -202,19 +166,18 @@ kotlin {
}

// Test tasks loods plugin from local maven repository
tasks.named("test").configure {
tasks.named<Test>("test") {
dependsOn("publishToMavenLocal")
}

tasks.withType<Test>().configureEach {
tasks.withType<Test> {
useJUnitPlatform()
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
doFirst {
logger.lifecycle("maxParallelForks for '$path' is $maxParallelForks")
}
testLogging {
events(
TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED
Expand Down Expand Up @@ -382,9 +345,6 @@ pluginBundle {
"ktlintPlugin" {
displayName = "Ktlint Gradle Plugin"
}
"ktlintIdeaPlugin" {
displayName = "Ktlint Gradle IntelliJ Configuration Plugin"
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions plugin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
kotlin = "1.5.31"
ktlint = "0.45.2" # last version prior to API changes. we can increase this more once we drop support for the old API.
ktlint = "0.47.1" # last version prior to API changes. we can increase this more once we drop support for the old API.
androidPlugin = "7.0.0"
semver = "1.1.1"
jgit = "5.6.0.201912101111-r"
sl4fj = "1.7.30"
gradleWrapper = "7.3.3"
gradleWrapperSha = "b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302"
gradleWrapper = "8.4"
gradleWrapperSha = "3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae"
junit5 = "5.5.2"
assertJ = "3.11.1"
commonsIo = "2.8.0"
Expand Down
4 changes: 2 additions & 2 deletions plugin/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=b586e04868a22fd817c8971330fec37e298f3242eb85c374181b12d637f80302
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 34eeeae

Please sign in to comment.