Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Plugin: Circular Dependency #1335

Closed
wabuMike opened this issue Dec 16, 2022 · 3 comments · Fixed by #1344
Closed

Gradle Plugin: Circular Dependency #1335

wabuMike opened this issue Dec 16, 2022 · 3 comments · Fixed by #1344
Labels
bug Something isn't working plugin/gradle
Milestone

Comments

@wabuMike
Copy link

wabuMike commented Dec 16, 2022

How to reproduce

  1. Include the Gradle Plugin in an existing Quarkus Gradle project as described in https://github.com/smallrye/smallrye-open-api/blob/main/tools/gradle-plugin/README.md#via-gradle-includebuild
  2. On the existing project, execute the Gradle task "generateOpenApiSpec" with ./gradlew generateOpenApiSpec. Gradle will give you the error:

FAILURE: Build failed with an exception.

  • What went wrong:
    Circular dependency between the following tasks:
    :compileJava
    +--- :quarkusGenerateCode
    | --- :processResources
    | --- :generateOpenApiSpec
    | +--- :compileJava ()
    | +--- :quarkusGenerateCode (
    )
    | --- :quarkusGenerateCodeDev
    | --- :processResources ()
    --- :quarkusGenerateCodeDev (
    )

(*) - details omitted (listed previously)

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 2s

Solution

The problem is with those lines in SmallryeOpenApiPlugin.java:

project.getTasks().named(sourceSet.getProcessResourcesTaskName(), ProcessResources.class)
                .configure(t -> {
                    t.dependsOn(genTaskName);
                    t.from(project.getTasks().getByName(genTaskName).getOutputs().getFiles());
                });

When I remove those lines, the task runs as expected. I suppose those lines have their purpose and although removing them works for my use case, it might break other use cases.

@MikeEdgar
Copy link
Member

@snazy, do you have any ideas on this one? My Gradle expertise isn't quite up to par :-)

@MikeEdgar MikeEdgar added the bug Something isn't working label Jan 7, 2023
@snazy
Copy link
Contributor

snazy commented Jan 9, 2023

Looking...

snazy added a commit to snazy/smallrye-open-api that referenced this issue Jan 9, 2023
The Smallrye Gradle plugin adds the generated OpenAPI schema files (YAML + JSON) to the generated jar file. This was achieved using via the `processResources` task, which unfortunately is not "compatible" with the Quarkus plugin (see below output). The fix is to add the generated schema files directly to the `jar` task.

Tests have been added to verify interopability with the Quarkus plugin, also reproducers for smallrye#1335 (without the production code changes of course):
```
Circular dependency between the following tasks:
:compileJava
+--- :quarkusGenerateCode
|    \--- :processResources
|         \--- :generateOpenApiSpec
|              +--- :compileJava (*)
|              +--- :quarkusGenerateCode (*)
|              \--- :quarkusGenerateCodeDev
|                   \--- :processResources (*)
\--- :quarkusGenerateCodeDev (*)
```

Fixes smallrye#1335
@MikeEdgar MikeEdgar added this to the 3.1.2 milestone Jan 9, 2023
@snazy
Copy link
Contributor

snazy commented Jan 9, 2023

Fix in #1344

MikeEdgar pushed a commit that referenced this issue Jan 9, 2023
The Smallrye Gradle plugin adds the generated OpenAPI schema files (YAML + JSON) to the generated jar file. This was achieved using via the `processResources` task, which unfortunately is not "compatible" with the Quarkus plugin (see below output). The fix is to add the generated schema files directly to the `jar` task.

Tests have been added to verify interopability with the Quarkus plugin, also reproducers for #1335 (without the production code changes of course):
```
Circular dependency between the following tasks:
:compileJava
+--- :quarkusGenerateCode
|    \--- :processResources
|         \--- :generateOpenApiSpec
|              +--- :compileJava (*)
|              +--- :quarkusGenerateCode (*)
|              \--- :quarkusGenerateCodeDev
|                   \--- :processResources (*)
\--- :quarkusGenerateCodeDev (*)
```

Fixes #1335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin/gradle
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants