I am uging “Gradle 8.1.1.” I have a question about using a plugin declared in a version-catalog inside a pre-compiled convention plugin? The version-catalog is published to a maven private repo with URL Rubens Private Maven Repo from a Git project found at BitBucket at
gradle-catalog
Below is my consuming Gradle convention plugin:
├── LICENSE.txt
├── README.md
├── build.gradle.kts
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
└── src
└── main
└── kotlin
└── com.rubensgomes.gradle.kotlin-conventions.gradle.kts
settings.gradle.kts:
rootProject.name = "gradle-conventions"
// centralized plugin dependency repositories
pluginManagement {
// property defined in ~/.gradle/gradle.properties
val myMavenRepoReadUrl: String by settings
repositories {
gradlePluginPortal()
mavenCentral()
// Rubens Gomes private maven consuming artifacts repo
maven ( url = myMavenRepoReadUrl )
}
}
// centralized library dependency repositories
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from("com.rubensgomes.gradle:gradle-catalog:1.0.0")
}
}
// property defined in ~/.gradle/gradle.properties
val myMavenRepoReadUrl: String by settings
repositories {
// add gradlePluginPortal so external plugins can be resolved
// in the dependencies section
gradlePluginPortal()
mavenCentral()
// Rubens Gomes private maven consuming artifacts repo
maven ( url = myMavenRepoReadUrl )
}
}
plugins {
// following plugin must be applied below to be used by the gradle build.
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}
build.gradle.kts:
plugins {
`java`
`maven-publish`
`kotlin-dsl`
}
group="com.rubensgomes.gradle"
version="1.0.0-SNAPSHOT"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.AMAZON)
}
}
publishing {
publications {
create<MavenPublication>("Kotlin-Gradle-Conventions") {
from(components["java"])
pom {
name.set("Gradle Kotlin Conventions")
description.set("Shareable configurations, plugins, tasks, and libraries to be used accross Kotlin development projects")
url.set("https://bitbucket.org/rubens-gomes/gradle-catalog/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("rubenssgomes")
name.set("Rubens Gomes")
email.set("rubens.s.gomes@gmail.com")
}
}
scm {
developerConnection.set("scm:git:ssh:git@bitbucket.org:rubens-gomes/gradle-conventions.git")
}
}
}
}
repositories {
// defined in ~/.gradle/gradle.properties
val myMavenRepoWriteUrl: String by project
val myMavenRepoWriteUsername: String by project
val myMavenRepoWritePassword: String by project
maven {
// private maven publishing artifacts repo
url = uri(myMavenRepoWriteUrl)
credentials {
username = myMavenRepoWriteUsername
password = myMavenRepoWritePassword
}
}
}
}
tasks.publish {
dependsOn("check")
}
src/main/kotlin/com.rubensgomes.gradle.kotlin-conventions.gradle.kts:
plugins {
`java`
// Following does not work, and is my questions?
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.spotless)
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.AMAZON)
}
}
repositories {
mavenCentral()
}
dependencies {
// SLF4J + Log4J Implementation
implementation(libs.bundles.logging)
// kotlin testing API + Junit engine
implementation(libs.bundles.testing)
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
// Java/Kotlin code formatter
spotless {
java {
importOrder()
googleJavaFormat()
formatAnnotations()
removeUnusedImports()
}
kotlin {
ktfmt()
}
}