Skip to content

tasks.named can no longer find a task from another project #1718

Description

@NonSwag

Expected and Results

Before updating from 9.0.2 to 9.1.0 I used dependsOn(project(":source-generator").tasks.named("generateSources")) to make the compileJava task depend on my generateSources task

This however no longer works, the task cannot be found.
Using dependsOn(":source-generator:generateSources") works though.

This is a breaking change, and I didn't find anything in the changelogs or documentations that this behavior will be changed.

Related environment and versions

Updated from Shadow 9.0.2 to 9.1.0
Gradle version 9.1.0-rc-2

Reproduction steps

Depend on a task from another project using the following code:

tasks.compileJava {
    dependsOn(project(":source-generator").tasks.named("generateSources"))
}

Anything else?

A problem occurred configuring root project 'per-worlds'.
> Could not create task ':compileJava'.
   > Task with name 'generateSources' not found in project ':source-generator'.

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'per-worlds'.
	...
Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':compileJava'.
	...
Caused by: org.gradle.api.UnknownTaskException: Task with name 'generateSources' not found in project ':source-generator'.
	...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions