0

project structure

my-project
﹂ buildSrc
  ﹂ build.settings.kts
﹂ plugin
  ﹂ src
    ﹂ main
       ﹂ com
          ﹂ example
             ﹂ GreetingPlugin.kt
  ﹂ build.settings.kts
﹂ playground
  ﹂ build.settings.kts
settings.gradle.kts

I created a custom plugin in plugin module. Basically just print "Hello" in console when applied. I published to local maven. And in settings.gradle.kts, I added mavenLocal(), which should apply to all sub modules' scripts.

settings.gradle.kts

pluginManagement {
    repositories {
        mavenLocal()
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

rootProject.name = 'my-project'

include(":plugin")
include(":playground")

In playground module I can apply it without issue.

playground/build.settings.kts

plugins {
    kotlin("jvm")
    id("com.example.greeting") version "0.0.1-SNAPSHOT"
}

repositories {
    mavenCentral()
}

I can see it print "Hello" when build

> Configure project :playground
Hello

But when I tried to apply that to buildSrc, it just throws Plugin [id: 'com.example.greeting', version: '0.0.1-SNAPSHOT'] was not found in any of the following sources:

buildSrc/build.settings.kts

plugins {
    kotlin("jvm") version "1.7.20"
    id("com.example.greeting") version "0.0.1-SNAPSHOT"
}

repositories {
    mavenCentral()
}

I event tried add mavenLocal() to buildSrc/build.settings.kts, but still the same. I don't really get how buildSrc refers to which repositories.

How can use my custom plugin in my local maven?

Arst
  • 3,098
  • 1
  • 35
  • 42

0 Answers0