Skip to content

Commit

Permalink
Avoid throwing exception when BuildFusService can't be injected
Browse files Browse the repository at this point in the history
#KT-63990
  • Loading branch information
nav-nav authored and qodana-bot committed Dec 19, 2023
1 parent cfbb957 commit b0cc245
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,20 @@ class ProjectIsolationIT : KGPBaseTest() {
build(":main-project:compileKotlin")
}
}

@DisplayName("project with buildSrc should be compatible with project isolation")
@GradleTestVersions(
minVersion = TestVersions.Gradle.G_7_4
)
@JvmGradlePluginTests
@GradleTest
fun testProjectIsolationWithBuildSrc(gradleVersion: GradleVersion) {
project(
projectName = "kt-63990-buildSrcWithKotlinJvmPlugin",
gradleVersion = gradleVersion,
buildOptions = defaultBuildOptions.copy(configurationCache = null)
) {
build("tasks")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class BuildOptions(
val stacktraceMode: String? = StacktraceOption.FULL_STACKTRACE_LONG_OPTION,
val kotlinVersion: String = TestVersions.Kotlin.CURRENT,
val warningMode: WarningMode = WarningMode.Fail,
val configurationCache: Boolean = false,
val configurationCache: Boolean? = false, //null value is only for cases, when project isolation is used without configuration cache. Otherwise Gradle runner will throw exception "The configuration cache cannot be disabled when isolated projects is enabled."
val projectIsolation: Boolean = false,
val configurationCacheProblems: BaseGradleIT.ConfigurationCacheProblems = BaseGradleIT.ConfigurationCacheProblems.FAIL,
val parallel: Boolean = true,
Expand Down Expand Up @@ -114,8 +114,10 @@ data class BuildOptions(
WarningMode.None -> arguments.add("--warning-mode=none")
}

arguments.add("-Dorg.gradle.unsafe.configuration-cache=$configurationCache")
arguments.add("-Dorg.gradle.unsafe.configuration-cache-problems=${configurationCacheProblems.name.lowercase(Locale.getDefault())}")
if (configurationCache != null) {
arguments.add("-Dorg.gradle.unsafe.configuration-cache=$configurationCache")
arguments.add("-Dorg.gradle.unsafe.configuration-cache-problems=${configurationCacheProblems.name.lowercase(Locale.getDefault())}")
}

if (gradleVersion >= GradleVersion.version("7.1")) {
arguments.add("-Dorg.gradle.unsafe.isolated-projects=$projectIsolation")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
plugins {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
kotlin("jvm")
}

repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal class BuildFinishFlowAction : FlowAction<BuildFinishFlowAction.Paramete
}

override fun execute(parameters: Parameters) {
parameters.buildFlowServiceProperty.get().recordBuildFinished(
parameters.buildFlowServiceProperty.orNull?.recordBuildFinished(
parameters.action.orNull, parameters.buildFailed.get()
)
}
Expand Down

0 comments on commit b0cc245

Please sign in to comment.