Fix dependencies to the cross-project tasks

This commit is contained in:
Ilya Chernikov
2018-01-16 12:49:12 +01:00
committed by Vyacheslav Gerasimov
parent 434bbafe58
commit 555e9674b2
12 changed files with 11 additions and 32 deletions
+1 -2
View File
@@ -355,14 +355,13 @@ task<Copy>("dist") {
} }
val compilerCopyTask = task<Copy>("idea-plugin-copy-compiler") { val compilerCopyTask = task<Copy>("idea-plugin-copy-compiler") {
dependsOnTaskIfExistsRec("dist") shouldRunAfter(":dist")
into(ideaPluginDir) into(ideaPluginDir)
from(distDir) { include("kotlinc/**") } from(distDir) { include("kotlinc/**") }
} }
task<Copy>("ideaPlugin") { task<Copy>("ideaPlugin") {
dependsOn(compilerCopyTask) dependsOn(compilerCopyTask)
dependsOnTaskIfExistsRec("idea-plugin")
shouldRunAfter(":prepare:idea-plugin:idea-plugin") shouldRunAfter(":prepare:idea-plugin:idea-plugin")
into("$ideaPluginDir/lib") into("$ideaPluginDir/lib")
} }
-20
View File
@@ -20,26 +20,6 @@ fun Project.callGroovy(name: String, vararg args: Any?): Any? {
return (property(name) as Closure<*>).call(*args) return (property(name) as Closure<*>).call(*args)
} }
fun AbstractTask.dependsOnTaskIfExists(task: String, project: Project?, parentProject: Project?) {
val thisTask = this
val p = project ?: this.project
p.afterEvaluate {
p.tasks.firstOrNull { it.name == task }?.also {
if (parentProject != null) {
parentProject.evaluationDependsOn(p.path)
}
thisTask.dependsOn(it)
}
}
}
fun AbstractTask.dependsOnTaskIfExistsRec(task: String, project: Project? = null, parentProject: Project? = null) {
dependsOnTaskIfExists(task, project, parentProject)
(project ?: this.project).subprojects.forEach {
dependsOnTaskIfExistsRec(task, it, this.project)
}
}
inline fun<T: Any> Project.withJavaPlugin(crossinline body: () -> T?): T? { inline fun<T: Any> Project.withJavaPlugin(crossinline body: () -> T?): T? {
var res: T? = null var res: T? = null
pluginManager.withPlugin("java") { pluginManager.withPlugin("java") {
+1 -1
View File
@@ -24,7 +24,7 @@ sourceSets {
testsJar {} testsJar {}
projectTest { projectTest {
dependsOnTaskIfExistsRec("dist", project = rootProject) shouldRunAfter(":dist")
dependsOn(":prepare:mock-runtime-for-test:dist") dependsOn(":prepare:mock-runtime-for-test:dist")
workingDir = rootDir workingDir = rootDir
} }
+1 -1
View File
@@ -22,7 +22,7 @@ tasks.withType<KotlinCompile> {
projectTest { projectTest {
executable = "${rootProject.extra["JDK_18"]!!}/bin/java" executable = "${rootProject.extra["JDK_18"]!!}/bin/java"
dependsOnTaskIfExistsRec("dist", project = rootProject) shouldRunAfter(":dist")
dependsOn(":prepare:mock-runtime-for-test:dist") dependsOn(":prepare:mock-runtime-for-test:dist")
workingDir = rootDir workingDir = rootDir
systemProperty("kotlin.test.script.classpath", the<JavaPluginConvention>().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator)) systemProperty("kotlin.test.script.classpath", the<JavaPluginConvention>().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator))
+1 -1
View File
@@ -17,6 +17,6 @@ sourceSets {
} }
projectTest { projectTest {
dependsOnTaskIfExistsRec("dist", project = rootProject) shouldRunAfter(":dist")
workingDir = rootDir workingDir = rootDir
} }
+1 -1
View File
@@ -17,5 +17,5 @@ val ideaSandboxDir: File by rootProject.extra
runIdeTask("runIde", ideaPluginDir, ideaSandboxDir) { runIdeTask("runIde", ideaPluginDir, ideaSandboxDir) {
dependsOn(":dist", ":prepare:idea-plugin:idea-plugin", ":ideaPlugin") shouldRunAfter(":ideaPlugin")
} }
+1 -1
View File
@@ -116,7 +116,7 @@ sourceSets {
} }
projectTest { projectTest {
dependsOnTaskIfExistsRec("dist", project = rootProject) shouldRunAfter(":dist")
workingDir = rootDir workingDir = rootDir
doFirst { doFirst {
systemProperty("idea.home.path", intellijRootDir().canonicalPath) systemProperty("idea.home.path", intellijRootDir().canonicalPath)
+1 -1
View File
@@ -47,7 +47,7 @@ sourceSets {
} }
projectTest { projectTest {
dependsOnTaskIfExistsRec("dist", project = rootProject) shouldRunAfter(":dist")
workingDir = rootDir workingDir = rootDir
doFirst { doFirst {
systemProperty("idea.home.path", intellijRootDir().canonicalPath) systemProperty("idea.home.path", intellijRootDir().canonicalPath)
@@ -52,7 +52,7 @@ evaluationDependsOn(":kotlin-android-extensions-runtime")
projectTest { projectTest {
environment("ANDROID_EXTENSIONS_RUNTIME_CLASSES", getSourceSetsFrom(":kotlin-android-extensions-runtime")["main"].output.classesDirs.asPath) environment("ANDROID_EXTENSIONS_RUNTIME_CLASSES", getSourceSetsFrom(":kotlin-android-extensions-runtime")["main"].output.classesDirs.asPath)
dependsOnTaskIfExistsRec("dist", project = rootProject) shouldRunAfter(":dist")
workingDir = rootDir workingDir = rootDir
doFirst { doFirst {
val androidPluginPath = File(intellijRootDir(), "plugins/android").canonicalPath val androidPluginPath = File(intellijRootDir(), "plugins/android").canonicalPath
@@ -37,7 +37,7 @@ testsJar {}
projectTest { projectTest {
workingDir = rootDir workingDir = rootDir
dependsOnTaskIfExistsRec("dist", project = rootProject) shouldRunAfter(":dist")
} }
runtimeJar() runtimeJar()
+1 -1
View File
@@ -177,7 +177,7 @@ val ideaUltimatePluginDir: File by rootProject.extra
task<Copy>("ideaUltimatePlugin") { task<Copy>("ideaUltimatePlugin") {
dependsOn("$communityPluginProject:ideaPlugin") dependsOn("$communityPluginProject:ideaPlugin")
dependsOnTaskIfExistsRec("ideaPlugin", rootProject) shouldRunAfter(":ideaPlugin")
into(ideaUltimatePluginDir) into(ideaUltimatePluginDir)
from(ideaPluginDir) { exclude("lib/kotlin-plugin.jar") } from(ideaPluginDir) { exclude("lib/kotlin-plugin.jar") }
from(jar, { into("lib") }) from(jar, { into("lib") })
+1 -1
View File
@@ -19,6 +19,6 @@ val ideaUltimateSandboxDir: File by rootProject.extra
if (intellijUltimateEnabled) { if (intellijUltimateEnabled) {
runIdeTask("runUltimate", ideaUltimatePluginDir, ideaUltimateSandboxDir) { runIdeTask("runUltimate", ideaUltimatePluginDir, ideaUltimateSandboxDir) {
dependsOn(":dist", ":prepare:idea-plugin:idea-plugin", ":ideaPlugin", ":ultimate:idea-ultimate-plugin") shouldRunAfter(":ultimate:ideaUltimatePlugin")
} }
} }