Skip to content

Commit

Permalink
Merge pull request gradle#9143 from gradle/bamboo/master/revert-resol…
Browse files Browse the repository at this point in the history
…ver-java-home

Revert "Let Kotlin DSL resolver return given Java home"
  • Loading branch information
bamboo authored Apr 16, 2019
2 parents 3a3dedd + 062ee5c commit 4a5d9be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,6 @@ class KotlinScriptDependenciesResolverTest : AbstractKotlinIntegrationTest() {
assertSucceeds()
}

@Test
fun `returns given Java home`() {

val javaHome = System.getProperty("java.home")
val env = arrayOf("gradleJavaHome" to javaHome)
assertThat(
resolvedScriptDependencies(env = *env)?.javaHome,
equalTo(javaHome)
)
}


@Test
fun `succeeds on init script`() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ class KotlinBuildScriptDependenciesResolver @VisibleForTesting constructor(
previousDependencies: KotlinScriptExternalDependencies?
): KotlinScriptExternalDependencies? {

val request = scriptModelRequestFrom(scriptFile, environment, cid)
log(SubmittedModelRequest(cid, scriptFile, request))
val scriptModelRequest = scriptModelRequestFrom(scriptFile, environment, cid)
log(SubmittedModelRequest(cid, scriptFile, scriptModelRequest))

val response = DefaultKotlinBuildScriptModelRepository.scriptModelFor(request)
val response = DefaultKotlinBuildScriptModelRepository.scriptModelFor(scriptModelRequest)
if (response == null) {
log(RequestCancelled(cid, scriptFile, request))
log(RequestCancelled(cid, scriptFile, scriptModelRequest))
return null
}
log(ReceivedModelResponse(cid, scriptFile, response))
Expand All @@ -155,15 +155,15 @@ class KotlinBuildScriptDependenciesResolver @VisibleForTesting constructor(

return when {
response.exceptions.isEmpty() ->
dependenciesFrom(request, response).also {
dependenciesFrom(response).also {
log(ResolvedDependencies(cid, scriptFile, it))
}
previousDependencies != null && previousDependencies.classpath.count() > response.classPath.size ->
previousDependencies.also {
log(ResolvedToPreviousWithErrors(cid, scriptFile, previousDependencies, response.exceptions))
}
else ->
dependenciesFrom(request, response).also {
dependenciesFrom(response).also {
log(ResolvedDependenciesWithErrors(cid, scriptFile, it, response.exceptions))
}
}
Expand Down Expand Up @@ -207,12 +207,11 @@ class KotlinBuildScriptDependenciesResolver @VisibleForTesting constructor(
?: GradleInstallation.Wrapper

private
fun dependenciesFrom(request: KotlinBuildScriptModelRequest, response: KotlinBuildScriptModel) =
fun dependenciesFrom(response: KotlinBuildScriptModel) =
KotlinBuildScriptDependencies(
response.classPath,
response.sourcePath,
response.implicitImports,
request.javaHome?.path
response.implicitImports
)
}

Expand All @@ -221,8 +220,7 @@ internal
class KotlinBuildScriptDependencies(
override val classpath: Iterable<File>,
override val sources: Iterable<File>,
override val imports: Iterable<String>,
override val javaHome: String? = null
override val imports: Iterable<String>
) : KotlinScriptExternalDependencies


Expand Down

0 comments on commit 4a5d9be

Please sign in to comment.