Optional shared artifacts

Hello,

My project consist of multiple subprojects. Each of these outputs a jar. For deployment I need to sign those jar and collect all of them. So what I did is defining a signJar task that does its stuff to create a new signed jar and I used the sharing task output as described here: Sharing outputs between projects to pass all the jars to the root project.

Now I have a problem in that running gradle build, the signJar tasks are always executed due to being added as

artifacts {
    add("signedJar", signedJar)
}

in each subproject.

Is there a way to have those created only when publishing and not when calling the build task?

Thanks!

If you don’t depend on them, they should not be built I think.
You probably should provide an MCVE that shows your behavior so that you can maybe get a recommendation what to change concretely.

They are build at least by the build task for sure. I’ll try creating a dummy project.