Trying to install Worker API plugin to local .m2

Can anyone help me work out how to install the below example Worker API plugin to the local .m2 repository? My understanding is that I should now use publishToMavenLocal. However, when we do this we get a “:publishToMavenLocal UP-TO-DATE” response but nothing goes into the local repository.

ZKMAction2.zip

By way of background, the example plugin simply passes parameters to a local closed source JAR. The Worker API is being used in an attempt to avoid Gradle instrumenting the local JAR which (in the real world) would do an anti-tamper check.

I didn’t really understand what you try to do, but it certainly sounds like the wrong approach for sure.

But anyway answer the question, you do not have any publication defined, so there is nothing to publish. The actual publishToMavenLocal task never has anything to do, as it just depends on the actual publish tasks that would be there if you would have defined any publication.

I didn’t really understand what you try to do

In its simplest terms I am trying to install the example plugin in ZKMAction2.zip to the local .m2 repository. With earlier versions of Gradle I could simply say “gradle build install”. That no longer works with Gradle 8.

The actual publishToMavenLocal task never has anything to do

Firstly, is publishToMavenLocal task the appropriate way of installing a plugin to the local repository or is there a better way?

If I must use the publishToMavenLocal task then could you please give me an example publish task that will simply install the plugin to the local repository. E.g. Do I have to add something to the build.gradle?

There do not seem to be any version 8, end to end full detail examples available on the Internet.

Just to be clear, I did not create the plugin that I am now trying to install. It was given to me by members of the Gradle development team as the recommended way of preventing Gradle from instrumenting a local JAR that is referenced by a plugin.

In its simplest terms I am trying to install the example plugin in ZKMAction2.zip to the local .m2 repository.

That is an empty project with a plugin in buildSrc that even says in the description “It is in buildSrc for sake of a simple example but should be extracted.”. So what you have there seems to just be a showcase and not something that is ready-to-use.

With earlier versions of Gradle I could simply say “gradle build install”. That no longer works with Gradle 8.

That’s not correct. With ancient version of Gradle you had to apply the maven plugin and if you are not happy with the defaults configure it, then were able to use the install task.

With current versions you apply the maven-publish plugin and if you are not happy with the defaults configure it, then are able to use the publishToMavenLocal task.
And as I said, in the default configuration there is no publication defined, so there is nothing to publish.
Just have a look at the documentation at Maven Publish Plugin.

But even then, again, that is an empty project there is nothing that you could configure to be published like it is.

Firstly, is publishToMavenLocal task the appropriate way of installing a plugin to the local repository or is there a better way?

Scratch “a plugin” and replace it by “something” and it is correct, yes. That is the way to publish all defined publications to maven local. Once there are multiple publications, there are also tasks for only publishing a specific publication and publishToMavenLocal just depends on all of those as described in the docs.

There do not seem to be any version 8, end to end full detail examples available on the Internet.

???
Practically any build that is published somewhere is a complete end-to-end example.

Just to be clear, I did not create the plugin that I am now trying to install. It was given to me by members of the Gradle development team

Maybe you should contact those people then to learn how you should use what you were given? :slight_smile:

as the recommended way of preventing Gradle from instrumenting a local JAR that is referenced by a plugin.

That sample project from a cursory look just seems to demonstrate how to use the worker API and does not seem to be a ready-to-use end product.

So what you have there seems to just be a showcase and not something that is ready-to-use.

I guess that explains why I could not make sense of it or make it work.

Maybe you should contact those people then to learn how you should use what you were given?

After giving me the purported example Worker API solution, the Gradle developers brushed me off when I could not make it work. They instead referred me to this support group.

“It is in buildSrc for sake of a simple example but should be extracted”

Can you make any sense of this comment that was inserted into the source? Extracted to where?

If you or anyone else can help me understand how this Worker API example was supposed to work it would be greatly appreciated.

The comment probably means you should set up a proper new plugin project, move the example implementation done in buildSrc in that example project into the plugin project nad add tests, publishing, and whatever else you need.