Skip to content

Commit 26c07ab

Browse files
committed
feat(GradleInspector): Add custom JDK download capability
Firewalled environments can't rely on open internet access, leading to invalid request to external Foojay Disco service. Adding customJdkUrl to enable the capability of direct download of an specified JDK as long as it is tied to javaVersion. Signed-off-by: Helio Chissini de Castro <[email protected]>
1 parent ba2982c commit 26c07ab

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

plugins/package-managers/gradle-inspector/src/main/kotlin/GradleInspector.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ data class GradleInspectorConfig(
9393
* The directory of the Java home to use when analyzing projects. By default, the same Java home as for ORT itself
9494
* is used.
9595
*/
96-
val javaHome: String?
96+
val javaHome: String?,
97+
98+
/**
99+
* Custom JDK URL for direct download instead of the Disco service. It is valid if the javaVersion is set together.
100+
*/
101+
val customJdkUrl: String?
97102
)
98103

99104
/**
@@ -163,9 +168,15 @@ class GradleInspector(
163168
val javaHome = config.javaVersion
164169
?.takeUnless { JavaBootstrapper.isRunningOnJdk(it) }
165170
?.let {
166-
JavaBootstrapper.installJdk("TEMURIN", it).onFailure { e ->
167-
issues += createAndLogIssue(e.collectMessages())
168-
}.getOrNull()
171+
if (config.customJdkUrl != null) {
172+
JavaBootstrapper.downloadJdk(config.customJdkUrl, "custom", it).onFailure { e ->
173+
issues += createAndLogIssue(e.collectMessages())
174+
}.getOrNull()
175+
} else {
176+
JavaBootstrapper.installJdk("TEMURIN", it).onFailure { e ->
177+
issues += createAndLogIssue(e.collectMessages())
178+
}.getOrNull()
179+
}
169180
} ?: config.javaHome?.let { File(it) }
170181

171182
javaHome?.also {

0 commit comments

Comments
 (0)