Hi,
What I’m trying to do:
- I have a custom Maven repository containing Plugins, for example a Sonarqube Plugin which I want to add in my Gradle project
- The project should consist of multiple subprojects where I can share common build logic via buildSrc as well as share logic between subprojects
Thus I did setup the following project structure:
.
├── api
│ ├── build.gradle
├── buildSrc
│ ├── build.gradle
│ └── src
│ └── main
│ └── groovy
│ └── java-common-conventions.gradle
├── gradle
└── settings.gradle
The content of aforementioned files is as following:
settings.gradle
pluginManagement {
repositories {
maven {
name = "plugin-releases"
url = "https://my-custom-repo-url/artifactory/plugins-release"
}
}
}
rootProject.name = 'gradle-multiproject'
include("api")
buildSrc/build.gradle
plugins {
id 'groovy-gradle-plugin'
}
repositories {
gradlePluginPortal()
}
buildSrc/src/main/groovy/java-common-conventions.gradle
plugins {
id 'java-library'
id 'org.sonarqube'
}
dependencies {
implementation 'org.slf4j:slf4j-api:2.0.9'
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.named('test', Test) {
useJUnitPlatform()
}
// Just a test to make sure the plugin is loaded correctly and can be configured
sonarqube {
description = "Global sonarqube configuration"
property 'sonar.sourceEncoding', 'UTF-8'
}
api/build.gradle
plugins {
id 'java-common-conventions'
}
Error message:
An exception occurred applying plugin request [id: ‘java-common-conventions’]
Failed to apply plugin ‘java-common-conventions’.
org.gradle.api.plugins.UnknownPluginException: Plugin with id ‘org.sonarqube’ not found.
If I’m browsing the repository URL, I can find the plugin, but I think it couldn’t be resolved.
Former projects used buildscript and classpath as following:
buildscript {
group = group
version = version
description = description
apply from: "${repositoryBaseUrl}/main.gradle"
dependencies {
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.1'
}
project.repositories {
mavenLocal()
maven {
name 'lib-snapshots'
url 'https://my-custom-repo-url/artifactory/libs-snapshot'
}
}
}
I think using buildscript this way doesn’t work in newer versions of Gradle and Java and is even discouraged, otherwise I am not sure how to tell Gradle the exact plugin ID or even if that’s the real issue here.
The maven POM looks like this:
<?xml version="1.0" encoding="US-ASCII"?>
<metadata>
<groupId>org.sonarqube</groupId>
<artifactId>org.sonarqube.gradle.plugin</artifactId>
<version>3.1</version>
<versioning>
<latest>3.1</latest>
<release>3.1</release>
<versions>
<version>3.1</version>
</versions>
<lastUpdated>20250515071239</lastUpdated>
</versioning>
</metadata>
I’m sure I’m confusing a few things, so any advice would be highly appreciated!