Catch NoClassDefFoundError when BuildScanExtension is not found
Add simple test with init script #KT-59589
This commit is contained in:
committed by
Space Team
parent
1642eaa48a
commit
27043bd8a6
+44
@@ -16,6 +16,7 @@ import java.nio.file.Path
|
|||||||
import kotlin.io.path.*
|
import kotlin.io.path.*
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||||
|
import org.jetbrains.kotlin.gradle.testbase.TestVersions.ThirdPartyDependencies.GRADLE_ENTERPRISE_PLUGIN_VERSION
|
||||||
|
|
||||||
@DisplayName("Build reports")
|
@DisplayName("Build reports")
|
||||||
@JvmGradlePluginTests
|
@JvmGradlePluginTests
|
||||||
@@ -371,4 +372,47 @@ class BuildReportsIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("build reports work with init script")
|
||||||
|
@GradleTestVersions(
|
||||||
|
minVersion = TestVersions.Gradle.MIN_SUPPORTED,
|
||||||
|
additionalVersions = [TestVersions.Gradle.G_7_6, TestVersions.Gradle.G_8_0],
|
||||||
|
maxVersion = TestVersions.Gradle.G_8_1
|
||||||
|
)
|
||||||
|
@GradleTest
|
||||||
|
fun testBuildReportsWithInitScript(gradleVersion: GradleVersion) {
|
||||||
|
project("simpleProject", gradleVersion) {
|
||||||
|
gradleProperties.modify { "$it\nkotlin.build.report.output=BUILD_SCAN,FILE\n" }
|
||||||
|
|
||||||
|
val initScript = projectPath.resolve("init.gradle").createFile()
|
||||||
|
initScript.modify {
|
||||||
|
"""
|
||||||
|
initscript {
|
||||||
|
repositories {
|
||||||
|
maven { url = 'https://plugins.gradle.org/m2/' }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.gradle:gradle-enterprise-gradle-plugin:$GRADLE_ENTERPRISE_PLUGIN_VERSION'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeSettings {
|
||||||
|
it.pluginManager.apply(com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin)
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
build(
|
||||||
|
"compileKotlin",
|
||||||
|
"-I", "init.gradle",
|
||||||
|
)
|
||||||
|
|
||||||
|
build(
|
||||||
|
"compileKotlin",
|
||||||
|
"-I", "init.gradle",
|
||||||
|
enableBuildScan = true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -82,5 +82,6 @@ interface TestVersions {
|
|||||||
|
|
||||||
object ThirdPartyDependencies {
|
object ThirdPartyDependencies {
|
||||||
const val SHADOW_PLUGIN_VERSION = "8.1.1"
|
const val SHADOW_PLUGIN_VERSION = "8.1.1"
|
||||||
|
const val GRADLE_ENTERPRISE_PLUGIN_VERSION = "3.13.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -17,6 +17,10 @@ class BuildScanExtensionHolder(val buildScan: BuildScanExtension) : java.io.Seri
|
|||||||
// Build scan plugin is applied, but BuildScanExtension class is not available due to Gradle classpath isolation
|
// Build scan plugin is applied, but BuildScanExtension class is not available due to Gradle classpath isolation
|
||||||
// Could be reproduced by applying Gradle enterprise plugin via init script: KT-59589
|
// Could be reproduced by applying Gradle enterprise plugin via init script: KT-59589
|
||||||
null
|
null
|
||||||
|
} catch (e: NoClassDefFoundError) {
|
||||||
|
// Build scan plugin is applied, but BuildScanExtension class is not available due to Gradle classpath isolation
|
||||||
|
// Could be reproduced by applying Gradle enterprise plugin via init script: KT-59589
|
||||||
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildScanExtension?.let { BuildScanExtensionHolder(it) }
|
return buildScanExtension?.let { BuildScanExtensionHolder(it) }
|
||||||
|
|||||||
Reference in New Issue
Block a user