Skip to content

Commit d039d19

Browse files
committed
Fix tests in the new build infrastructure
1 parent a61facf commit d039d19

48 files changed

Lines changed: 380 additions & 225 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ant/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apply { plugin("kotlin") }
66
dependencies {
77
compile(commonDep("org.apache.ant", "ant"))
88
compile(project(":kotlin-preloader"))
9-
compile(project(":kotlin-stdlib"))
9+
compile(projectDist(":kotlin-stdlib"))
1010
}
1111

1212
sourceSets {

build-common/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ dependencies {
1313
testCompile(commonDep("junit:junit"))
1414
testCompile(project(":compiler.tests-common"))
1515
testCompile(protobufFull())
16-
testRuntime(project(":kotlin-stdlib"))
17-
testRuntime(project(":kotlin-reflect"))
16+
testRuntime(projectDist(":kotlin-stdlib"))
17+
testRuntime(projectDist(":kotlin-reflect"))
1818
}
1919

2020
sourceSets {

buildSrc/src/main/kotlin/CommonUtil.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ inline fun <reified T : Task> Project.task(noinline configuration: T.() -> Unit)
1313

1414

1515
fun AbstractTask.dependsOnTaskIfExists(task: String) {
16-
project.tasks.firstOrNull { it.name == task }?.let { dependsOn(it) }
16+
val thisTask = this
17+
project.afterEvaluate {
18+
project.tasks.firstOrNull { it.name == task }?.let { thisTask.dependsOn(it) }
19+
}
1720
}
1821

1922
fun AbstractTask.dependsOnTaskIfExistsRec(task: String, project: Project? = null) {

buildSrc/src/main/kotlin/artifacts.kt

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import org.gradle.api.artifacts.Configuration
88
import org.gradle.api.artifacts.ConfigurationContainer
99
import org.gradle.api.artifacts.Dependency
1010
import org.gradle.api.file.DuplicatesStrategy
11+
import org.gradle.api.plugins.BasePluginConvention
1112
import org.gradle.api.plugins.JavaPluginConvention
1213
import org.gradle.api.tasks.javadoc.Javadoc
1314
import org.gradle.jvm.tasks.Jar
14-
15+
import java.io.File
1516

1617
fun Project.testsJar(body: Jar.() -> Unit = {}): Jar {
1718
val testsJarCfg = configurations.getOrCreate("tests-jar").extendsFrom(configurations["testCompile"])
@@ -93,7 +94,7 @@ fun Project.publish(body: Upload.() -> Unit = {}): Upload {
9394
}
9495
}
9596

96-
fun Project.ideaPlugin(subdir: String = "lib", body: Copy.() -> Unit) {
97+
fun Project.ideaPlugin(subdir: String = "lib", body: AbstractCopyTask.() -> Unit) {
9798
task<Copy>("idea-plugin") {
9899
body()
99100
into(File(rootProject.extra["ideaPluginDir"].toString(), subdir).path)
@@ -105,19 +106,27 @@ fun Project.ideaPlugin(subdir: String = "lib") = ideaPlugin(subdir) {
105106
fromRuntimeJarIfExists(this)
106107
}
107108

109+
fun Project.dist(targetDir: File? = null,
110+
targetName: String? = null,
111+
fromTask: Task? = null,
112+
body: AbstractCopyTask.() -> Unit = {}): AbstractCopyTask {
113+
val distJarCfg = configurations.getOrCreate("distJar")
114+
val distLibDir: File by rootProject.extra
115+
val distJarName = targetName ?: (the<BasePluginConvention>().archivesBaseName + ".jar")
108116

109-
fun Project.dist(body: Copy.() -> Unit) {
110-
task<Copy>("dist") {
117+
return task<Copy>("dist") {
111118
body()
112-
rename("-${java.util.regex.Pattern.quote(rootProject.extra["build.number"].toString())}", "")
113-
into(rootProject.extra["distLibDir"].toString())
119+
when {
120+
fromTask != null -> from(fromTask)
121+
else -> project.fromRuntimeJarIfExists(this)
122+
}
123+
rename(".*", distJarName)
124+
// rename("-${java.util.regex.Pattern.quote(rootProject.extra["build.number"].toString())}", "")
125+
into(targetDir ?: distLibDir)
126+
project.addArtifact(distJarCfg, this, File(targetDir ?: distLibDir, distJarName))
114127
}
115128
}
116129

117-
fun Project.dist() = dist {
118-
fromRuntimeJarIfExists(this)
119-
}
120-
121130
private fun<T: AbstractCopyTask> Project.fromRuntimeJarIfExists(task: T) {
122131
if (extra.has("runtimeJarTask")) {
123132
task.from(extra["runtimeJarTask"] as Task)

buildSrc/src/main/kotlin/dependencies.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ fun DependencyHandler.projectDep(name: String): Dependency = project(name, confi
5151
fun DependencyHandler.projectDepIntransitive(name: String): Dependency =
5252
project(name, configuration = "default").apply { isTransitive = false }
5353

54+
fun DependencyHandler.projectDist(name: String): Dependency = project(name, configuration = "distJar").apply { isTransitive = false }
5455
fun DependencyHandler.projectTests(name: String): Dependency = project(name, configuration = "tests-jar").apply { isTransitive = false }
5556
fun DependencyHandler.projectRuntimeJar(name: String): Dependency = project(name, configuration = "runtimeJar")
5657
fun DependencyHandler.projectArchives(name: String): Dependency = project(name, configuration = "archives")

compiler.tests-common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
compile(project(":js:js.translator"))
2424
compile(project(":android-extensions-compiler"))
2525
compile(project(":kotlin-test:kotlin-test-jvm"))
26-
compile(commonDep("junit"))
26+
compile(commonDep("junit:junit"))
2727
compile(ideaSdkCoreDeps("intellij-core"))
2828
compile(ideaSdkDeps("openapi", "idea", "idea_rt"))
2929
compile(preloadedDeps("dx", subdir = "android-5.0/lib"))

compiler/build.gradle.kts

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,55 @@ jvmTarget = "1.6"
99
val compilerModules: Array<String> by rootProject.extra
1010
val otherCompilerModules = compilerModules.filter { it != path }
1111

12+
val depDistProjects = listOf(
13+
":kotlin-script-runtime",
14+
":kotlin-stdlib",
15+
":kotlin-reflect",
16+
":kotlin-test:kotlin-test-jvm")
17+
18+
// TODO: it seems incomplete, find and add missing dependencies
19+
val testDistProjects = listOf(
20+
"", // for root project
21+
":prepare:mock-runtime-for-test",
22+
":kotlin-compiler",
23+
":kotlin-runtime",
24+
":kotlin-script-runtime",
25+
":kotlin-stdlib",
26+
":kotlin-stdlib-jre7",
27+
":kotlin-stdlib-jre8",
28+
":kotlin-stdlib-js",
29+
":kotlin-reflect",
30+
":kotlin-test:kotlin-test-jvm",
31+
":kotlin-test:kotlin-test-junit",
32+
":kotlin-test:kotlin-test-js",
33+
":kotlin-daemon-client",
34+
":android-extensions-compiler",
35+
":kotlin-ant")
36+
1237
dependencies {
38+
depDistProjects.forEach {
39+
testCompile(projectDist(it))
40+
}
1341
testCompile(commonDep("junit:junit"))
14-
testCompile(project(":kotlin-test:kotlin-test-jvm"))
15-
testCompile(project(":kotlin-test:kotlin-test-junit"))
42+
testCompileOnly(projectDist(":kotlin-test:kotlin-test-jvm"))
43+
testCompileOnly(projectDist(":kotlin-test:kotlin-test-junit"))
1644
testCompile(project(":compiler.tests-common"))
17-
testCompileOnly(project(":compiler:ir.ir2cfg"))
18-
testCompileOnly(project(":compiler:ir.tree")) // used for deepCopyWithSymbols call that is removed by proguard from the compiler TODO: make it more straightforward
19-
testCompile(ideaSdkDeps("openapi", "idea", "util", "asm-all", "commons-httpclient-3.1-patched"))
20-
// deps below are test runtime deps, but made test compile to split compilation and running to reduce mem req
21-
testCompile(project(":kotlin-stdlib"))
22-
testCompile(project(":kotlin-script-runtime"))
23-
testCompile(project(":kotlin-runtime"))
24-
testCompile(project(":kotlin-reflect"))
25-
testCompile(project(":android-extensions-compiler"))
26-
testCompile(project(":kotlin-ant"))
45+
testCompile(project(":compiler:ir.ir2cfg"))
46+
testCompile(project(":compiler:ir.tree")) // used for deepCopyWithSymbols call that is removed by proguard from the compiler TODO: make it more straightforward
2747
otherCompilerModules.forEach {
28-
testCompile(project(it))
48+
testCompileOnly(project(it))
2949
}
50+
testCompile(ideaSdkDeps("openapi", "idea", "util", "asm-all", "commons-httpclient-3.1-patched"))
3051
testRuntime(ideaSdkCoreDeps("*.jar"))
3152
testRuntime(ideaSdkDeps("*.jar"))
32-
// testRuntime(project(":kotlin-compiler", configuration = "default"))
3353
}
3454

3555
sourceSets {
3656
"main" {}
3757
"test" {
3858
projectDefault()
39-
java.srcDir("tests-ir-jvm/tests")
59+
// not yet ready
60+
// java.srcDir("tests-ir-jvm/tests")
4061
}
4162
}
4263

@@ -52,22 +73,6 @@ jar.apply {
5273

5374
testsJar {}
5475

55-
// TODO: it seems incomlete, find and add missing dependencies
56-
val testDistProjects = listOf(
57-
":prepare:mock-runtime-for-test",
58-
":kotlin-compiler",
59-
":kotlin-runtime",
60-
":kotlin-script-runtime",
61-
":kotlin-stdlib",
62-
":kotlin-stdlib-jre7",
63-
":kotlin-stdlib-jre8",
64-
":kotlin-stdlib-js",
65-
":kotlin-reflect",
66-
":kotlin-test:kotlin-test-jvm",
67-
":kotlin-test:kotlin-test-junit",
68-
":kotlin-test:kotlin-test-js",
69-
":kotlin-daemon-client")
70-
7176
projectTest {
7277
dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray())
7378
workingDir = rootDir

compiler/cli/cli-runner/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apply { plugin("kotlin") }
66
jvmTarget = "1.6"
77

88
dependencies {
9-
compile(project(":kotlin-stdlib"))
9+
compile(projectDist(":kotlin-stdlib"))
1010
}
1111

1212
sourceSets {

compiler/container/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ dependencies {
77
compile(project(":core:util.runtime"))
88
compile(commonDep("javax.inject"))
99
compile(ideaSdkCoreDeps("intellij-core"))
10+
testCompile(projectDist(":kotlin-test:kotlin-test-jvm"))
11+
testCompile(projectDist(":kotlin-test:kotlin-test-junit"))
1012
testCompile(commonDep("junit:junit"))
11-
testCompile(project(":kotlin-test:kotlin-test-jvm"))
1213
testRuntime(ideaSdkCoreDeps("trove4j", "intellij-core"))
1314
}
1415

compiler/frontend.script/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jvmTarget = "1.6"
66
dependencies {
77
compile(project(":compiler:util"))
88
compile(project(":compiler:frontend"))
9-
compile(project(":kotlin-reflect"))
9+
compile(projectDist(":kotlin-reflect"))
1010
compile(preloadedDeps("kotlinx-coroutines-core"))
1111
}
1212

0 commit comments

Comments
 (0)