Skip to content

Commit

Permalink
Make Java mainClass and javaVersion mutations work with Kotlin-only p…
Browse files Browse the repository at this point in the history
…rojects, too
  • Loading branch information
h0tk3y committed Jul 12, 2024
1 parent 1ffdc82 commit 852a15b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import org.gradle.declarative.dsl.schema.AnalysisSchema
import org.gradle.internal.declarativedsl.dom.mutation.*
import org.gradle.internal.declarativedsl.schemaUtils.propertyNamed

interface JavaPrototypeMutationDefinition : MutationDefinition {
interface JvmPrototypeMutationDefinition : MutationDefinition {
override fun isCompatibleWithSchema(projectAnalysisSchema: AnalysisSchema): Boolean =
projectAnalysisSchema.hasJavaPrototype()
projectAnalysisSchema.hasJvmPrototype()
}

object SetJvmApplicationMainClass : JavaPrototypeMutationDefinition {
object SetJvmApplicationMainClass : JvmPrototypeMutationDefinition {
override val id: String = "org.gradle.client.demo.mutations.jvm.application.setMainClass"
override val name: String = "Set application main class"
override val description: String = "Set the entry point class for the application"
Expand All @@ -33,7 +33,7 @@ object SetJvmApplicationMainClass : JavaPrototypeMutationDefinition {
}
}

object SetJavaVersion : JavaPrototypeMutationDefinition {
object SetJavaVersion : JvmPrototypeMutationDefinition {
override val id: String = "org.gradle.client.demo.mutations.jvm.setJavaVersion"
override val name: String = "Set Java version"
override val description: String = "Set the target Java version"
Expand Down
3 changes: 3 additions & 0 deletions mutations-demo/src/main/kotlin/JavaSchemaAccessors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import org.gradle.declarative.dsl.schema.DataClass
fun AnalysisSchema.hasJavaPrototype(): Boolean =
dataClassesByFqName.keys.any { it.qualifiedName == "org.gradle.api.experimental.java.JavaLibrary" }

fun AnalysisSchema.hasJvmPrototype(): Boolean =
dataClassesByFqName.keys.any { it.qualifiedName == "org.gradle.api.experimental.jvm.HasJvmApplication" }

val AnalysisSchema.hasJvmApplication: DataClass
get() = typeByFqn("org.gradle.api.experimental.jvm.HasJvmApplication")

Expand Down

0 comments on commit 852a15b

Please sign in to comment.