Arjan van Wieringen
02/04/2023, 12:44 PMsettings.gradle.kts I have:
includeBuild('plugins/conventions')
includeBuild('plugins/starters')
How can I reference plugins defined in conventions in the starters project? They are unable to resolve and I have no clue on how to add them to the dependencyResolutionMaangement of starters.hfhbd
02/04/2023, 12:46 PMincludeBuild('conventions') in settings.gradle.kts inside plugins/starters, I think.Adam S
02/04/2023, 12:57 PMAdam S
02/04/2023, 1:00 PMincludeBuild() directory needs to be relative
// ./plugins/conventions/settings.gradle.kts
includeBuild("../starters")
then I’m pretty sure that the plugins in plugins/starters will be auto-included, so in the root you just need
// ./settings.gradle.kts
includeBuild("./plugins/conventions")
And if you have any Settings convention plugins (foo.settings.gradle.kts) then you need to use pluginManagement {}
pluginManagement {
  includeBuild("../settings-plugins/")
}PoisonedYouth
02/04/2023, 1:09 PMVampire
02/04/2023, 1:27 PMArjan van Wieringen
02/04/2023, 1:29 PMincludeBuild("../starters") in settings.gradle.kts of plugins/conventions/settings.gradle.kts
• Only includeBuild("./plugins/conventions") in root settings.gradle.kts
This results in:
starters:test: Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10 because no repositories are defined.
Required by:
    project :starters
Scenario 2:
• includeBuild("../conventions") in settings.gradle.kts of plugins/starters/settings.gradle.kts
• includeBuild("./plugins/conventions")  and includeBuild("./plugins/starters") in root settings.gradle.kts 
This results in:
starters:test: Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10 because no repositories are defined.
Required by:
    project :starters
Scenario 3:
• Same as Scenario 2
• But I add the dependencyResolutionManagement of conventions also in starters
Result:
Plugin [id: 'repositories.conventions'] was not found in any of the following sources:
This is one of my convention plugins I want to use in the starters.Adam S
02/04/2023, 1:32 PMsettings.gradle.kts
// settings.gradle.kts
pluginManagement {
  repositories {
    gradlePluginPortal()
    mavenCentral()
  }
}
@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature
dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
  repositories {
    mavenCentral()
    gradlePluginPortal()
  }
}Arjan van Wieringen
02/04/2023, 1:35 PMconventions build projectAdam S
02/04/2023, 1:36 PMrepositories.conventions plugin (src/kotlin/…?), and what package is it in?Arjan van Wieringen
02/04/2023, 1:38 PMplugins/conventions/src/main/kotlin/repositories.conventions.gradle.kts and it contains a block repositories which I use in other convention plugins or target project. That works just fine. It just doesn't resolve in another build project. I had the starters as part of the conventions subproject initially but decided to separate them out.Adam S
02/04/2023, 1:40 PM./plugins/conventions/build/pluginDescriptors/...?
you’ve applied the kotlin-dsl plugin in ./plugins/conventions/build.gradle.kts, right?Arjan van Wieringen
02/04/2023, 2:36 PMimplementation-class=Repositories_conventionsPlugin.Adam S
02/04/2023, 2:36 PMArjan van Wieringen
02/04/2023, 2:37 PMrepositories.conventions.properties But that itsn't a problem I think. I can easily apply this plugin in other projects, just not in another precompiled plugin in another subproject.
I'll create a minimal example later to maybe isolate the issue and to be able to share code.Adam S
02/04/2023, 2:39 PMArjan van Wieringen
02/05/2023, 8:40 AM/plugins and they create descriptors. But when I include a starter plugin in an actual project it throws an error (the error being that a convention plugin I reference in a starter plugin can not be found). I can however include the plugins of conventions in an example project without problems.Adam S
02/05/2023, 9:25 AMplugins/starters project.
In plugins/starters/src/main/kotlin/starter.multiplatform.gradle.kts
• it applies the convention plugin id("convention.repositories"), but that plugin exists in plugins/conventions, so add includeBuild("../conventions") to plugins/starters/settings.gradle.kts
• it applies the Kotlin Multiplatform & Serialization plugins, but the Maven dependencies aren’t added into plugins/starters/build.gradle.ktsAdam S
02/05/2023, 9:33 AMPlugin with id 'convention.repositories' not found is shown because the plugins/conventions project isn’t building at all (I should see a plugins/conventions/build dir, but there isn’t one, therefore the project isn’t building). So Gradle isn’t showing the root cause.
because includedBuild projects are completely independent, you can open them up in IntelliJ or terminal and try and build them
long story short, this is the wrong Maven coordinate for the KxS plugin
gradle-plugin-jetbrains-serialization = { module = "org.jetbrains.kotlin.plugin.serialization:org.jetbrains.kotlin.plugin.serialization.gradle.plugin", version.ref = "jetbrains-kotlin" }
That’s the magic Maven coordinate that Gradle uses to match a plugin ID id("org.jetbrains.kotlin.plugin.serialization") to the Maven dependency that actually contains the plugin JAR
To get the Maven coordinate, look at the plugin page https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.serialization and copy the Maven coordinate from classpath(...) in the ‘legacy’ sectionArjan van Wieringen
02/05/2023, 9:37 AMArjan van Wieringen
02/05/2023, 9:37 AMAdam S
02/05/2023, 9:37 AMAdam S
02/05/2023, 9:41 AM// ./build.gradle.kts
plugins {
    @Suppress("DSL_SCOPE_VIOLATION") kotlin("js").version(libs.versions.jetbrains.kotlin).apply(false)
    @Suppress("DSL_SCOPE_VIOLATION") kotlin("jvm").version(libs.versions.jetbrains.kotlin).apply(false)
    @Suppress("DSL_SCOPE_VIOLATION") kotlin("multiplatform").version(libs.versions.jetbrains.kotlin).apply(false)
    @Suppress("DSL_SCOPE_VIOLATION") kotlin("plugin.serialization").version(libs.versions.jetbrains.kotlin).apply(false)
    @Suppress("DSL_SCOPE_VIOLATION") id("org.jetbrains.compose").version(libs.versions.jetbrains.compose).apply(false)
}Arjan van Wieringen
02/05/2023, 9:42 AMAdam S
02/05/2023, 9:44 AMe: /home/.local/share/gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-serialization/1.8.0/938336470c17e5706f7ab33f2b2ee2fcfacfe80/kotlin-serialization-1.8.0-gradle75.jar!/META-INF/kotlinx-serialization-compiler-plugin.k2.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more detailsAdam S
02/05/2023, 9:49 AMval versionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
there’s no official support for using them, so it will probably cause weird issues. And generally, I don’t think it’s necessary - the versions can be left up to the actual projects because 1. it’s easier to see what versions are used in a subproject if they’re defined locally, 2. it can lead to weird issues if two plugins want to use two different versions, and 3. if ever a project wants to ‘opt out’ of a version, it could be really trickyArjan van Wieringen
02/05/2023, 9:54 AMimplementation dependency then in a library plugin?Adam S
02/05/2023, 9:54 AMAdam S
02/05/2023, 10:03 AM., and for some reason that’s making either Kotlin or Gradle confusedAdam S
02/05/2023, 10:04 AMModule was compiled with an incompatible version of Kotlin this was caused by me opening the projects in IntelliJ which auto-downloaded Gradle 7.5.1, but the root project has 7.6. So I copied the Gradle wrapper files from the root project.Adam S
02/05/2023, 10:06 AMconvention.repositories.gradle.kts to repositories.gradle.kts
2. add package convention at the topArjan van Wieringen
02/05/2023, 10:19 AMAdam S
02/05/2023, 10:21 AMAdam S
02/05/2023, 10:25 AMlibs.versions.toml to centralise the definitions, and create a java-version-platform subproject for version alignment. Then in the version-platform I use the libs.versions.toml to add all the BOMs or other dependencies, and in all subprojects import the version-platform, and again use libs.versions.toml to add specific dependencies.Adam S
02/05/2023, 10:26 AMAdam S
02/05/2023, 10:31 AMPlugin with id 'convention.repositories' not found but I can’t figure out why. My guess is that chaining two includedBuilds doesn’t pass along plugin IDs. Do you really need two separate includedBuild projects for convention plugins?Adam S
02/05/2023, 10:32 AMIncluding plugin builds via the plugin management block is an incubating feature. You may also use the stablemechanism outsideincludeBuildto include plugin builds. However, this does not support all use cases and including plugin builds like that will be deprecated once the new mechanism is stable.pluginManagement
Arjan van Wieringen
02/05/2023, 10:36 AMArjan van Wieringen
02/05/2023, 10:36 AMPoisonedYouth
02/05/2023, 10:38 AMAdam S
02/05/2023, 10:39 AMAdam S
02/05/2023, 10:42 AMlibs.versions.toml, version-catalog etc in a large project, take a look at https://github.com/adamko-dev/kafkatorio/
(although it is quite messy)Adam S
02/05/2023, 10:45 AM