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

Support for dev-mode-only conditional dependencies #44424

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aloubyansky
Copy link
Member

@aloubyansky aloubyansky commented Nov 11, 2024

This change introduces support for extension conditional dependencies that include dev mode as one of the conditions to enable a dependency.

The simplest form of a conditional dependency would be one extension declaring a dev mode conditional dependency on another extension w/o further conditions, i.e. dev mode will be the only condition. For example

            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-extension-maven-plugin</artifactId>
                <version>${quarkus.version}</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>extension-descriptor</goal>
                        </goals>
                        <configuration>
                            <deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment>
                            <conditionalDevDependencies>
                                <extension>${project.groupId}:quarkus-blue:${project.version}</extension>
                            </conditionalDevDependencies>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

An extension that is configured with the above quarkus-extension-maven-plugin configuration will declared a dev-mode-only dependency on extension quarkus-blue. quarkus-blue will be a regular extension, it will not have to configure anything on its side.

If an extension declaring a dev mode dependency on quarkus-blue also needs a compile time dependency on quarkus-blue, it can add an optional or provided dependency onquarkus-blue.

@phillip-kruger does this look Ok to you? I haven't added the docs yet, otherwise, it should be usable.

@quarkus-bot quarkus-bot bot added area/core area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins labels Nov 11, 2024
@phillip-kruger
Copy link
Member

@aloubyansky can you show an example on how an extension will pull in it's own dev ui (runtime json-rpc services) ?

@aloubyansky
Copy link
Member Author

For now this is limited to extension dependencies.

Today applications could add an optional or provided dependency to make it available in dev mode but not in prod. It would be present in test mode too though.

@aloubyansky
Copy link
Member Author

Oh, sorry, I'm waking up :)
An extension may configure a dev mode dependency on another extension. Just a min I'll push an example.

@aloubyansky
Copy link
Member Author

Here is a very simple example https://github.com/aloubyansky/playground/tree/dev-mode-conditional-deps

quarkus-blue is a regular extension project.
quarkus-red adds a dev mode only dependency on quarkus-blue in https://github.com/aloubyansky/playground/blob/dev-mode-conditional-deps/quarkus-red/runtime/pom.xml#L35
It doesn't add any other (Maven) dependency on it but it could, for example optional or provided, in case it needs it on the compile classpath.
An application adds a dependency on quarkus-red https://github.com/aloubyansky/playground/blob/dev-mode-conditional-deps/app/pom.xml#L16

The application can be launched in dev mode with mvn clean compile quarkus:dev

@maxandersen
Copy link
Member

Nice.

Haven't tried it yet but just curious - does the sbom generation captures this already or would that require more changes ?

  • does it work with Gradle ?

  • I'm going to assume it works with jbang as it would just be handled by Quarkus build time dep resolver?

  • any downsides you spotted when implementing it ?

@aloubyansky
Copy link
Member Author

Gradle will need a minor adjustment. Otherwise it should work.

Copy link

github-actions bot commented Nov 15, 2024

🎊 PR Preview 0d1aa9a has been successfully built and deployed to https://quarkus-pr-main-44424-preview.surge.sh/version/main/guides/

  • Images of blog posts older than 3 months are not available.
  • Newsletters older than 3 months are not available.

@aloubyansky
Copy link
Member Author

The implementation and docs are done. I'm looking to add a test for Gradle.

@aloubyansky aloubyansky marked this pull request as ready for review November 15, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/documentation area/gradle Gradle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants