Skip to content

Replace Gradle's deprecated buildIdentifier.getName() with newer API #48522

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

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

Eng-Fouad
Copy link
Contributor

buildIdentifier.getName() is deprecated since Gradle 8.2 and will be removed in the next release Gradle 9.0.

* @deprecated Use {@link #getBuildPath()} instead.
     */
    @Deprecated
    String getName();

@quarkus-bot quarkus-bot bot added area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle labels Jun 22, 2025
@Eng-Fouad
Copy link
Contributor Author

Eng-Fouad commented Jun 22, 2025

I think this if-statement should be updated:

https://github.com/Eng-Fouad/quarkus/blob/b9ba83d8faa888f056df0ae1b5da3efd99d90c89/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java#L57-L60

if (ib.getName().equals(buildPath)) {
    return ib;
}

Previously it was:

if (ib.getName().equals(buildName)) {
    return ib;
}

and I am not sure how the values of buildPath and buildName look like:

/**
     * Absolute build path of the build within the Gradle invocation.
     *
     * @since 8.2
     */
    String getBuildPath();

    /**
     * The name of the build.
     *
     * @deprecated Use {@link #getBuildPath()} instead.
     */
    @Deprecated
    String getName();

Is it like this?

buildPath = /opt/myproject/subproject1/build
buildName = subproject1

cc @aloubyansky

@Eng-Fouad Eng-Fouad marked this pull request as ready for review June 22, 2025 11:05
@Eng-Fouad Eng-Fouad marked this pull request as draft June 22, 2025 11:06
@Eng-Fouad Eng-Fouad mentioned this pull request Jun 22, 2025
10 tasks
@Eng-Fouad
Copy link
Contributor Author

This resolves #39221 as well.

@maxandersen
Copy link
Member

i've seen a few of these "xyz deprecated in version something of gradle" - is any of this changing the base version of gradle we say Quarkus work with? do we keep track of it so we don't surprise users with breaking things by surprise?

@Eng-Fouad Eng-Fouad force-pushed the gradle-deprecated-3 branch from b9ba83d to abbcfdd Compare June 24, 2025 15:47
@Eng-Fouad Eng-Fouad marked this pull request as ready for review June 24, 2025 15:48

This comment has been minimized.

@Eng-Fouad
Copy link
Contributor Author

i've seen a few of these "xyz deprecated in version something of gradle" - is any of this changing the base version of gradle we say Quarkus work with? do we keep track of it so we don't surprise users with breaking things by surprise?

I am not sure. The Gradle guide does not mention any minimum supported Gradle versions.

cc @gsmet @geoand @aloubyansky

@wolfs
Copy link

wolfs commented Jun 24, 2025

Is it like this?

buildPath = /opt/myproject/subproject1/build
buildName = subproject1

No, the absolute build path means the path within a composite build. So the root build has name : (I think) and buildPath :. In included build logic build might have build path :build-logic and build name build-logic. Finally, if a included build includes a build logic build the build path would be :included-build:build-logic and the build name would be build-logic.

In general, the absolute build path is a unique identifier of an (included) build in a Gradle invocation, while the build name is not.

@Eng-Fouad
Copy link
Contributor Author

Eng-Fouad commented Jun 24, 2025

Is it like this?

buildPath = /opt/myproject/subproject1/build
buildName = subproject1

No, the absolute build path means the path within a composite build. So the root build has name : (I think) and buildPath :. In included build logic build might have build path :build-logic and build name build-logic. Finally, if a included build includes a build logic build the build path would be :included-build:build-logic and the build name would be build-logic.

In general, the absolute build path is a unique identifier of an (included) build in a Gradle invocation, while the build name is not.

So, is this implementation correct?

if ((":" + ib.getName()).equals(buildPath)) {
    return ib;
}

// or maybe
if (buildPath).endsWith((":" + ib.getName())) {
    return ib;
}

Alternatively, we can use (not sure if it is valid for all cases):

if (((DefaultIncludedBuild) ib).getBuildIdentifier().getBuildPath().equals(buildPath)) {
    return ib;
}

or

if (((IncludedBuildInternal) ib).getTarget().getBuildIdentifier().getBuildPath().equals(buildPath)) {
    return ib;
}

@wolfs
Copy link

wolfs commented Jun 24, 2025

This might work some of the time. What I don't understand is why you try to obtain the instance of the included build in the first place. What is the code trying to achieve and can that be achieved on the dependency level alone without reaching into other configured projects or included builds.

@Eng-Fouad Eng-Fouad force-pushed the gradle-deprecated-3 branch from abbcfdd to 9000916 Compare June 24, 2025 16:19
@Eng-Fouad
Copy link
Contributor Author

This might work some of the time. What I don't understand is why you try to obtain the instance of the included build in the first place. What is the code trying to achieve and can that be achieved on the dependency level alone without reaching into other configured projects or included builds.

The code existed before. I am just trying to replace deprecated methods that will be removed in the next release Gradle 9.0.

Copy link

quarkus-bot bot commented Jun 24, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 9000916.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

Copy link
Member

@aloubyansky aloubyansky left a comment

Choose a reason for hiding this comment

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

Thanks a lot @Eng-Fouad!

@aloubyansky
Copy link
Member

@wolfs thanks for your advises here. For now, we need to be able to discover project sources for certain launch modes. If there is a better way of doing that, please let us know. Thanks!

@aloubyansky aloubyansky merged commit 1fb6d40 into quarkusio:main Jun 25, 2025
23 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.25 - main milestone Jun 25, 2025
@Eng-Fouad Eng-Fouad deleted the gradle-deprecated-3 branch June 25, 2025 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle triage/backport
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants