[Build] Extract configuration of JUnit5 dependencies to common helper in buildSrc

This commit is contained in:
Dmitriy Novozhilov
2021-02-01 12:21:29 +03:00
parent dea3c954f1
commit c432efc364
10 changed files with 63 additions and 42 deletions
+47
View File
@@ -9,10 +9,13 @@
import org.gradle.api.GradleException import org.gradle.api.GradleException
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection import org.gradle.api.file.FileCollection
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.project import org.gradle.kotlin.dsl.project
import java.io.File import java.io.File
@@ -112,6 +115,50 @@ fun DependencyHandler.projectTests(name: String): ProjectDependency = project(na
fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = project(name, configuration = "runtimeJar") fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = project(name, configuration = "runtimeJar")
fun DependencyHandler.projectArchives(name: String): ProjectDependency = project(name, configuration = "archives") fun DependencyHandler.projectArchives(name: String): ProjectDependency = project(name, configuration = "archives")
fun Project.testApiJUnit5(
vintageEngine: Boolean = false,
runner: Boolean = false,
suiteApi: Boolean = false
) {
with(dependencies) {
val platformVersion = commonVer("org.junit", "junit-bom")
testApi(platform("org.junit:junit-bom:$platformVersion"))
testApi("org.junit.jupiter:junit-jupiter")
if (vintageEngine) {
testApi("org.junit.vintage:junit-vintage-engine:$platformVersion")
}
val componentsVersion = commonVer("org.junit.platform", "")
val components = mutableListOf(
"org.junit.platform:junit-platform-commons",
"org.junit.platform:junit-platform-launcher"
)
if (runner) {
components += "org.junit.platform:junit-platform-runner"
}
if (suiteApi) {
components += "org.junit.platform:junit-platform-suite-api"
}
for (component in components) {
testApi("$component:$componentsVersion")
}
addDependencyTo<ExternalModuleDependency>(this, "testImplementation", intellijDep()) {
// This dependency is needed only for FileComparisonFailure
includeJars("idea_rt", rootProject = rootProject)
isTransitive = false
}
// This is needed only for using FileComparisonFailure, which relies on JUnit 3 classes
add("testRuntimeOnly", commonDep("junit:junit"))
}
}
private fun DependencyHandler.testApi(dependencyNotation: Any) {
add("testApi", dependencyNotation)
}
val Project.protobufVersion: String get() = findProperty("versions.protobuf") as String val Project.protobufVersion: String get() = findProperty("versions.protobuf") as String
val Project.protobufRepo: String val Project.protobufRepo: String
+1 -12
View File
@@ -24,10 +24,7 @@ dependencies {
testApi(project(":compiler:fir:entrypoint")) testApi(project(":compiler:fir:entrypoint"))
testApi(project(":compiler:frontend")) testApi(project(":compiler:frontend"))
testApi(platform("org.junit:junit-bom:5.7.0")) testApiJUnit5()
testApi("org.junit.jupiter:junit-jupiter")
testApi("org.junit.platform:junit-platform-commons:1.7.0")
testApi("org.junit.platform:junit-platform-launcher:1.7.0")
testCompileOnly(project(":kotlin-reflect-api")) testCompileOnly(project(":kotlin-reflect-api"))
testRuntimeOnly(project(":kotlin-reflect")) testRuntimeOnly(project(":kotlin-reflect"))
@@ -35,14 +32,6 @@ dependencies {
testRuntimeOnly(project(":compiler:fir:fir2ir:jvm-backend")) testRuntimeOnly(project(":compiler:fir:fir2ir:jvm-backend"))
testImplementation(intellijCoreDep()) { includeJars("intellij-core") } testImplementation(intellijCoreDep()) { includeJars("intellij-core") }
testImplementation(intellijDep()) {
// This dependency is needed only for FileComparisonFailure
includeJars("idea_rt", rootProject = rootProject)
isTransitive = false
}
// This is needed only for using FileComparisonFailure, which relies on JUnit 3 classes
testRuntimeOnly(commonDep("junit:junit"))
testRuntimeOnly(intellijDep()) { testRuntimeOnly(intellijDep()) {
includeJars( includeJars(
"jps-model", "jps-model",
+1 -4
View File
@@ -30,10 +30,7 @@ dependencies {
testApi(projectTests(":compiler:fir:analysis-tests")) testApi(projectTests(":compiler:fir:analysis-tests"))
testApi(project(":compiler:fir:fir-serialization")) testApi(project(":compiler:fir:fir-serialization"))
testApi(platform("org.junit:junit-bom:5.7.0")) testApiJUnit5()
testApi("org.junit.jupiter:junit-jupiter")
testApi("org.junit.platform:junit-platform-commons:1.7.0")
testApi("org.junit.platform:junit-platform-launcher:1.7.0")
testCompileOnly(project(":kotlin-reflect-api")) testCompileOnly(project(":kotlin-reflect-api"))
testRuntimeOnly(project(":kotlin-reflect")) testRuntimeOnly(project(":kotlin-reflect"))
+1 -12
View File
@@ -17,23 +17,12 @@ dependencies {
testImplementation(projectTests(":generators:test-generator")) testImplementation(projectTests(":generators:test-generator"))
testApi(platform("org.junit:junit-bom:5.7.0")) testApiJUnit5()
testApi("org.junit.jupiter:junit-jupiter")
testApi("org.junit.platform:junit-platform-commons:1.7.0")
testApi("org.junit.platform:junit-platform-launcher:1.7.0")
testApi(projectTests(":compiler:test-infrastructure")) testApi(projectTests(":compiler:test-infrastructure"))
testApi(projectTests(":compiler:test-infrastructure-utils")) testApi(projectTests(":compiler:test-infrastructure-utils"))
testApi(projectTests(":compiler:tests-compiler-utils")) testApi(projectTests(":compiler:tests-compiler-utils"))
testApi(projectTests(":compiler:tests-common-jvm6")) testApi(projectTests(":compiler:tests-common-jvm6"))
testImplementation(intellijDep()) {
// This dependency is needed only for FileComparisonFailure
includeJars("idea_rt", rootProject = rootProject)
isTransitive = false
}
// This is needed only for using FileComparisonFailure, which relies on JUnit 3 classes
testRuntimeOnly(commonDep("junit:junit"))
testRuntimeOnly(intellijDep()) { testRuntimeOnly(intellijDep()) {
includeJars( includeJars(
"jps-model", "jps-model",
@@ -12,21 +12,13 @@ dependencies {
testApi(projectTests(":compiler:test-infrastructure")) testApi(projectTests(":compiler:test-infrastructure"))
testApi(projectTests(":compiler:test-infrastructure-utils")) testApi(projectTests(":compiler:test-infrastructure-utils"))
testApi(projectTests(":compiler:tests-compiler-utils")) testApi(projectTests(":compiler:tests-compiler-utils"))
testCompile(projectTests(":compiler:tests-common"))
testCompile(projectTests(":compiler:tests-common-new")) testCompile(projectTests(":compiler:tests-common-new"))
testApi(platform("org.junit:junit-bom:5.7.0")) testApiJUnit5(vintageEngine = true, runner = true, suiteApi = true)
testApi("org.junit.jupiter:junit-jupiter")
testApi("org.junit.vintage:junit-vintage-engine:5.7.0")
testApi("org.junit.platform:junit-platform-commons:1.7.0")
testApi("org.junit.platform:junit-platform-launcher:1.7.0")
testApi("org.junit.platform:junit-platform-runner:1.7.0")
testApi("org.junit.platform:junit-platform-suite-api:1.7.0")
testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") } testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") }
testRuntime(project(":kotlin-reflect")) testRuntime(project(":kotlin-reflect"))
testRuntime(intellijDep()) testRuntime(intellijDep())
testRuntime(intellijDep())
testJvm6ServerRuntime(projectTests(":compiler:tests-common-jvm6")) testJvm6ServerRuntime(projectTests(":compiler:tests-common-jvm6"))
} }
@@ -7,8 +7,7 @@ dependencies {
testRuntimeOnly(intellijDep()) // Should come before compiler, because of "progarded" stuff needed for tests testRuntimeOnly(intellijDep()) // Should come before compiler, because of "progarded" stuff needed for tests
testImplementation(kotlinStdlib()) testImplementation(kotlinStdlib())
testImplementation(platform("org.junit:junit-bom:5.7.0")) testApiJUnit5()
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation(projectTests(":compiler:tests-common")) testImplementation(projectTests(":compiler:tests-common"))
testImplementation(projectTests(":compiler:test-infrastructure")) testImplementation(projectTests(":compiler:test-infrastructure"))
testImplementation(projectTests(":compiler:tests-common-new")) testImplementation(projectTests(":compiler:tests-common-new"))
+2
View File
@@ -16,3 +16,5 @@ versions.jar.lz4-java=1.7.1
ignore.jar.snappy-in-java=true ignore.jar.snappy-in-java=true
versions.gradle-api=4.5.1 versions.gradle-api=4.5.1
versions.shadow=5.2.0 versions.shadow=5.2.0
versions.junit-bom=5.7.0
versions.org.junit.platform=1.7.0
+2
View File
@@ -15,3 +15,5 @@ versions.jar.lz4-java=1.7.1
ignore.jar.snappy-in-java=true ignore.jar.snappy-in-java=true
versions.gradle-api=4.5.1 versions.gradle-api=4.5.1
versions.shadow=5.2.0 versions.shadow=5.2.0
versions.junit-bom=5.7.0
versions.org.junit.platform=1.7.0
+2
View File
@@ -19,3 +19,5 @@ versions.gradle-api=4.5.1
versions.shadow=5.2.0 versions.shadow=5.2.0
ignore.jar.common=true ignore.jar.common=true
ignore.jar.lombok-ast=true ignore.jar.lombok-ast=true
versions.junit-bom=5.7.0
versions.org.junit.platform=1.7.0
+2
View File
@@ -19,3 +19,5 @@ versions.gradle-api=4.5.1
versions.shadow=5.2.0 versions.shadow=5.2.0
ignore.jar.common=true ignore.jar.common=true
ignore.jar.lombok-ast=true ignore.jar.lombok-ast=true
versions.junit-bom=5.7.0
versions.org.junit.platform=1.7.0