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: Fix circular task dependency with Quarkus plugin #1344

Merged
merged 1 commit into from
Jan 9, 2023

Conversation

snazy
Copy link
Contributor

@snazy snazy commented 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

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
@@ -46,4 +46,8 @@ tasks.named<Test>("test") {
useJUnitPlatform()
}

tasks.named("pluginUnderTestMetadata") {
dependsOn("processJandexIndex")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to this PR, fixes this build warning:

> Task :pluginUnderTestMetadata
Execution optimizations have been disabled for task ':pluginUnderTestMetadata' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/home/snazy/devel/misc/smallrye-open-api/tools/gradle-plugin/build/resources/main'. Reason: Task ':pluginUnderTestMetadata' uses this output of task ':processJandexIndex' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.6/userguide/validation_problems.html#implicit_dependency for more details about this problem.

t.dependsOn(genTaskName);
t.from(project.getTasks().getByName(genTaskName).getOutputs().getFiles());
});
project.getTasks().named(sourceSet.getJarTaskName(), Jar.class)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is the actual fix

@sonarcloud
Copy link

sonarcloud bot commented Jan 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@MikeEdgar MikeEdgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for looking at and fixing this @snazy

@MikeEdgar MikeEdgar merged commit 64000ce into smallrye:main Jan 9, 2023
@snazy snazy deleted the fix-circular-dependency-w-quarkus branch January 9, 2023 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gradle Plugin: Circular Dependency
2 participants