Some Task Execution Confusion

Hi,
I have a task that creates a custom jar that contains only tests, i.e., ‘createTestJar’ that is of type Jar. I want the createTestJar task to only be built when executing the uploadArchives task and not during the build task as they are essentially doing the same thing and is redundant. Is there a way to only have the createTestJar task run during uploadArchives task and be excluded when running the build task?

The createTestJar task should be marked as up-to-date if run a second time with no input changes. If that is working then you probably don’t need to worry too much about the task having two parent dependencies since the task will only be executed once. If up-to-date isn’t working, then I would try to understand why and fix that instead. Running Gradle with -i will show some information about why a task is not up-to-date.