Skip to content

Using gradle, sources not generated under build/generated-sources but build/classes/java/quarkus-generated-sources #1130

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

Open
laurentperez opened this issue May 6, 2025 · 6 comments
Labels
area:client This item is related to the client extension

Comments

@laurentperez
Copy link
Contributor

laurentperez commented May 6, 2025

Tell us the extension you're using

Client

I tried this:

Hi. Labelling as bug but I'm not sure this is the correct label.

Use case : we use gradle, not maven.

./gradlew compileJava generates the sources in build/classes/java/quarkus-generated-sources/open-api-json. note the "classes" folder.

I believe this should generate in build/generated-sources/open-api-json instead. See https://docs.quarkiverse.io/quarkus-openapi-generator/dev/client.html, where maven would generate in target/ root

I've looked into the source and I do not understand how "classes/java/quarkus-generated*sources" is prefixed to io.quarkiverse.openapi.generator.deployment.codegen.OpenApiGeneratorOutputPaths#OPENAPI_PATH

I believe the root path is https://github.com/quarkiverse/quarkus-openapi-generator/blob/main/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java#L104

Is it correct when I write that gradle should generate in build/generated-sources ?

thanks

This happened:

The target folder does not seem right

I expected this:

Sources in build/generated-sources

Is there a workaround?

Manually adding sources in IDE from build/classes/java/quarkus-generated-sources instead of empty build/generated-sources

How can we try to reproduce the issue?

./gradlew compilejava

Anything else?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus OpenApi version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.name: Bug Report 🐞
@ricardozanini
Copy link
Member

Hi!

The target output comes from Quarkus and is provided by the io.quarkus.deployment.CodeGenProvider class. So wherever the platform tells us where to save the generated code, we will do so.

@geoand do you know who we can talk to about this?

@ricardozanini ricardozanini added the area:client This item is related to the client extension label May 6, 2025
@laurentperez
Copy link
Contributor Author

digging deeper, this sounds similar to redhat-developer/vscode-java#1675 (comment) or https://youtrack.jetbrains.com/issue/IDEA-364096/Quarkus-generated-source-is-not-marked-as-source-directory

I'm not even confident to suggest that the extension should override the path provided by the CodeGenProvider so that both maven and gradle write their generated sources under build/generated-sources/open-api-xxx because it may be breaking existing gradle builds when authors already added build/classes/java/quarkus-generated-sources under their srcSets

Should I instead make a PR so that the extension documentation mentions that under gradle, the generated sources will land in a buildtool-specific Path ?

I understand this is gradle related and that the majority (?) of extension users still use maven, so I'm evaluating if a documentation specific PR would be an adequate hint.

@ricardozanini
Copy link
Member

Should I instead make a PR so that the extension documentation mentions that under gradle, the generated sources will land in a buildtool-specific Path ?

Oh that would be pretty good, please do! 🙏

@geoand
Copy link

geoand commented May 7, 2025

Maybe @aloubyansky has some thoughts on this

@aloubyansky
Copy link
Member

build/classes/java/quarkus-generated-sources doesn't look right though. I guess those generated sources end up in the final JAR then?

@laurentperez
Copy link
Contributor Author

build/classes/java/quarkus-generated-sources doesn't look right though. I guess those generated sources end up in the final JAR then?

Here is a reproducer, this path seems to be the default when we use gradle+kotlin

The extension indeed honors this path and will generate under "generated source directory:"

However the .java sources will not be in the final jar, only classes will be there.

The path doesn't look right - and it feels weird to include sources from a classes folder, but I'm not sure this is "wrong" from a gradle build tool perspective ?
I'm not sure if gradle has a convention telling where generated sources should be written.

sdk i quarkus
quarkus create app --kotlin --gradle-kotlin-dsl
cd code-with-quarkus
./gradlew build

Started Gradle worker daemon (0.91 secs) with fork options DaemonForkOptions{executable=/usr/local/sdkman/candidates/java/21.0.7-tem/bin/java, minHeapSize=null, maxHeapSize=null, jvmArgs=[], keepAliveMode=SESSION}.
Generating Quarkus code for org.acme:code-with-quarkus:1.0.0-SNAPSHOT
  launch mode:                  NORMAL
  base name:                    code-with-quarkus-1.0.0-SNAPSHOT
  generated source directory:   /workspaces/quarkus-openapi-generator/foo/code-with-quarkus/build/classes/java/quarkus-generated-sources
  build directory:              /workspaces/quarkus-openapi-generator/foo/code-with-quarkus/build


@laurentperez ➜ /workspaces/quarkus-openapi-generator/foo/code-with-quarkus (main) $ jar xvf build/quarkus-app/app/code-with-quarkus-1.0.0-SNAPSHOT.jar 
  created: META-INF/
 inflated: META-INF/code-with-quarkus.kotlin_module
  created: org/
  created: org/acme/
 inflated: org/acme/GreetingResource.class
  created: org/openapi/
  created: org/openapi/quarkus/
  created: org/openapi/quarkus/foo_yaml/
  created: org/openapi/quarkus/foo_yaml/model/
 inflated: org/openapi/quarkus/foo_yaml/model/HelloGet200Response$HelloGet200ResponseQueryParam.class
 inflated: org/openapi/quarkus/foo_yaml/model/HelloGet200Response.class
  created: org/openapi/quarkus/foo_yaml/api/
 inflated: org/openapi/quarkus/foo_yaml/api/DefaultApi.class
 inflated: application.properties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:client This item is related to the client extension
Projects
None yet
Development

No branches or pull requests

4 participants