Skip to content

Make the Disco URL configurable in ORT - #12257

Open
m-suchecki wants to merge 2 commits into
oss-review-toolkit:mainfrom
boschglobal:m-suchecki/configurable_disco_url
Open

m-suchecki wants to merge 2 commits into
oss-review-toolkit:mainfrom
boschglobal:m-suchecki/configurable_disco_url

Conversation

@m-suchecki

Copy link
Copy Markdown

This PR makes the Disco service URL configurable in JavaBootstrapper class. Refer to the single commits for further information.

Part of #12249.

@m-suchecki
m-suchecki requested a review from a team as a code owner August 4, 2026 09:03
@m-suchecki
m-suchecki force-pushed the m-suchecki/configurable_disco_url branch 3 times, most recently from e98c11c to 48be018 Compare August 4, 2026 13:08
@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.21%. Comparing base (c214d6c) to head (2bce5eb).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main   #12257   +/-   ##
=========================================
  Coverage     59.21%   59.21%           
  Complexity     1892     1892           
=========================================
  Files           366      366           
  Lines         13839    13839           
  Branches       1462     1462           
=========================================
  Hits           8195     8195           
  Misses         5115     5115           
  Partials        529      529           
Flag Coverage Δ
funTest-external-tools 16.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@m-suchecki
m-suchecki force-pushed the m-suchecki/configurable_disco_url branch 5 times, most recently from d09a3ee to a8eb1ab Compare August 6, 2026 11:40

@sschuberth sschuberth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure about this. Do we really need to be able to customize the foojay discoapi URL, or would it be sufficient to use the existing customJdkUrl feature (to point to a download URL on a custom discoapi server)?

* Return it on success, or an exception on failure. If [discoUrl] is null, use the default Disco API URL.
*/
internal fun findJdkPackage(distributionName: String, version: String): Result<Package> {
internal fun findJdkPackage(distributionName: String, version: String, discoUrl: String? = null): Result<Package> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So far, it (deliberately) was an implementation detail that the JavaBootstrapper uses the foojay discoapi, but now you're exposing that via the signature. The idea was that we could switch from foojay discoapi (which had several issues in the past months) to something else without breaking changes in public API.

@m-suchecki m-suchecki Aug 18, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I can rename it to something else, like jdkApiUrl or jdkRepoServerUrl, to remove the Foojay exposure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would change nothing about the fact that the URL needs to point to a Disco-API-compatible server.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, that is true. But we are missing the point that said URL will be a mirror or custom server compatible with currently used API. Be it DiscoAPI or something else in the future. Here, we are providing a possibility to use a similar service, based on the officially used one. After all, it's an optional parameter and don't have to be used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, so if the idea is to evolve JavaBootstrapper into a service-agnostic bootstrapper for JDKs that could also use something else than the Disco API service in the future, I'll all for it. But then then object should probably be turned into a class with a constructor argument that added the service URL (for whatever service it is) to here:

internal val discoService = DiscoService.create(client = OkHttpClientHelper.buildClient())

To override:

.baseUrl(url ?: DEFAULT_SERVER_URL)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

So I made JavaBootstrapper service-agnostic. It takes JdkService interface and calls findPackage(). FoojayJdkService implements it and uses DiscoService to fetch JDKs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure about the current approach with the JdkService abstraction. As it is now, consumers still need to know the underlying implementation since they have to create a JavaBootstrapper instance passing in the service. Also, I am not sure that we are already in the position to design a flexible abstraction as long as we only know a single discovery service implementation.

The original plan was much less ambitious: to only make the URL of the disco service used by JavaBootstrapper configurable. I think, the main problem is that in places whether JavaBootstrapper is used, no configuration mechanism is available that could be used for this purpose.

@sschuberth, do you have an idea how this could be solved without inventing a complete abstraction layer?

/**
* The URL of the Foojay Disco API. If unset, the Disco client's default URL is used.
*/
val discoUrl: String? = null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure whether we should add this on the AnalyzerConfiguration level. Not all analyzers / package managers need to be able to bootstrap a JDK, and also the related javaVersion property is defined per-package-manager.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Using AnalyzerConfiguration is the easiest way to set this variable, easily accessible by all package managers and didn't require too many changes. If you insist, it could probably be defined per-package-manager, similar to javaVersion. But it would be a duplicated entry, as I don't think anyone would use different servers for each package manager.

@sschuberth sschuberth Aug 18, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using AnalyzerConfiguration is the easiest way to set this variable,

I believe this is one of the cases where the solution with the least amount of code changes is not the best solution in the sense of maintainability and need-to-know-principle.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I see your point. Then it could be defined per-package-manager, in their config. Would that suffice?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That would certainly be better in my view. But personally, I'm still not convinced that this feature is of general use / interest on top of the customJdkUrl feature we already have, at least for GradleInspector.

What about other @oss-review-toolkit/core-devs?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I defined the URL variable (jdkRepositoryUrl) per-package-manager instead of using AnalyzerConfiguration.

@m-suchecki
m-suchecki force-pushed the m-suchecki/configurable_disco_url branch from a8eb1ab to d58af13 Compare September 3, 2026 10:26
@m-suchecki
m-suchecki force-pushed the m-suchecki/configurable_disco_url branch from d58af13 to 4c1814c Compare September 21, 2026 14:06
@sschuberth
sschuberth requested a review from a team September 21, 2026 14:20
Comment thread utils/ort/src/funTest/kotlin/FoojayJdkServiceFunTest.kt Dismissed
@m-suchecki
m-suchecki force-pushed the m-suchecki/configurable_disco_url branch 4 times, most recently from 6ea8d3e to 94cb0ae Compare September 29, 2026 08:32
Evolve JavaBootstrapper into service-agnostic bootstrapper
for JDKs that can use different JDK repositories.

Some environments may want or need to route Disco API calls through
custom endpoint. The URL was previously hardcoded in JavaBootstrapper
to default DiscoService URL making it impossible to use a custom proxy
or self-hosted mirror.

Signed-off-by: Marek Suchecki <Marek.Suchecki@pl.bosch.com>
Update JavaBootstrapperFunTest.kt test case to include new JDK service.
Add new FoojayJdkServiceFunTest.kt test class.

Signed-off-by: Marek Suchecki <Marek.Suchecki@pl.bosch.com>
@m-suchecki
m-suchecki force-pushed the m-suchecki/configurable_disco_url branch from 94cb0ae to b4c1d71 Compare September 29, 2026 08:33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants