Test the custom gradle plugin

I have developed a custom gradle plugin.
I created a new functionTest configuration and under functionalTest/resources

I have a basic-project with build.gradle and settings.gradle.

Also under functionalTest/java I have a Test.java
Which has functional tests written with gradle runner. Which uses resources/basic-project to test

I want to apply the plugin here in basic-project/build.gradle and check if the tasks in the plugin are producing outputs as expected.

Now I’m not able to use the latest build of the plugin unless I publish it to a repository.

How do I do this without publishing it anywhere?

You could publish it to “Maven Local”. The java-gradle-plugin should create a task for that automatically.

Make sure, that mavenLocal() is a plugin repository in your project, so it can resolve plugins from there.

1 Like

If so, than better not use mavenLocal() which is broken by design from Maven already.
Better deploy to some dedicated local file-based repository and use that in the test.

But usually, if you use .withPluginClasspath() with TestKit, that should already add your plugin to the classpath of the test and make it usable in your tests.

1 Like

@Vampire thanks. withClasspath() was the find.
I previously didn’t recognise that functionalTest was consuming the previous publish into the local maven repository.

But this makes me impossible to test the current build unless it is published.
I want to publish only after the functionTest succeeds.

Ah, sorry. I misunderstood. I though you wanted to test the published plugin manually after it was unit/IT/functional tested.

1 Like