https://kotlinlang.org logo
Title
s

Stephan Schroeder

04/29/2019, 5:15 PM
so I got a local plugin that my other project just can’t seem to find (with the local maven repository):
group = "uk.co.mulecode"
version = "1.0.0-SNAPSHOT"

...

gradlePlugin {
    plugins {
        create("easy-scm") {
            id = "uk.co.mulecode.easy-scm"
            implementationClass = "uk.co.mulecode.EasyScm"
        }
    }
}
after running
gradle install
I can find it in /Users/MDuke/.m2/repository/uk/co/mulecode/easy-scm/1.0.0-SNAPSHOT/easy-scm-1.0.0-SNAPSHOT.jar. Still when trying to use it in another project by importing it locally
buildscript {
    repositories {
        mavenLocal()
//        mavenCentral()
    }
    dependencies {
//        classpath("uk.co.mulecode:easy-scm:1.0.0-SNAPSHOT")
//        classpath("uk.co.mulecode:uk.co.mulecode.easy-scm:1.0.0-SNAPSHOT")
        classpath(group = "uk.co.mulecode", name="easy-scm", version = "1.0.0-SNAPSHOT")
    }
}

plugins {
    id("java")
    id("maven")
    id("uk.co.mulecode.easy-scm") version "1.0.0-SNAPSHOT"
}
...
it isn’t found, as can be seen by running `gradle tasks`:
FAILURE: Build failed with an exception.

* Where:
Build file '/Users/SSchrod/progs/progtests/sandbox-project/build.gradle.kts' line: 12

* What went wrong:
Plugin [id: 'uk.co.mulecode.easy-scm', version: '1.0.0-SNAPSHOT'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'uk.co.mulecode.easy-scm:uk.co.mulecode.easy-scm.gradle.plugin:1.0.0-SNAPSHOT')
  Searched in the following repositories:
    Gradle Central Plugin Repository
the artifact path looks pretty messed up but I just can’t figure out what the problem is. To add insult to injury importing of the plugin actually works from an equivalent Groovy-DSL gradle project.
o

octylFractal

04/29/2019, 5:20 PM
I think you can get the correct repository by specifying it in
settings.gradle.kts
instead, using
pluginManagement
https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_management
technically
plugins {}
is not supposed to reference/rely on
buildscript
content, including repositories
s

Stephan Schroeder

04/30/2019, 8:35 AM
Thanks, that works! It seems a bit hacky, but it gets the job done 😃
//settings.gradle.kts
pluginManagement {
    resolutionStrategy {
        eachPlugin {
            if (requested.id.namespace == "uk.co.mulecode") {
                useModule("uk.co.mulecode:simple-version:1.0.0-SNAPSHOT")
            }
        }
    }
    repositories {
        mavenLocal()
        gradlePluginPortal()
    }
}
e

efemoney

05/01/2019, 4:08 AM
I dont think you need
if (requested.id.namespace == "uk.co.mulecode")
Since you are specifying the version inline also