Skip to content

Provide an option to not add 'shdowJar' task to 'assemble' lifecycle #1908

@jjohannes

Description

@jjohannes

What feature do you want to see added?

Context

In our project, we have a quite strict lifecycle task setup to clearly communicate to developers about which tasks they need to know in daily development.

The tasks developers normally use are only: lifecycle tasks assemble and qualityGate and a number of test tasks for different test suites. When you run ./gradlew in one of our projects, you only see the following to not make Gradle appear unnecessary complex to those that only use it (and do not configure it):

------------------------------------------------------------
Tasks runnable from root project '...'
------------------------------------------------------------

Default tasks: tasks

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.
clean - Deletes the build directory.
qualityGate - Apply spotless rules and run all quality checks.
test - Runs the test suite.
testIntegration - Runs the test integration suite.
timeConsuming - Runs the time consuming suite.
timingSensitive - Runs the timing sensitive suite.

Issue with Shadow (since 9.2.0)

The developers are trained to use assemble as a "quick" check that everything compiles and assembles in general (Javadocs are generated, normal Jars can be packaged, ...). For that, we modified what is part of that assemble lifecycle and like to be in full control of it.

In particular, we do not want it to build shadow Jars as we use these only for specific cases and they take quite some time to assemble as they are very large. But they do not add value to what developers expect assemble to do in our case.

Unfortunately, Gradle has no API to remove a dependsOn from a lifecycle task again. (It should have that, only for lifecycle task, but it does not.) Hence, it would be great if this plugin can offer a configuration option to not do this:

https://github.com/Jonathing/shadow/blob/a4ba8604dd4ab209e1adbe010a2644332574d99e/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt#L544-L546

Before the change in #1766, you could work around it by only applying parts of the shadow plugin in a specific way. I have done this here:

Since 9.2.0 we can't update anymore as this solution no longer works. Hence, from our perspective, it is a regression (we have a failing test).

Upstream changes

No response

Are you interested in contributing this feature?

If you agree to add this and let me know where the option can go, I am happy to provide a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions