Hi
I’m trying to set up my first plugin environment as a standalone project and test it as described here
https://docs.gradle.org/current/userguide/custom_plugins.html
and
https://docs.gradle.org/8.5/userguide/testing_gradle_plugins.html#manual-tests
Project has 2 subprojects ‘plugin’ and ‘plugin-test’
The top level settings.gradle
# content of settings.gradle
rootProject.name = 'my-gradle-plugin'
//includeBuild "plugin"
//includeBuild "plugin-test"
include 'plugin', 'plugin-test'
plugin has a single class
interface GreetingPluginExtension {
Property<String> getMessage()
}
class GreetingPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
// Add the 'greeting' extension object
def extension = project.extensions.create('greeting', GreetingPluginExtension)
extension.message.convention('Hello from GreetingPlugin')
// Add a task that uses configuration from the extension object
project.task('hello') {
doLast {
println extension.message.get()
}
}
}
}
and plugin-test has settings.gradle
pluginManagement {
includeBuild "../plugin"
}
and its build.gradle
plugins {
id 'java'
}
//apply plugin: GreetingPlugin
when I execute from root of the project
./gradlew :plugin-test:tasks
I don’t see the task hello
Also
./gradlew :plugin-test:hello
FAILURE: Build failed with an exception.
* What went wrong:
Cannot locate tasks that match ':plugin-test:hello' as task 'hello' not found in project ':plugin-test'. Some candidates are: 'help'.
Uncommenting apply plugin
line does not change anything
What am I missing?
Are there any example projects I could check?
I’ve seen gradle itself uses includeBuild in its settings.gradle
but for me when I specify
rootProject.name = 'my-gradle-plugin'
includeBuild "plugin"
includeBuild "plugin-test"
I get
./gradlew :plugin-test:hello
FAILURE: Build failed with an exception.
* Where:
Initialization script '/Users/daniel/.gradle/init.d/taskinfo.gradle' line: 10
* What went wrong:
Failed to apply plugin class 'org.barfuin.gradle.taskinfo.GradleTaskInfoPlugin'.
> The plugin 'org.barfuin.gradle.taskinfo' does not support composite builds at this time.
You can still run it by adding -Ptaskinfo.disableSafeguard=true to your Gradle invocation.In that case, tasks from the included builds will be executed.
./gradlew -v
------------------------------------------------------------
Gradle 8.5
------------------------------------------------------------
Build time: 2023-11-29 14:08:57 UTC
Revision: 28aca86a7180baa17117e0e5ba01d8ea9feca598
Kotlin: 1.9.20
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 17.0.9 (Eclipse Adoptium 17.0.9+9)
OS: Mac OS X 14.2.1 aarch64