Skip to content

Commit 550ab36

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. Signed-off-by: Helio Chissini de Castro <[email protected]>
1 parent dc7326f commit 550ab36

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

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

Lines changed: 21 additions & 7 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
/**
@@ -160,16 +165,25 @@ class GradleInspector(
160165
addProgressListener(ProgressListener { logger.debug(it.displayName) })
161166
}
162167

163-
val javaHome = config.javaVersion
164-
?.takeUnless { JavaBootstrapper.isRunningOnJdk(it) }
165-
?.let {
166-
JavaBootstrapper.installJdk("TEMURIN", it).onFailure { e ->
168+
val javaHome = config.customJdkUrl
169+
?.let { url ->
170+
JavaBootstrapper.downloadJdk(url).onFailure { e ->
167171
issues += createAndLogIssue(e.collectMessages())
168172
}.getOrNull()
169-
} ?: config.javaHome?.let { File(it) }
173+
}
174+
175+
?: config.javaVersion
176+
?.takeUnless { JavaBootstrapper.isRunningOnJdk(it) }
177+
?.let { version ->
178+
JavaBootstrapper.installJdk("TEMURIN", version).onFailure { e ->
179+
issues += createAndLogIssue(e.collectMessages())
180+
}.getOrNull()
181+
}
182+
183+
?: config.javaHome?.let { File(it) }
170184

171185
javaHome?.also {
172-
logger.info { "Setting Java home for project analysis to '$it'." }
186+
logger.info { "Setting Java home for project analysis to '$it'. " }
173187
setJavaHome(it)
174188
}
175189
}

0 commit comments

Comments
 (0)