Reputation: 1024
I have 3 projects, build with Gradle (8.6), that I wanted to share dependencies and plugins. To do so, I've created a multi module build with buildSrc. I try to follow documentations and schema generated with Gradle and using convetion plugins. However, I cannot add any plugins (including lombok) beside 'java' plugin.
My goal was that I wanted to create a "common" project where other modules can get dependencies and plugins from.
I was able to recreate problem when using standard schema generated with 'Gradle init'.
My confing looks like this:
buildSrc/java-common.conventions:
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
// Apply the java Plugin to add support for Java.
id 'java'
id 'io.freefair.lombok' //Lombok project
}
repositories {
// Use Maven Central for resolving dependencies.
google()
mavenCentral()
}
dependencies {
constraints {
// Define dependency versions as constraints
implementation 'org.apache.commons:commons-text:1.9'
}
// Use JUnit Jupiter API for testing.
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
// Use JUnit Jupiter Engine for testing.
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
tasks.named('test') {
// Use junit platform for unit tests.
useJUnitPlatform()
}
buildSrc/java.application.conventions.gradle
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
// Apply the common convention plugin for shared build configuration between library and application projects.
id 'com.temp.java-common-conventions'
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}
app/build.gradle
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'com.temp.java-application-conventions'
}
dependencies {
implementation 'org.apache.commons:commons-text'
implementation project(':utilities')
}
application {
// Define the main class for the application.
mainClass = 'com.temp.app.App'
}
And error that I get:
Build file 'C:\Temp\GradleExample\app\build.gradle' line: 6
An exception occurred applying plugin request [id: 'com.temp.java-application-conventions']
> Failed to apply plugin 'com.temp.java-application-conventions'.
> Failed to apply plugin 'com.temp.java-common-conventions'.
> org.gradle.api.plugins.UnknownPluginException: Plugin with id 'io.freefair.lombok' not found.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
Upvotes: 2
Views: 267