Skip to content

Commit 3251b87

Browse files
authored
Merge pull request #16 from dwursteisen/main
Bumps
2 parents a7a9f31 + 0695b9e commit 3251b87

File tree

15 files changed

+254
-125
lines changed

15 files changed

+254
-125
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# Ignore Gradle build output directory
44
build
55
.idea
6+
**/out

developer-plugin/build.gradle.kts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
13
@Suppress("DSL_SCOPE_VIOLATION")
24
plugins {
35
alias(libs.plugins.gradle.publish)
@@ -39,6 +41,9 @@ dependencies {
3941
}
4042

4143
gradlePlugin {
44+
website.set("https://github.com/minigdx/minigdx-developer-gradle-plugin")
45+
vcsUrl.set("https://github.com/minigdx/minigdx-developer-gradle-plugin")
46+
4247
// Define the plugin
4348
val developer by plugins.creating {
4449
id = "com.github.minigdx.gradle.plugin.developer"
@@ -56,6 +61,7 @@ gradlePlugin {
5661
description = """Configure MiniGDX libs to build for the JVM only.
5762
| The usage is mainly for MiniGDX contributors.
5863
""".trimMargin()
64+
tags.set(listOf("minigdx", "developer", "kotlin", "jvm", "mpp", "ios", "js", "android", "native"))
5965
}
6066

6167
val jvm by plugins.creating {
@@ -65,27 +71,13 @@ gradlePlugin {
6571
description = """Configure MiniGDX libs to build for different platforms.
6672
| The usage is mainly for MiniGDX contributors.
6773
""".trimMargin()
74+
tags.set(listOf("minigdx", "developer", "kotlin", "jvm"))
6875
}
6976
}
7077

71-
pluginBundle {
72-
website = "https://github.com/minigdx/minigdx-developer-gradle-plugin"
73-
vcsUrl = "https://github.com/minigdx/minigdx-developer-gradle-plugin"
74-
75-
tags = listOf("minigdx", "developer")
76-
77-
pluginTags = mapOf(
78-
"jvm" to listOf("kotlin", "jvm"),
79-
"mpp" to listOf("kotlin", "jvm", "mpp", "ios", "js", "android", "native")
80-
)
81-
}
82-
83-
val compileKotlin: org.jetbrains.kotlin.gradle.tasks.KotlinCompile by tasks
84-
compileKotlin.kotlinOptions.jvmTarget = "1.8"
8578

8679
// Add a source set for the functional test suite
87-
val functionalTestSourceSet = sourceSets.create("functionalTest") {
88-
}
80+
val functionalTestSourceSet = sourceSets.create("functionalTest") {}
8981

9082
gradlePlugin.testSourceSets(functionalTestSourceSet)
9183
configurations["functionalTestImplementation"].extendsFrom(configurations["testImplementation"])
@@ -101,20 +93,31 @@ tasks.check {
10193
dependsOn(functionalTest)
10294
}
10395

104-
// Ensure "org.gradle.jvm.version" is set to "8" in Gradle metadata.
105-
tasks.withType<JavaCompile> {
106-
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
107-
targetCompatibility = JavaVersion.VERSION_1_8.toString()
108-
}
109-
96+
val javaVersion = JavaLanguageVersion.of(11)
11097
java {
11198
toolchain {
112-
languageVersion.set(JavaLanguageVersion.of(11))
99+
languageVersion.set(javaVersion)
113100
}
114101
}
115102

116103
kotlin {
117104
jvmToolchain {
118-
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
105+
this.languageVersion.set(javaVersion)
119106
}
120107
}
108+
109+
project.tasks.withType(KotlinCompile::class.java).configureEach {
110+
kotlinOptions.jvmTarget = "11"
111+
val toolchainService = project.extensions.getByType(JavaToolchainService::class.java)
112+
kotlinJavaToolchain.toolchain.use(
113+
toolchainService.launcherFor {
114+
languageVersion.set(javaVersion)
115+
}
116+
)
117+
}
118+
119+
// Ensure "org.gradle.jvm.version" is set to "11" in Gradle metadata.
120+
project.tasks.withType(JavaCompile::class.java).configureEach {
121+
sourceCompatibility = JavaVersion.VERSION_11.toString()
122+
targetCompatibility = JavaVersion.VERSION_11.toString()
123+
}

developer-plugin/src/functionalTest/kotlin/com/github/minigdx/gradle/plugin/MinigdxDeveloperPluginFunctionalTest.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44
package com.github.minigdx.gradle.plugin
55

6-
import java.io.File
76
import org.gradle.testkit.runner.GradleRunner
87
import org.gradle.testkit.runner.TaskOutcome
98
import org.junit.Rule
@@ -24,7 +23,12 @@ class MinigdxDeveloperPluginFunctionalTest {
2423
// Setup the test build
2524
val projectDir = temporaryFolder.newFolder("build", "functionalTest")
2625
projectDir.mkdirs()
27-
projectDir.resolve("settings.gradle").writeText("")
26+
projectDir.resolve("settings.gradle").writeText("""
27+
plugins {
28+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
29+
}
30+
""".trimIndent())
31+
2832
projectDir.resolve("build.gradle").writeText("""
2933
plugins {
3034
id('com.github.minigdx.gradle.plugin.developer')
@@ -49,7 +53,11 @@ class MinigdxDeveloperPluginFunctionalTest {
4953
// Setup the test build
5054
val projectDir = temporaryFolder.newFolder("build", "functionalTest")
5155
projectDir.mkdirs()
52-
projectDir.resolve("settings.gradle").writeText("")
56+
projectDir.resolve("settings.gradle").writeText("""
57+
plugins {
58+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
59+
}
60+
""")
5361
projectDir.resolve("build.gradle").writeText("""
5462
plugins {
5563
id('com.github.minigdx.gradle.plugin.developer')

developer-plugin/src/functionalTest/kotlin/com/github/minigdx/gradle/plugin/MinigdxKotlinJvmPluginFunctionalTest.kt

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44
package com.github.minigdx.gradle.plugin
55

6-
import java.io.File
76
import org.gradle.testkit.runner.GradleRunner
87
import org.gradle.testkit.runner.TaskOutcome
98
import org.junit.Rule
@@ -20,26 +19,66 @@ class MinigdxKotlinJvmPluginFunctionalTest {
2019
@get:Rule
2120
val temporaryFolder: TemporaryFolder = TemporaryFolder()
2221

23-
@Test fun `can build`() {
22+
@Test
23+
fun `can build`() {
2424
// Setup the test build
2525
val projectDir = temporaryFolder.newFolder("build", "functionalTest")
2626
projectDir.mkdirs()
27-
projectDir.resolve("settings.gradle").writeText("")
28-
projectDir.resolve("build.gradle").writeText("""
27+
projectDir.resolve("settings.gradle").writeText("""
28+
plugins {
29+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
30+
}
31+
""")
32+
projectDir.resolve("build.gradle").writeText(
33+
"""
2934
plugins {
3035
id('com.github.minigdx.gradle.plugin.developer.jvm')
3136
}
32-
""")
37+
"""
38+
)
3339

3440
// Run the build
35-
val runner = GradleRunner.create()
36-
runner.forwardOutput()
37-
runner.withPluginClasspath()
38-
runner.withArguments("build")
39-
runner.withProjectDir(projectDir)
40-
val result = runner.build();
41+
val result = GradleRunner.create()
42+
.forwardOutput()
43+
.withPluginClasspath().withArguments("build")
44+
.withProjectDir(projectDir)
45+
.build()
4146

4247
// Verify the result
4348
assertEquals(TaskOutcome.SUCCESS, result.task(":build")?.outcome)
4449
}
50+
51+
@Test
52+
fun `can build with configuration cache`() {
53+
// Setup the test build
54+
val projectDir = temporaryFolder.newFolder("build", "functionalTest")
55+
projectDir.mkdirs()
56+
projectDir.resolve("settings.gradle").writeText("""
57+
plugins {
58+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
59+
}
60+
""")
61+
projectDir.resolve("build.gradle").writeText(
62+
"""
63+
plugins {
64+
id('com.github.minigdx.gradle.plugin.developer.jvm')
65+
}
66+
"""
67+
)
68+
69+
// Run the build
70+
GradleRunner.create()
71+
.forwardOutput()
72+
.withPluginClasspath().withArguments("build", "--configuration-cache")
73+
.withProjectDir(projectDir)
74+
.build()
75+
val result = GradleRunner.create()
76+
.forwardOutput()
77+
.withPluginClasspath().withArguments("build", "--configuration-cache")
78+
.withProjectDir(projectDir)
79+
.build()
80+
81+
// Verify the result
82+
assertTrue(result.output.contains("Reusing configuration cache."))
83+
}
4584
}

developer-plugin/src/functionalTest/kotlin/com/github/minigdx/gradle/plugin/MinigdxKotlinMppPluginFunctionalTest.kt

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
*/
44
package com.github.minigdx.gradle.plugin
55

6-
import java.io.File
76
import org.gradle.testkit.runner.GradleRunner
87
import org.gradle.testkit.runner.TaskOutcome
8+
import org.junit.Ignore
99
import org.junit.Rule
1010
import org.junit.rules.TemporaryFolder
1111
import kotlin.test.Test
@@ -24,22 +24,62 @@ class MinigdxKotlinMppPluginFunctionalTest {
2424
// Setup the test build
2525
val projectDir = temporaryFolder.newFolder("build", "functionalTest")
2626
projectDir.mkdirs()
27-
projectDir.resolve("settings.gradle").writeText("")
27+
projectDir.resolve("settings.gradle").writeText("""
28+
plugins {
29+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
30+
}
31+
""")
2832
projectDir.resolve("build.gradle").writeText("""
2933
plugins {
3034
id('com.github.minigdx.gradle.plugin.developer.mpp')
3135
}
3236
""")
3337

3438
// Run the build
35-
val runner = GradleRunner.create()
36-
runner.forwardOutput()
37-
runner.withPluginClasspath()
38-
runner.withArguments("build")
39-
runner.withProjectDir(projectDir)
40-
val result = runner.build();
39+
val result = GradleRunner.create()
40+
.forwardOutput()
41+
.withPluginClasspath()
42+
.withArguments("build")
43+
.withProjectDir(projectDir)
44+
.build()
4145

4246
// Verify the result
4347
assertEquals(TaskOutcome.SUCCESS, result.task(":build")?.outcome)
4448
}
49+
50+
@Test
51+
@Ignore("Configuration Cache not yet supported by Kotlin Multiplatform")
52+
fun `can build with configuration cache`() {
53+
// Setup the test build
54+
val projectDir = temporaryFolder.newFolder("build", "functionalTest")
55+
projectDir.mkdirs()
56+
projectDir.resolve("settings.gradle").writeText("""
57+
plugins {
58+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0")
59+
}
60+
""")
61+
projectDir.resolve("build.gradle").writeText("""
62+
plugins {
63+
id('com.github.minigdx.gradle.plugin.developer.mpp')
64+
}
65+
""")
66+
67+
// Run the build
68+
GradleRunner.create()
69+
.forwardOutput()
70+
.withPluginClasspath()
71+
.withArguments("build", "--configuration-cache")
72+
.withProjectDir(projectDir)
73+
.build()
74+
75+
val result = GradleRunner.create()
76+
.forwardOutput()
77+
.withPluginClasspath()
78+
.withArguments("build", "--configuration-cache")
79+
.withProjectDir(projectDir)
80+
.build()
81+
82+
// Verify the result
83+
assertTrue(result.output.contains("Reusing configuration cache."))
84+
}
4585
}

developer-plugin/src/main/kotlin/com/github/minigdx/gradle/plugin/MiniGdxDeveloperExtension.kt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.github.minigdx.gradle.plugin
22

3+
import org.gradle.api.Action
4+
import org.gradle.api.NamedDomainObjectList
35
import org.gradle.api.Project
46
import org.gradle.api.provider.Property
7+
import javax.inject.Inject
58

69
open class MiniGdxDeveloperExtension(private val project: Project) {
710

@@ -20,13 +23,13 @@ open class MiniGdxDeveloperExtension(private val project: Project) {
2023
*/
2124
val projectUrl: Property<String> = project.property()
2225

23-
val licence = Licence(project)
26+
val licence: Licence = project.objects.newInstance(Licence::class.java, project)
2427

25-
fun licence(configuration: Licence.() -> Unit) {
26-
configuration(licence)
28+
fun licence(configuration: Action<Licence>) {
29+
configuration.execute(licence)
2730
}
2831

29-
class Licence(project: Project) {
32+
open class Licence @Inject constructor(project: Project) {
3033
/**
3134
* Name of the Licence.
3235
*/
@@ -38,7 +41,8 @@ open class MiniGdxDeveloperExtension(private val project: Project) {
3841
val url: Property<String> = project.property()
3942
}
4043

41-
class Developer(project: Project) {
44+
45+
open class Developer @Inject constructor( project: Project) {
4246

4347
val name: Property<String> = project.property()
4448

@@ -47,20 +51,21 @@ open class MiniGdxDeveloperExtension(private val project: Project) {
4751
val url: Property<String> = project.property()
4852
}
4953

50-
val developers = mutableListOf<Developer>()
54+
val developers: NamedDomainObjectList<Developer> = project.objects.namedDomainObjectList(Developer::class.java)
5155

5256
/**
5357
* Add a developer to this project.
5458
*/
55-
fun developer(configure: Developer.() -> Unit) {
59+
fun developer(configure: Action<Developer>) {
5660
val developer = Developer(project)
57-
configure(developer)
61+
configure.execute(developer)
5862
developers.add(developer)
5963
}
6064

6165
companion object {
6266

6367
val IOS_MPP_PROPERTY = "minigdx.mpp.ios"
68+
val K2_MPP_PROPERTY = "minigdx.mpp.k2"
6469
}
6570
}
6671

0 commit comments

Comments
 (0)