Hi!
I use the plugin which has an official application way as follows:
buildscript {
val korgePluginVersion: String by project
repositories {
mavenLocal()
mavenCentral()
google()
maven { url = uri("https://plugins.gradle.org/m2/") }
}
dependencies {
classpath("com.soywiz.korlibs.korge.plugins:korge-gradle-plugin:$korgePluginVersion")
}
}
apply<KorgeGradlePlugin>()
Its artifact is com.soywiz.korlibs.korge.plugins:korge-gradle-plugin:2.1.1.4
.
I would like to use a modern way of plugin application. What I’ve come up is as follows:
pluginManagement {
repositories {
mavenLocal()
mavenCentral()
google()
maven("https://plugins.gradle.org/m2/")
}
val korgePluginVersion: String by settings
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.soywiz.korge") {
useModule("com.soywiz.korlibs.korge.plugins:korge-gradle-plugin:$korgePluginVersion")
}
}
}
plugins {
id("com.soywiz.korge") apply false
}
}
After it, I can easily apply it as plugins { id("com.soywiz.korge") }
in the required modules.
However, I don’t like this way since it seems more natural to me to specify version in the plugins block, like this:
```kt
pluginManagement {
repositories {
mavenLocal()
mavenCentral()
google()
maven("https://plugins.gradle.org/m2/")
}
val korgePluginVersion: String by settings
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.soywiz.korge") {
useModule("com.soywiz.korlibs.korge.plugins:korge-gradle-plugin")
}
}
}
plugins {
id("com.soywiz.korge") version korgePluginVersion apply false
}
}
Here I have an exception: Invalid format: 'com.soywiz.korlibs.korge.plugins:korge-gradle-plugin'. Group, name and version cannot be empty. Correct example: 'org.gradle:gradle-core:1.0'
.
Also, I’m not sure whether I need resolutionStrategy at all… Maybe I just need to specify a different plugin ID and everything starts working itself…
So could somebody advise what’s a proper way to migrate from apply plugin to plugins block in my case?