generated from cortinico/kotlin-gradle-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Remove legacy kotlin-compiler-embeddable
dependency to prevent potential Kotlin version conflicts
#223
Merged
Merged
Remove legacy kotlin-compiler-embeddable
dependency to prevent potential Kotlin version conflicts
#223
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b09f242
add test to verify that the plugin can be applied to projects with diβ¦
6d978cb
increase kotlin version to 1.9.20 to showcase the failing PluginVersiβ¦
b2d96c9
remove kotlin compiler embeddable dependency to apply plugin successfβ¦
9244a85
remove formatting changes
d650061
add changes to changelog
8c1791d
add changelog entry for kotlin version bump
simonhauck c01a53f
bump version of this plugin for version compatibility test to maximumβ¦
simonhauck a322a27
Update dependency com.android.library to v8.1.3 (#224)
renovate[bot] e58d716
Update dependency com.android.library to v8.1.4 (#225)
renovate[bot] e363af0
Update dependency com.github.ben-manes.versions to v0.50.0 (#226)
renovate[bot] 441ad6e
Update dependency org.jetbrains.kotlin:kotlin-compiler-embeddable to β¦
renovate[bot] f7ed8cb
Update kotlin to v1.9.21 (#229)
renovate[bot] c5993e8
rebase commit, resolve conflicts
91188e3
remove formatting changes
e621693
remove unused kotlin-compiler-embeddable dependency
simonhauck 22bfea5
Update CHANGELOG.md
cortinico 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 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
71 changes: 71 additions & 0 deletions
71
plugin-build/plugin/src/test/java/com/ncorti/ktfmt/gradle/PluginVersionCompatibilityTest.kt
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,71 @@ | ||
package com.ncorti.ktfmt.gradle | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import java.io.File | ||
import java.nio.file.Path | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.intellij.lang.annotations.Language | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.io.TempDir | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.ValueSource | ||
|
||
internal class PluginVersionCompatibilityTest { | ||
|
||
@TempDir lateinit var tempDir: File | ||
|
||
private val pluginBuildDirectory = Path.of("./", "../") | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
File(tempDir, "src/main/java").mkdirs() | ||
File("src/test/resources/jvmProject-version-compatibility").copyRecursively(tempDir) | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = ["1.7.20", "1.9.10", "1.9.20"]) | ||
fun `plugin can be applied to projects with different kotlin versions`(kotlinVersion: String) { | ||
// Prevent sharing of classpath | ||
publishPluginToMavenLocal() | ||
|
||
replaceKotlinVersion(kotlinVersion) | ||
|
||
createTempFile(content = "val answer = 42\n") | ||
val result = | ||
GradleRunner.create() | ||
.withProjectDir(tempDir) | ||
.withArguments("ktfmtCheckMain", "--info") | ||
.build() | ||
|
||
assertThat(result.task(":ktfmtCheckMain")?.outcome).isEqualTo(TaskOutcome.SUCCESS) | ||
} | ||
|
||
private fun publishPluginToMavenLocal() { | ||
GradleRunner.create() | ||
.withProjectDir(pluginBuildDirectory.toFile()) | ||
.withArguments( | ||
"plugin:publishToMavenLocal", | ||
"-PVERSION=99.99.99-compatibility-check", | ||
"-Pskip-signing=true" | ||
) | ||
.build() | ||
} | ||
|
||
private fun replaceKotlinVersion(version: String) { | ||
val file = tempDir.resolve("build.gradle.kts") | ||
val updatedKotlinVersion = file.readText().replace("KOTLIN_VERSION_PLACEHOLDER", version) | ||
|
||
file.writeText(updatedKotlinVersion) | ||
} | ||
|
||
private fun createTempFile( | ||
@Language("kotlin") content: String, | ||
fileName: String = "TestFile.kt", | ||
path: String = "src/main/java" | ||
) = | ||
File(File(tempDir, path), fileName).apply { | ||
createNewFile() | ||
writeText(content) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
plugin-build/plugin/src/test/resources/jvmProject-version-compatibility/build.gradle.kts
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,6 @@ | ||
plugins { | ||
kotlin("jvm") version "KOTLIN_VERSION_PLACEHOLDER" | ||
id("com.ncorti.ktfmt.gradle") version "99.99.99-compatibility-check" | ||
} | ||
|
||
repositories { mavenCentral() } |
9 changes: 9 additions & 0 deletions
9
plugin-build/plugin/src/test/resources/jvmProject-version-compatibility/settings.gradle.kts
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,9 @@ | ||
rootProject.name = ("test-fixtures") | ||
|
||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} |
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.
Q: Is this really needed? I believe the
.gradle
files inside theresources/
folder are ignored no?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.
When calling
gradlew :plugin-build:plugin:publishToMavenLocal
I get an error about an unconfigured signatory, because the signing task is an implicit dependency.The publish task is executed from the parent project, so the build.gradle.kts file in the resources directory are unrelated to this.
I am not aware of another easy solution to disable the signing task conditionally for the test.