I still am unable to figure out how to make a conv...
# gradle
a
I still am unable to figure out how to make a convention plugin that just applies Compose....It's driving me nuts. See thread for my current code for the plugin.
Copy code
# build-tools/settings.gradle.kts
rootProject.name = "build-tools"

include(":plugins")
Copy code
# build-tools/plugins/build.gradle.kts
plugins {
    `kotlin-dsl`
}

repositories {
    gradlePluginPortal()
    google()
    mavenCentral()
    maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
}

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0")
    implementation("org.jetbrains.compose:compose-gradle-plugin:1.2.1")
}
Copy code
# build-tools/plugins/src/main/kotlin/compose-desktop
plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose")
}

repositories {
    google()
    mavenCentral()
    maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
}

compose {
    kotlinCompilerPlugin.set("1.4.0")
}

kotlin {
    jvm()

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(compose.desktop.currentOs) {
                    exclude("org.jetbrains.compose.material", "material")
                    exclude("org.jetbrains.compose.material3", "material3")
                }
            }
        }
    }
}
And now I get:
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find org.jetbrains.compose.compiler:compiler:1.4.0.
when I include this plugin in a project.
I tried to follow the guides in https://github.com/jjohannes/understanding-gradle#readme but if I want to do something slightly different I get these errors..... I seem to lack a complete sense of how Gradle works somehow.
h
I think you just forgot to add the compose-jb repo to your actually projects
Wait, sorry, you already have the repo block in your convention plugin.
a
I found out it works when using Kotlin 1.7.20 and no manual setting of the Compose Compiler plugin
But that is still strange...
h
Yeah...
a
It works now, I made a typo.... 😞
Copy code
compose {
    kotlinCompilerPlugin.set("1.4.0")
}
Should be
Copy code
compose {
    kotlinCompilerPlugin.set("androidx.compose.compiler:compiler:1.4.0")
}
Time to call it quits for the day
h
Oh 😄 btw you could also define your repos in settings.gradle.kts for all projects
Copy code
dependencyResolutionManagement {
  repositories {
    mavenCentral()
    google()
    maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
  }
}
a
yeah, that's better I suppose
h
Especially you can forbid/ignore repos added by a plugin/project for security reasons by setting
repositoriesMode
a
But that dependencyResolutionManagement in the build-tools settings is only for the fetching of the dependencies in the subsequent build scripts. Not for the actual compiled convention plugin codes right?
h
I don't know, what you mean. "compiled convention" plugins are normal plugins. Gradle generates the id descriptor for gradle.kts files. So dependencyResolutionManagement is valid for all projects and their applied plugins.
a
You are right. My IDE complained when I moved it all and it didn't build. But after a refresh of the Gradle project it worked.
I appreciate your help enormously btw
h
Yeah IDE support is still a problem if you have errors in your build logic, very annoying but I don't think a solution exists.