votingworks / electionguard-kotlin-multiplatform

An implementation of ElectionGuard version 2.0.0 in Kotlin.
MIT License
9 stars 5 forks source link

Create single place in gradle to specify the version of kotlin to use #258

Closed JohnLCaron closed 1 year ago

JohnLCaron commented 1 year ago

https://discuss.kotlinlang.org/t/specifying-the-kotlin-version-in-gradle-multi-project-builds/23838

Adding this to buildSrc/build.gradle.kts:

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21")
}

gives error:

Build file '/home/snake/dev/github/electionguard-kotlin-multiplatform/egklib/build.gradle.kts' line: 10

Error resolving plugin [id: 'org.jetbrains.kotlin.multiplatform', version: '1.7.21']
> The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.

seems to interfere with the use of dependencyResolutionManagement in settings.gradle.kts

JohnLCaron commented 1 year ago

https://discuss.kotlinlang.org/t/specifying-the-kotlin-version-in-gradle-multi-project-builds/23838

create root level build.gradle.kts::

plugins {
    java
    kotlin("jvm") version "1.7.21" apply false
}

gives error:

org.gradle.internal.exceptions.LocationAwareException: Build file '/home/snake/dev/github/electionguard-kotlin-multiplatform/egklib/build.gradle.kts' line: 10
Error resolving plugin [id: 'org.jetbrains.kotlin.multiplatform', version: '1.7.21']
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:233)

    ... 185 more
Caused by: org.gradle.plugin.management.internal.InvalidPluginRequestException: The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.
    at org.gradle.plugin.use.resolve.internal.AlreadyOnClasspathPluginResolver.resolve(AlreadyOnClasspathPluginResolver.java:84)
    at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:229)
JohnLCaron commented 1 year ago

Part of the problem may be that is that egklib and hacllib use:

kotlin("multiplatform") version "1.7.21"

but webapps uses

kotlin("jvm") version "1.7.21"
JohnLCaron commented 1 year ago

Would be nice to put

val kotlinVersion by extra("1.7.21") in some common place, then use it like

kotlin("multiplatform") version kotlinVersion

putting it in buildSrc/build.gradle.kts doesnt work putting it in build.gradle.kts doesnt work

JohnLCaron commented 1 year ago

putting

kotlinVersion=1.7.21

into gradle.properties

and then can use

plugins {
    kotlin("multiplatform") version providers.gradleProperty("kotlinVersion").get()
    ...

but only if theres a

buildscript {
    repositories {
    }
}

above the plugins (ok to be empty), otherwise you get

/home/snake/dev/github/electionguard-kotlin-multiplatform/hacllib/build.gradle.kts:3:37: Unresolved reference: providers

The usual gradle "ya just gotta know" bullshit