generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple versions of ktlint standard ruleset (#487)
* Support multiple versions of ktlint standard ruleset The StandardRulesetProvider from each supported version of ktlint is transformed with shadow plugin to a unique class so that multiple versions of the StandardRulesetProvider class can be compiled into the plugin. Closes #426 Closes #35 * Increase build memory (cherry picked from commit 516955b)
- Loading branch information
1 parent
01f7d52
commit 7c9d0b3
Showing
18 changed files
with
343 additions
and
56 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Why is this a module? | ||
|
||
The `ktlint-lib` contains several libraries to isolate functionalities from Ktlint in such a way that it does not conflict with the plugin. | ||
|
||
## Core | ||
|
||
The Ktlint RuleEngine core module requires certain elements of the kotlin compiler. As of that it includes a dependency on the embedded kotlin compiler library. This clashes and conflicts with classes we use in the JetBrains Kotlin plugin. | ||
|
||
## Ruleset | ||
|
||
Each ruleset library transforms the StandardRuleSetProvider of that version to a unique class name so that multiple versions of the Standard rule sets can be supported by the plugin. The plugin allows the user to configure one of the supported ktlint versios. In this way, the user can keep the configuration of the ktlint intellij plugin in sync with other plugins like the ktlint gradle plugin or kotlinter. |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("java") // Java support | ||
alias(libs.plugins.kotlin) // Kotlin support | ||
alias(libs.plugins.shadow) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// Until version 0.50.0, the "mu.Kotlin" logger was used. In 1.x version this has been replaced with | ||
// "io.github.oshai.kotlinlogging.KLogger". | ||
implementation("com.pinterest.ktlint:ktlint-logger:0.50.0") | ||
implementation("com.pinterest.ktlint:ktlint-ruleset-standard:0.50.0") | ||
} | ||
|
||
tasks { | ||
// Set the compatibility versions to 11 | ||
withType<JavaCompile> { | ||
sourceCompatibility = "11" | ||
targetCompatibility = "11" | ||
} | ||
withType<KotlinCompile> { | ||
kotlinOptions.jvmTarget = "11" | ||
} | ||
|
||
withType<ShadowJar> { | ||
val api = project.configurations.api.get() | ||
val impl = project.configurations.implementation.get() | ||
|
||
configurations = listOf(api, impl).map { it.apply { isCanBeResolved = true } } | ||
|
||
relocate( | ||
"com.pinterest.ktlint.logger", | ||
"shadow.com.pinterest.ktlint-0-50-0.logger", | ||
) | ||
relocate( | ||
"com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider", | ||
"shadow.com.pinterest.ktlint.ruleset.standard.StandardRuleSetProviderV0_50_0", | ||
) | ||
} | ||
} |
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,39 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("java") // Java support | ||
alias(libs.plugins.kotlin) // Kotlin support | ||
alias(libs.plugins.shadow) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("com.pinterest.ktlint:ktlint-ruleset-standard:1.0.1") | ||
} | ||
|
||
tasks { | ||
// Set the compatibility versions to 11 | ||
withType<JavaCompile> { | ||
sourceCompatibility = "11" | ||
targetCompatibility = "11" | ||
} | ||
withType<KotlinCompile> { | ||
kotlinOptions.jvmTarget = "11" | ||
} | ||
|
||
withType<ShadowJar> { | ||
val api = project.configurations.api.get() | ||
val impl = project.configurations.implementation.get() | ||
|
||
configurations = listOf(api, impl).map { it.apply { isCanBeResolved = true } } | ||
|
||
relocate( | ||
"com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider", | ||
"shadow.com.pinterest.ktlint.ruleset.standard.StandardRuleSetProviderV1_00_1", | ||
) | ||
} | ||
} |
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,39 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("java") // Java support | ||
alias(libs.plugins.kotlin) // Kotlin support | ||
alias(libs.plugins.shadow) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("com.pinterest.ktlint:ktlint-ruleset-standard:1.1.1") | ||
} | ||
|
||
tasks { | ||
// Set the compatibility versions to 11 | ||
withType<JavaCompile> { | ||
sourceCompatibility = "11" | ||
targetCompatibility = "11" | ||
} | ||
withType<KotlinCompile> { | ||
kotlinOptions.jvmTarget = "11" | ||
} | ||
|
||
withType<ShadowJar> { | ||
val api = project.configurations.api.get() | ||
val impl = project.configurations.implementation.get() | ||
|
||
configurations = listOf(api, impl).map { it.apply { isCanBeResolved = true } } | ||
|
||
relocate( | ||
"com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider", | ||
"shadow.com.pinterest.ktlint.ruleset.standard.StandardRuleSetProviderV1_01_1", | ||
) | ||
} | ||
} |
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,39 @@ | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("java") // Java support | ||
alias(libs.plugins.kotlin) // Kotlin support | ||
alias(libs.plugins.shadow) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("com.pinterest.ktlint:ktlint-ruleset-standard:1.2.1") | ||
} | ||
|
||
tasks { | ||
// Set the compatibility versions to 11 | ||
withType<JavaCompile> { | ||
sourceCompatibility = "11" | ||
targetCompatibility = "11" | ||
} | ||
withType<KotlinCompile> { | ||
kotlinOptions.jvmTarget = "11" | ||
} | ||
|
||
withType<ShadowJar> { | ||
val api = project.configurations.api.get() | ||
val impl = project.configurations.implementation.get() | ||
|
||
configurations = listOf(api, impl).map { it.apply { isCanBeResolved = true } } | ||
|
||
relocate( | ||
"com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider", | ||
"shadow.com.pinterest.ktlint.ruleset.standard.StandardRuleSetProviderV1_02_1", | ||
) | ||
} | ||
} |
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
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
Oops, something went wrong.