diff --git a/ant/build.gradle.kts b/ant/build.gradle.kts index f507c495a40..924cd0611c6 100644 --- a/ant/build.gradle.kts +++ b/ant/build.gradle.kts @@ -11,7 +11,7 @@ dependencies { sourceSets { "main" { projectDefault() } - "test" { none() } + "test" {} } runtimeJar { diff --git a/buildSrc/src/main/kotlin/sourceSets.kt b/buildSrc/src/main/kotlin/sourceSets.kt index cfebd3cd3f6..c902494b365 100644 --- a/buildSrc/src/main/kotlin/sourceSets.kt +++ b/buildSrc/src/main/kotlin/sourceSets.kt @@ -1,83 +1,11 @@ @file:Suppress("unused") // usages in build scripts are not tracked properly import org.gradle.api.* -import org.gradle.api.file.SourceDirectorySet -import org.gradle.api.internal.HasConvention import org.gradle.api.plugins.JavaPluginConvention import org.gradle.api.tasks.* import org.gradle.kotlin.dsl.* -import java.io.File //import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet -private fun Project.configureKotlinProjectSourceSet(srcs: Iterable, - sourceSetName: String, - getSources: SourceSet.() -> SourceDirectorySet, - configureSourceDirs: SourceDirectorySet.() -> Unit) = - configure { - // if (srcs.none()) { -// sourceSets.removeIf { it.name == sourceSetName } -// } -// else { - sourceSets.matching { it.name == sourceSetName }.forEach { it.getSources().setSrcDirs(srcs).configureSourceDirs() } -// } - } - -private fun Project.configureKotlinProjectSourceSet(vararg srcs: String, sourceSetName: String, - getSources: SourceSet.() -> SourceDirectorySet, - sourcesBaseDir: File? = null, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectSourceSet(srcs.map { File(sourcesBaseDir ?: projectDir, it) }, sourceSetName, getSources, configureSourceDirs) - -fun Project.configureKotlinProjectSources(vararg srcs: String, - sourcesBaseDir: File? = null, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectSourceSet(*srcs, sourceSetName = "main", getSources = { this.java }, - sourcesBaseDir = sourcesBaseDir, configureSourceDirs = configureSourceDirs) - -fun Project.configureKotlinProjectSources(srcs: Iterable, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectSourceSet(srcs, sourceSetName = "main", getSources = { this.java }, configureSourceDirs = configureSourceDirs) - -fun Project.configureKotlinProjectSourcesDefault(sourcesBaseDir: File? = null, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectSources("src", sourcesBaseDir = sourcesBaseDir, configureSourceDirs = configureSourceDirs) - -fun Project.configureKotlinProjectResources(vararg srcs: String, - sourcesBaseDir: File? = null, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectSourceSet(*srcs, sourceSetName = "main", getSources = { this.resources }, - sourcesBaseDir = sourcesBaseDir, configureSourceDirs = configureSourceDirs) - -fun Project.configureKotlinProjectResources(srcs: Iterable, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectSourceSet(srcs, sourceSetName = "main", getSources = { this.resources }, configureSourceDirs = configureSourceDirs) - -fun Project.configureKotlinProjectResourcesDefault(sourcesBaseDir: File? = null) { - configureKotlinProjectResources("resources", sourcesBaseDir = sourcesBaseDir) - configureKotlinProjectResources("src", sourcesBaseDir = sourcesBaseDir) { include("META-INF/**", "**/*.properties") } -} - -fun Project.configureKotlinProjectNoTests() { - configureKotlinProjectSourceSet(sourceSetName = "test", getSources = { this.java }) - configureKotlinProjectSourceSet(sourceSetName = "test", getSources = { this.resources }) -} - -fun Project.configureKotlinProjectTests(vararg srcs: String, sourcesBaseDir: File? = null, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectSourceSet(*srcs, sourceSetName = "test", getSources = { this.java }, - sourcesBaseDir = sourcesBaseDir, configureSourceDirs = configureSourceDirs) - -fun Project.configureKotlinProjectTestsDefault(sourcesBaseDir: File? = null, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectTests("test", "tests", sourcesBaseDir = sourcesBaseDir, configureSourceDirs = configureSourceDirs) - -fun Project.configureKotlinProjectTestResources(vararg srcs: String, - sourcesBaseDir: File? = null, - configureSourceDirs: SourceDirectorySet.() -> Unit = {}) = - configureKotlinProjectSourceSet(*srcs, sourceSetName = "test", getSources = { this.resources }, - sourcesBaseDir = sourcesBaseDir, configureSourceDirs = configureSourceDirs) - - inline fun Project.sourceSets(crossinline body: SourceSetsBuilder.() -> Unit) = SourceSetsBuilder(this).body() @@ -88,6 +16,7 @@ class SourceSetsBuilder(val project: Project) { project.configure { sourceSets.matching { it.name == sourceSetName }.forEach { + none() it.body() } } @@ -95,15 +24,15 @@ class SourceSetsBuilder(val project: Project) { } fun SourceSet.none() { - java.srcDirs() - resources.srcDirs() + java.setSrcDirs(emptyList()) + resources.setSrcDirs(emptyList()) } fun SourceSet.projectDefault() { when (name) { "main" -> { java.srcDirs("src") - resources.srcDir("resources") + resources.srcDir("resources").apply { include("**") } resources.srcDir("src").apply { include("META-INF/**", "**/*.properties") } } "test" -> { @@ -112,7 +41,7 @@ fun SourceSet.projectDefault() { } } -// TODO: adding dep to the plugin breaks the build unexpectedly, resolve and uncomment +// TODO: adding KotlinSourceSet dep to the plugin breaks the build unexpectedly, resolve and uncomment //val SourceSet.kotlin: SourceDirectorySet // get() = // (this as HasConvention) diff --git a/compiler.tests-common/build.gradle.kts b/compiler.tests-common/build.gradle.kts index 8d60501098a..03dda408b8d 100644 --- a/compiler.tests-common/build.gradle.kts +++ b/compiler.tests-common/build.gradle.kts @@ -4,7 +4,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core")) compile(project(":core::util.runtime")) compile(project(":compiler:util")) @@ -30,6 +29,7 @@ dependencies { compile(preloadedDeps("dx", subdir = "android-5.0/lib")) } -configureKotlinProjectSources("tests-common", sourcesBaseDir = File(rootDir, "compiler")) -configureKotlinProjectNoTests() - +sourceSets { + "main" { java.srcDir("../compiler/tests-common") } + "test" {} +} diff --git a/compiler/android-tests/build.gradle.kts b/compiler/android-tests/build.gradle.kts index 20aed613fcc..e05db0e4bb1 100644 --- a/compiler/android-tests/build.gradle.kts +++ b/compiler/android-tests/build.gradle.kts @@ -1,15 +1,7 @@ -apply { - plugin("kotlin") -} +apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations - compile(project(":compiler:util")) compile(project(":compiler:cli")) compile(project(":compiler.tests-common")) @@ -28,13 +20,11 @@ dependencies { testCompile(ideaSdkDeps("jps-builders")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() - - -tasks.withType { - workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - systemProperty("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true +sourceSets { + "main" { java.srcDirs() } + "test" { projectDefault() } +} + +projectTest { + workingDir = rootDir } diff --git a/compiler/backend-common/build.gradle.kts b/compiler/backend-common/build.gradle.kts index 1edde2c3a5e..24f1ce52f76 100644 --- a/compiler/backend-common/build.gradle.kts +++ b/compiler/backend-common/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core")) compile(project(":compiler:util")) compile(project(":compiler:frontend")) @@ -10,6 +9,10 @@ dependencies { compile(project(":compiler:cli-common")) } -configureKotlinProjectSources("backend-common/src", "ir/backend.common/src", sourcesBaseDir = File(rootDir, "compiler")) -configureKotlinProjectNoTests() - +sourceSets { + "main" { + projectDefault() + java.srcDir("../ir/backend.common/src") + } + "test" {} +} diff --git a/compiler/backend/build.gradle.kts b/compiler/backend/build.gradle.kts index a70f01f307b..0c940823ec3 100644 --- a/compiler/backend/build.gradle.kts +++ b/compiler/backend/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:backend-common")) compile(project(":compiler:frontend")) @@ -12,7 +11,11 @@ dependencies { compile(project(":compiler:serialization")) } -configureKotlinProjectSources("backend/src", "ir/backend.jvm/src", sourcesBaseDir = File(rootDir, "compiler")) -configureKotlinProjectResourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { + projectDefault() + java.srcDir("../ir/backend.jvm/src") + } + "test" {} +} diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index f9102ecdbe5..a00688c1a6f 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -39,28 +39,25 @@ dependencies { buildVersion() } -configureKotlinProjectSources( - "compiler/daemon/src", - "compiler/conditional-preprocessor/src", - sourcesBaseDir = rootDir) -configureKotlinProjectResources("idea/src", sourcesBaseDir = rootDir) { - include("META-INF/extensions/common.xml", - "META-INF/extensions/kotlin2jvm.xml", - "META-INF/extensions/kotlin2js.xml") +sourceSets { + "main" { + java.srcDirs("daemon/src", + "conditional-preprocessor/src") + resources.srcDir("../idea/src").apply { + include("META-INF/extensions/common.xml", + "META-INF/extensions/kotlin2jvm.xml", + "META-INF/extensions/kotlin2js.xml") + } + } + "test" { projectDefault() } } -configureKotlinProjectTests("tests") testsJar {} -tasks.withType { +projectTest { dependsOnTaskIfExistsRec("dist", project = rootProject) dependsOn(":prepare:mock-runtime-for-test:dist") workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") systemProperty("kotlin.test.script.classpath", the().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator)) - jvmArgs("-ea", "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1200m", "-XX:+UseCodeCacheFlushing", "-XX:ReservedCodeCacheSize=128m", "-Djna.nosys=true") - maxHeapSize = "1200m" - ignoreFailures = true } diff --git a/compiler/cli/build.gradle.kts b/compiler/cli/build.gradle.kts index 56f3a1c28ae..1929bce4ae0 100644 --- a/compiler/cli/build.gradle.kts +++ b/compiler/cli/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:cli-common")) compile(project(":compiler:frontend")) @@ -22,11 +21,12 @@ dependencies { compile(files("${System.getProperty("java.home")}/../lib/tools.jar")) } -configureKotlinProjectSources("compiler/cli/src", - "plugins/annotation-collector/src", - "compiler/builtins-serializer/src", - "compiler/javac-wrapper/src", - sourcesBaseDir = rootDir) -configureKotlinProjectResourcesDefault() -configureKotlinProjectNoTests() - +sourceSets { + "main" { + projectDefault() + java.srcDirs("../../plugins/annotation-collector/src", + "../builtins-serializer/src", + "../javac-wrapper/src") + } + "test" {} +} diff --git a/compiler/cli/cli-common/build.gradle.kts b/compiler/cli/cli-common/build.gradle.kts index 93aea51b28b..e96ff4abb0d 100644 --- a/compiler/cli/cli-common/build.gradle.kts +++ b/compiler/cli/cli-common/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core:util.runtime")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) @@ -10,6 +9,8 @@ dependencies { compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array))) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/cli/cli-runner/build.gradle.kts b/compiler/cli/cli-runner/build.gradle.kts index 7e20a41b541..1250f666491 100644 --- a/compiler/cli/cli-runner/build.gradle.kts +++ b/compiler/cli/cli-runner/build.gradle.kts @@ -11,7 +11,7 @@ dependencies { sourceSets { "main" { projectDefault() } - "test" { none() } + "test" {} } runtimeJar { diff --git a/compiler/compiler-runner/build.gradle.kts b/compiler/compiler-runner/build.gradle.kts index 0b497f056e8..9e16a6c41c2 100644 --- a/compiler/compiler-runner/build.gradle.kts +++ b/compiler/compiler-runner/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-build-common")) compile(project(":compiler:cli-common")) compile(project(":kotlin-preloader")) @@ -12,6 +11,8 @@ dependencies { compile(project(":compiler:util")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/container/build.gradle.kts b/compiler/container/build.gradle.kts index d51cb79e6e2..4567ede8ddf 100644 --- a/compiler/container/build.gradle.kts +++ b/compiler/container/build.gradle.kts @@ -2,11 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations compile(project(":core:util.runtime")) compile(commonDep("javax.inject")) compile(ideaSdkCoreDeps("intellij-core")) @@ -15,17 +10,15 @@ dependencies { testRuntime(ideaSdkCoreDeps("trove4j", "intellij-core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} testsJar {} - -tasks.withType { +projectTest { dependsOnTaskIfExistsRec("dist", project = rootProject) dependsOn(":prepare:mock-runtime-for-test:dist") workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } diff --git a/compiler/daemon/daemon-client/build.gradle.kts b/compiler/daemon/daemon-client/build.gradle.kts index 33a63565f31..66000b5758a 100644 --- a/compiler/daemon/daemon-client/build.gradle.kts +++ b/compiler/daemon/daemon-client/build.gradle.kts @@ -14,7 +14,7 @@ dependencies { sourceSets { "main" { projectDefault() } - "test" { none() } + "test" {} } runtimeJar { diff --git a/compiler/daemon/daemon-common/build.gradle.kts b/compiler/daemon/daemon-common/build.gradle.kts index 9caba671fa5..81b0ed078a4 100644 --- a/compiler/daemon/daemon-common/build.gradle.kts +++ b/compiler/daemon/daemon-common/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core")) compile(project(":compiler:util")) compile(project(":compiler:cli-common")) compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array))) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/frontend.java/build.gradle.kts b/compiler/frontend.java/build.gradle.kts index 5d67f217602..58e1cab1380 100644 --- a/compiler/frontend.java/build.gradle.kts +++ b/compiler/frontend.java/build.gradle.kts @@ -2,13 +2,13 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core")) compile(project(":compiler:util")) compile(project(":compiler:frontend")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectResourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/frontend.script/build.gradle.kts b/compiler/frontend.script/build.gradle.kts index 770adfbd62c..c64c03ed333 100644 --- a/compiler/frontend.script/build.gradle.kts +++ b/compiler/frontend.script/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(project(":kotlin-reflect")) compile(preloadedDeps("kotlinx-coroutines-core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/frontend/build.gradle.kts b/compiler/frontend/build.gradle.kts index 6b6fc774eb5..22379e4a61e 100644 --- a/compiler/frontend/build.gradle.kts +++ b/compiler/frontend/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core")) compile(project(":compiler:util")) compile(project(":compiler:container")) @@ -11,6 +10,8 @@ dependencies { compile(commonDep("io.javaslang","javaslang")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/incremental-compilation-impl/build.gradle.kts b/compiler/incremental-compilation-impl/build.gradle.kts index a530996996d..96c4c35692b 100644 --- a/compiler/incremental-compilation-impl/build.gradle.kts +++ b/compiler/incremental-compilation-impl/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core")) compile(project(":compiler:util")) compile(project(":compiler:frontend")) @@ -14,7 +13,9 @@ dependencies { testCompile(projectTests(":kotlin-build-common")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} testsJar() diff --git a/compiler/ir/ir.ir2cfg/build.gradle.kts b/compiler/ir/ir.ir2cfg/build.gradle.kts index 887febe6941..80387dbfd4c 100644 --- a/compiler/ir/ir.ir2cfg/build.gradle.kts +++ b/compiler/ir/ir.ir2cfg/build.gradle.kts @@ -2,12 +2,13 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(project(":compiler:ir.tree")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/ir/ir.psi2ir/build.gradle.kts b/compiler/ir/ir.psi2ir/build.gradle.kts index d5c58caf700..abf4f19f006 100644 --- a/compiler/ir/ir.psi2ir/build.gradle.kts +++ b/compiler/ir/ir.psi2ir/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(project(":compiler:backend-common")) compile(project(":compiler:ir.tree")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/ir/ir.tree/build.gradle.kts b/compiler/ir/ir.tree/build.gradle.kts index 4666fa98542..633b86d484d 100644 --- a/compiler/ir/ir.tree/build.gradle.kts +++ b/compiler/ir/ir.tree/build.gradle.kts @@ -2,11 +2,12 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/light-classes/build.gradle.kts b/compiler/light-classes/build.gradle.kts index 471f583b48b..a62b78ae9ed 100644 --- a/compiler/light-classes/build.gradle.kts +++ b/compiler/light-classes/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:backend")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/plugin-api/build.gradle.kts b/compiler/plugin-api/build.gradle.kts index 32c07abdc4e..07bb3aa08e4 100644 --- a/compiler/plugin-api/build.gradle.kts +++ b/compiler/plugin-api/build.gradle.kts @@ -2,12 +2,13 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(ideaSdkCoreDeps("intellij-core")) compile(project(":compiler:util")) compile(project(":compiler:frontend")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/preloader/build.gradle.kts b/compiler/preloader/build.gradle.kts index 89256b2d732..5fb17afa3d3 100644 --- a/compiler/preloader/build.gradle.kts +++ b/compiler/preloader/build.gradle.kts @@ -15,7 +15,7 @@ sourceSets { srcDirs( "src", "instrumentation/src") } } - "test" { none() } + "test" {} } runtimeJar { diff --git a/compiler/resolution/build.gradle.kts b/compiler/resolution/build.gradle.kts index 571b3ba4008..fd01c671c0d 100644 --- a/compiler/resolution/build.gradle.kts +++ b/compiler/resolution/build.gradle.kts @@ -2,11 +2,12 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/serialization/build.gradle.kts b/compiler/serialization/build.gradle.kts index 571b3ba4008..fd01c671c0d 100644 --- a/compiler/serialization/build.gradle.kts +++ b/compiler/serialization/build.gradle.kts @@ -2,11 +2,12 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/tests-java8/build.gradle.kts b/compiler/tests-java8/build.gradle.kts index 3ad8e98a97d..68cd0ee39a0 100644 --- a/compiler/tests-java8/build.gradle.kts +++ b/compiler/tests-java8/build.gradle.kts @@ -3,11 +3,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations testCompile(commonDep("junit:junit")) testCompile(project(":kotlin-test:kotlin-test-jvm")) testCompile(project(":kotlin-test:kotlin-test-junit")) @@ -31,8 +26,10 @@ dependencies { testRuntime(ideaSdkDeps("*.jar")) } -configureKotlinProjectSources() -configureKotlinProjectTestsDefault() +sourceSets { + "main" {} + "test" { projectDefault() } +} tasks.withType { kotlinOptions.jdkHome = rootProject.extra["JDK_18"]!!.toString() @@ -41,16 +38,11 @@ tasks.withType { testsJar {} -tasks.withType { +projectTest { executable = "${rootProject.extra["JDK_18"]!!}/bin/java" dependsOnTaskIfExistsRec("dist", project = rootProject) dependsOn(":prepare:mock-runtime-for-test:dist") workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") systemProperty("kotlin.test.script.classpath", the().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator)) - jvmArgs("-ea", "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1200m", "-XX:+UseCodeCacheFlushing", "-XX:ReservedCodeCacheSize=128m", "-Djna.nosys=true") - maxHeapSize = "1200m" - ignoreFailures = true } diff --git a/compiler/util/build.gradle.kts b/compiler/util/build.gradle.kts index 6e7593e0e8d..f3efb33bdb6 100644 --- a/compiler/util/build.gradle.kts +++ b/compiler/util/build.gradle.kts @@ -2,13 +2,16 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core")) compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array))) compile(ideaSdkDeps("jps-model.jar", subdir = "jps")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectResources("resources", sourcesBaseDir = rootDir) -configureKotlinProjectNoTests() +sourceSets { + "main" { + projectDefault() + resources.srcDir(File(rootDir, "resources")).apply { include("**") } + } + "test" {} +} diff --git a/core/build.gradle.kts b/core/build.gradle.kts index b5987215094..1c9811c2ffa 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -12,14 +12,16 @@ dependencies { compile(commonDep("javax.inject")) } -configureKotlinProjectSources( - "descriptor.loader.java/src", - "descriptors/src", - "descriptors.runtime/src", - "deserialization/src") -configureKotlinProjectResources( - "descriptor.loader.java/src", "deserialization/src") { include("META-INF/**") } -configureKotlinProjectNoTests() +sourceSets { + "main" { + java.srcDirs("descriptor.loader.java/src", + "descriptors/src", + "descriptors.runtime/src", + "deserialization/src") + resources.srcDirs("descriptor.loader.java/src", "deserialization/src").apply { include("META-INF/**") } + } + "test" {} +} tasks.withType { dependsOn(protobufLiteTask) diff --git a/core/builtins/build.gradle.kts b/core/builtins/build.gradle.kts index a671b631a3d..e86de579b82 100644 --- a/core/builtins/build.gradle.kts +++ b/core/builtins/build.gradle.kts @@ -20,9 +20,14 @@ dependencies { compile(files(builtinsSerialized)) } -configureKotlinProjectSources("core/builtins/src", "core/runtime.jvm/src", sourcesBaseDir = rootDir) -configureKotlinProjectResources(listOf(builtinsSerialized)) -configureKotlinProjectNoTests() +sourceSets { + "main" { + projectDefault() + java.srcDir("../runtime.jvm/src") + resources.srcDir(builtinsSerialized).apply { include("**") } + } + "test" {} +} val serialize = task("serialize") { val outDir = builtinsSerialized diff --git a/core/reflection.jvm/build.gradle.kts b/core/reflection.jvm/build.gradle.kts index 2af9d7a3d1c..77ba0a23255 100644 --- a/core/reflection.jvm/build.gradle.kts +++ b/core/reflection.jvm/build.gradle.kts @@ -1,7 +1,6 @@ import org.gradle.api.tasks.compile.JavaCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.io.File buildscript { repositories { @@ -20,16 +19,6 @@ apply { plugin("com.github.johnrengelman.shadow") } -configure { - sourceSets.getByName("main")?.apply { - val srcs = listOf(File(rootDir, "core/reflection.jvm/src")) - java.setSrcDirs(srcs) - } - sourceSets.getByName("test").apply { - java.setSrcDirs(emptyList()) - } -} - dependencies { val compile by configurations compile(project(":core:builtins")) @@ -37,6 +26,11 @@ dependencies { compile(protobufLite()) } +sourceSets { + "main" { projectDefault() } + "test" {} +} + tasks.withType { dependsOn(protobufLiteTask) } @@ -44,5 +38,3 @@ tasks.withType { tasks.withType { dependsOn(protobufLiteTask) } - - diff --git a/core/script.runtime/build.gradle.kts b/core/script.runtime/build.gradle.kts index 29911d38fcf..6819454f8c3 100644 --- a/core/script.runtime/build.gradle.kts +++ b/core/script.runtime/build.gradle.kts @@ -10,8 +10,10 @@ dependencies { buildVersion() } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} tasks.withType { setupRuntimeJar("Kotlin Script Runtime") diff --git a/core/util.runtime/build.gradle.kts b/core/util.runtime/build.gradle.kts index 50bc2b44d20..4f81d77fa9c 100644 --- a/core/util.runtime/build.gradle.kts +++ b/core/util.runtime/build.gradle.kts @@ -5,11 +5,12 @@ apply { } dependencies { - val compile by configurations compile(project(":core:builtins")) compile(project(":kotlin-stdlib")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/eval4j/build.gradle.kts b/eval4j/build.gradle.kts index 99e10e4fbd1..8aa0569e7c4 100644 --- a/eval4j/build.gradle.kts +++ b/eval4j/build.gradle.kts @@ -1,8 +1,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations - val testCompile by configurations compile(project(":kotlin-stdlib")) compile(project(":kotlin-reflect")) compile(project(":compiler:backend")) @@ -13,15 +11,12 @@ dependencies { buildVersion() } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() - -tasks.withType { - dependsOnTaskIfExistsRec("dist", project = rootProject) - jvmArgs("-ea", "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1200m", "-XX:+UseCodeCacheFlushing", "-XX:ReservedCodeCacheSize=128m", "-Djna.nosys=true") - maxHeapSize = "1200m" - workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} + +projectTest { + dependsOnTaskIfExistsRec("dist", project = rootProject) + workingDir = rootDir } diff --git a/generators/build.gradle.kts b/generators/build.gradle.kts index b7ff8ad51a9..664428c9ee8 100644 --- a/generators/build.gradle.kts +++ b/generators/build.gradle.kts @@ -1,14 +1,7 @@ -apply { - plugin("kotlin") -} +apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations compile(project(":core")) compile(project(":idea")) compile(project(":j2k")) @@ -59,13 +52,11 @@ dependencies { testRuntime(ideaPluginDeps("*.jar", plugin = "android")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() - - -tasks.withType { - workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - systemProperty("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} + +projectTest { + workingDir = rootDir } diff --git a/gradle/project-schema.json b/gradle/project-schema.json index 7a521ca1fa7..113b2f66611 100644 --- a/gradle/project-schema.json +++ b/gradle/project-schema.json @@ -258,7 +258,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "compile", "compileClasspath", "compileOnly", @@ -295,7 +294,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "compile", "compileClasspath", "compileOnly", @@ -1941,7 +1939,8 @@ "testImplementation", "testRuntime", "testRuntimeClasspath", - "testRuntimeOnly" + "testRuntimeOnly", + "tests-jar" ], "extensions": { "ext": "org.gradle.api.plugins.ExtraPropertiesExtension", @@ -2679,7 +2678,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "compile", "compileClasspath", "compileOnly", @@ -2715,7 +2713,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "compile", "compileClasspath", "compileOnly", @@ -3569,7 +3566,6 @@ "configurations": [ "apiElements", "archives", - "build-version", "compile", "compileClasspath", "compileOnly", diff --git a/idea/build.gradle.kts b/idea/build.gradle.kts index 059d93a1593..97ce3110329 100644 --- a/idea/build.gradle.kts +++ b/idea/build.gradle.kts @@ -2,14 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations - - testRuntime(ideaSdkDeps("*.jar")) - compile(project(":kotlin-stdlib")) compile(project(":core")) compile(project(":compiler:backend")) @@ -64,6 +56,8 @@ dependencies { testCompileOnly(ideaSdkDeps("groovy-all", "velocity", "gson", "jsr305")) + testRuntime(ideaSdkDeps("*.jar")) + testRuntime(ideaPluginDeps("resources_en", plugin = "junit")) testRuntime(ideaPluginDeps("jcommander", "resources_en", plugin = "testng")) testRuntime(ideaPluginDeps("resources_en", plugin = "properties")) @@ -90,41 +84,27 @@ dependencies { (rootProject.extra["compilerModules"] as Array).forEach { testCompile(project(it)) } - - buildVersion() } -configureKotlinProjectSources("src", - "idea-maven/src", - "idea-gradle/src", - "idea-completion/src", - "idea-live-templates/src", - "idea-repl/src") -configure { - sourceSets["main"].apply { - resources { - srcDir(File(projectDir, "resources")) - .include("**") - srcDir(File(projectDir, "src")) - .include("META-INF/**", - "**/*.properties") - } +sourceSets { + "main" { + projectDefault() + java.srcDirs("idea-maven/src", + "idea-gradle/src", + "idea-completion/src", + "idea-live-templates/src", + "idea-repl/src") + } + "test" { + java.srcDirs("tests", + "idea-maven/test", + "idea-completion/tests") } } -configureKotlinProjectTests("tests", - "idea-maven/test", - "idea-completion/tests") -tasks.withType { +projectTest { dependsOnTaskIfExistsRec("dist", project = rootProject) - jvmArgs("-ea", "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1200m", "-XX:+UseCodeCacheFlushing", "-XX:ReservedCodeCacheSize=128m", "-Djna.nosys=true") - maxHeapSize = "1200m" workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } testsJar {} - - diff --git a/idea/formatter/build.gradle.kts b/idea/formatter/build.gradle.kts index 5f2e976dfda..00b1ab499a2 100644 --- a/idea/formatter/build.gradle.kts +++ b/idea/formatter/build.gradle.kts @@ -2,12 +2,13 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(ideaSdkDeps("openapi")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/idea/ide-common/build.gradle.kts b/idea/ide-common/build.gradle.kts index 016fb56eb2f..baebf7fb4e1 100644 --- a/idea/ide-common/build.gradle.kts +++ b/idea/ide-common/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) @@ -11,6 +10,8 @@ dependencies { compile(ideaSdkCoreDeps("annotations", "guava", "intellij-core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/idea/idea-android/build.gradle.kts b/idea/idea-android/build.gradle.kts index c9697a371f5..a740046465c 100644 --- a/idea/idea-android/build.gradle.kts +++ b/idea/idea-android/build.gradle.kts @@ -1,12 +1,7 @@ + apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations - compile(project(":kotlin-reflect")) compile(project(":compiler:util")) compile(project(":compiler:light-classes")) @@ -47,14 +42,13 @@ dependencies { testRuntime(ideaPluginDeps("*.jar", plugin = "android")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} -tasks.withType { +projectTest { workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } testsJar {} diff --git a/idea/idea-android/idea-android-output-parser/build.gradle.kts b/idea/idea-android/idea-android-output-parser/build.gradle.kts index 27686d42a87..1fade40a837 100644 --- a/idea/idea-android/idea-android-output-parser/build.gradle.kts +++ b/idea/idea-android/idea-android-output-parser/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(ideaSdkCoreDeps("intellij-core")) compile(ideaPluginDeps("gradle-tooling-api", plugin = "gradle")) compile(ideaPluginDeps("android", "android-common", "sdk-common", plugin = "android")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/idea/idea-core/build.gradle.kts b/idea/idea-core/build.gradle.kts index 5d6dd3c352b..8ee0d7ee4f3 100644 --- a/idea/idea-core/build.gradle.kts +++ b/idea/idea-core/build.gradle.kts @@ -1,7 +1,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-stdlib")) compile(project(":core")) compile(project(":compiler:frontend")) @@ -17,13 +16,13 @@ dependencies { compile(ideaSdkDeps("openapi", "idea")) compile(ideaPluginDeps("gradle-tooling-api", "gradle", plugin = "gradle")) compile(preloadedDeps("kotlinx-coroutines-core", "kotlinx-coroutines-jdk8")) - buildVersion() } -configureKotlinProjectSources("idea-core/src", "idea-analysis/src", sourcesBaseDir = File(rootDir, "idea")) -configureKotlinProjectResources("idea-analysis/src", sourcesBaseDir = File(rootDir, "idea")) { - include("**/*.properties") +sourceSets { + "main" { + projectDefault() + java.srcDir("../idea-analysis/src") + resources.srcDir("../idea-analysis/src").apply { include("**/*.properties") } + } + "test" {} } -configureKotlinProjectNoTests() - - diff --git a/idea/idea-jps-common/build.gradle.kts b/idea/idea-jps-common/build.gradle.kts index 49962609981..ab1719ae365 100644 --- a/idea/idea-jps-common/build.gradle.kts +++ b/idea/idea-jps-common/build.gradle.kts @@ -2,15 +2,15 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-stdlib")) compile(project(":compiler:util")) compile(project(":compiler:cli-common")) compile(project(":compiler:frontend.java")) compile(ideaSdkCoreDeps("intellij-core", "util")) - buildVersion() } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/idea/idea-test-framework/build.gradle.kts b/idea/idea-test-framework/build.gradle.kts index 59b702542e7..62efc257f95 100644 --- a/idea/idea-test-framework/build.gradle.kts +++ b/idea/idea-test-framework/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:frontend")) compile(project(":compiler:frontend.script")) compile(project(":compiler.tests-common")) @@ -12,7 +11,9 @@ dependencies { compile(ideaSdkDeps("openapi", "idea")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/idea/kotlin-gradle-tooling/build.gradle.kts b/idea/kotlin-gradle-tooling/build.gradle.kts index c3e4cb5b374..d8d6c556a3e 100644 --- a/idea/kotlin-gradle-tooling/build.gradle.kts +++ b/idea/kotlin-gradle-tooling/build.gradle.kts @@ -16,9 +16,10 @@ dependencies { buildVersion() } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() - +sourceSets { + "main" { projectDefault() } + "test" {} +} val jar: Jar by tasks diff --git a/j2k/build.gradle.kts b/j2k/build.gradle.kts index b2da11ece79..1f1262b08bd 100644 --- a/j2k/build.gradle.kts +++ b/j2k/build.gradle.kts @@ -6,9 +6,6 @@ apply { plugin("kotlin") } //} dependencies { - val compile by configurations - val testCompile by configurations - val testRuntime by configurations compile(project(":kotlin-stdlib")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) @@ -42,20 +39,16 @@ dependencies { // testRuntime(ideaPluginDeps("*.jar", plugin = "java-i18n")) // testRuntime(ideaPluginDeps("*.jar", plugin = "coverage")) // testRuntime(ideaPluginDeps("*.jar", plugin = "java-decompiler")) - buildVersion() } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} -tasks.withType { +projectTest { dependsOnTaskIfExistsRec("dist", project = rootProject) - jvmArgs("-ea", "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1200m", "-XX:+UseCodeCacheFlushing", "-XX:ReservedCodeCacheSize=128m", "-Djna.nosys=true") - maxHeapSize = "1200m" workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } testsJar() diff --git a/js/js.ast/build.gradle.kts b/js/js.ast/build.gradle.kts index a3522d73f87..04512bd5676 100644 --- a/js/js.ast/build.gradle.kts +++ b/js/js.ast/build.gradle.kts @@ -2,12 +2,13 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(ideaSdkCoreDeps("trove4j", "intellij-core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/js/js.dce/build.gradle.kts b/js/js.dce/build.gradle.kts index 93685ead052..ebdd7fb247e 100644 --- a/js/js.dce/build.gradle.kts +++ b/js/js.dce/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":js:js.ast")) compile(project(":js:js.translator")) compile(ideaSdkCoreDeps("intellij-core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/js/js.frontend/build.gradle.kts b/js/js.frontend/build.gradle.kts index 82aa0639612..1b0bb713edd 100644 --- a/js/js.frontend/build.gradle.kts +++ b/js/js.frontend/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(project(":js:js.ast")) @@ -11,6 +10,8 @@ dependencies { compile(ideaSdkCoreDeps("intellij-core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/js/js.parser/build.gradle.kts b/js/js.parser/build.gradle.kts index ae05bf64513..1cc9cdcaebd 100644 --- a/js/js.parser/build.gradle.kts +++ b/js/js.parser/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":js:js.ast")) compile(ideaSdkCoreDeps("intellij-core")) compile(preloadedDeps("json-org")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/js/js.serializer/build.gradle.kts b/js/js.serializer/build.gradle.kts index 638065acd2f..9549297f921 100644 --- a/js/js.serializer/build.gradle.kts +++ b/js/js.serializer/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(project(":compiler:serialization")) @@ -10,6 +9,8 @@ dependencies { compile(ideaSdkCoreDeps("intellij-core")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/js/js.tests/build.gradle.kts b/js/js.tests/build.gradle.kts index 6c72320a49d..70d19c15453 100644 --- a/js/js.tests/build.gradle.kts +++ b/js/js.tests/build.gradle.kts @@ -2,10 +2,6 @@ apply { plugin("kotlin") } dependencies { - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations - testCompile(project(":compiler.tests-common")) testCompile(project(":compiler:frontend")) testCompile(project(":compiler:cli")) @@ -19,8 +15,10 @@ dependencies { testRuntime(ideaSdkDeps("*.jar")) } -configureKotlinProjectSources() -configureKotlinProjectTestsDefault() +sourceSets { + "main" {} + "test" { projectDefault() } +} val test: Test by tasks test.apply { diff --git a/js/js.translator/build.gradle.kts b/js/js.translator/build.gradle.kts index 52adfe122e7..747c9c2b55a 100644 --- a/js/js.translator/build.gradle.kts +++ b/js/js.translator/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":core")) compile(project(":compiler:util")) compile(project(":compiler:frontend")) @@ -13,6 +12,10 @@ dependencies { compile(ideaSdkCoreDeps("intellij-core")) } -configureKotlinProjectSources("js.translator/src", "js.inliner/src", sourcesBaseDir = File(rootDir, "js")) -configureKotlinProjectNoTests() - +sourceSets { + "main" { + projectDefault() + java.srcDir("../js.inliner/src") + } + "test" {} +} diff --git a/libraries/examples/annotation-processor-example/build.gradle.kts b/libraries/examples/annotation-processor-example/build.gradle.kts index 3a9e1f290f0..0c7ce281bb4 100644 --- a/libraries/examples/annotation-processor-example/build.gradle.kts +++ b/libraries/examples/annotation-processor-example/build.gradle.kts @@ -3,10 +3,10 @@ description = "Simple Annotation Processor for testing kapt" apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-stdlib")) } -configureKotlinProjectSources("src/kotlin") -configureKotlinProjectResources("src/resources") -configureKotlinProjectNoTests() +sourceSets { + "test" {} +} + diff --git a/libraries/tools/kotlin-annotation-processing/build.gradle.kts b/libraries/tools/kotlin-annotation-processing/build.gradle.kts index 51db341ffe1..d9752a09763 100644 --- a/libraries/tools/kotlin-annotation-processing/build.gradle.kts +++ b/libraries/tools/kotlin-annotation-processing/build.gradle.kts @@ -1,44 +1,7 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations compile(project(":plugins:kapt3")) compileOnly("org.jetbrains.kotlin:gradle-api:1.6") compileOnly("com.android.tools.build:gradle:1.1.0") @@ -46,13 +9,12 @@ dependencies { testCompile(commonDep("junit:junit")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() - -tasks.withType { - workingDir = projectDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} + +projectTest { + workingDir = projectDir } diff --git a/libraries/tools/kotlin-script-util/build.gradle.kts b/libraries/tools/kotlin-script-util/build.gradle.kts index db2d33ffd60..f18e8045996 100644 --- a/libraries/tools/kotlin-script-util/build.gradle.kts +++ b/libraries/tools/kotlin-script-util/build.gradle.kts @@ -18,13 +18,7 @@ dependencies { testRuntime("org.apache.maven:maven-core:3.0.3") } -tasks.withType { - jvmArgs("-ea", "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1200m", "-XX:+UseCodeCacheFlushing", "-XX:ReservedCodeCacheSize=128m", "-Djna.nosys=true") - maxHeapSize = "1200m" - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true -} +projectTest() runtimeJar() sourcesJar() diff --git a/plugins/allopen/allopen-cli/build.gradle.kts b/plugins/allopen/allopen-cli/build.gradle.kts index b8c0d1468a7..d86d8d86f4d 100644 --- a/plugins/allopen/allopen-cli/build.gradle.kts +++ b/plugins/allopen/allopen-cli/build.gradle.kts @@ -15,7 +15,7 @@ dependencies { sourceSets { "main" { projectDefault() } - "test" { none() } + "test" {} } val jar = runtimeJar { diff --git a/plugins/allopen/allopen-ide/build.gradle.kts b/plugins/allopen/allopen-ide/build.gradle.kts index 8feea1447f8..23677c7d130 100644 --- a/plugins/allopen/allopen-ide/build.gradle.kts +++ b/plugins/allopen/allopen-ide/build.gradle.kts @@ -17,8 +17,10 @@ dependencies { } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} val jar: Jar by tasks diff --git a/plugins/android-extensions/android-extensions-compiler/build.gradle.kts b/plugins/android-extensions/android-extensions-compiler/build.gradle.kts index 03bbffc04b6..b476f8a201a 100644 --- a/plugins/android-extensions/android-extensions-compiler/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-compiler/build.gradle.kts @@ -4,7 +4,6 @@ description = "Kotlin Android Extensions Compiler" apply { plugin("kotlin") } dependencies { - val compile by configurations compile(ideaSdkCoreDeps("intellij-core")) compile(project(":compiler:util")) compile(project(":compiler:plugin-api")) @@ -14,16 +13,12 @@ dependencies { compile(ideaPluginDeps("layoutlib", plugin = "android")) } -configureKotlinProjectSources("android-extensions-compiler/src", "android-extensions-runtime/src", sourcesBaseDir = File(rootDir, "plugins", "android-extensions")) -configureKotlinProjectResourcesDefault(sourcesBaseDir = File(rootDir, "plugins", "android-extensions", "android-extensions-compiler", "src")) -configureKotlinProjectNoTests() - sourceSets { "main" { projectDefault() java.srcDir("../android-extensions-runtime/src") } - "test" { none() } + "test" {} } runtimeJar () diff --git a/plugins/android-extensions/android-extensions-idea/build.gradle.kts b/plugins/android-extensions/android-extensions-idea/build.gradle.kts index 3166080cc70..b2de849fe55 100644 --- a/plugins/android-extensions/android-extensions-idea/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-idea/build.gradle.kts @@ -43,17 +43,15 @@ dependencies { testRuntime(ideaPluginDeps("*.jar", plugin = "android")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} testsJar {} - -tasks.withType { +projectTest { workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } val jar: Jar by tasks diff --git a/plugins/android-extensions/android-extensions-jps/build.gradle.kts b/plugins/android-extensions/android-extensions-jps/build.gradle.kts index 45acaa2554e..a12d61cc430 100644 --- a/plugins/android-extensions/android-extensions-jps/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-jps/build.gradle.kts @@ -2,13 +2,14 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":compiler:util")) compile(project(":jps-plugin")) compile(project(":android-extensions-compiler")) compile(ideaPluginDeps("android-jps-plugin", plugin = "android", subdir = "lib/jps")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/plugins/annotation-based-compiler-plugins-ide-support/build.gradle.kts b/plugins/annotation-based-compiler-plugins-ide-support/build.gradle.kts index 9c359a4661d..450c1de7c5f 100644 --- a/plugins/annotation-based-compiler-plugins-ide-support/build.gradle.kts +++ b/plugins/annotation-based-compiler-plugins-ide-support/build.gradle.kts @@ -2,11 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations compile(project(":compiler:util")) compile(project(":compiler:frontend")) compile(project(":compiler:cli-common")) @@ -17,6 +12,8 @@ dependencies { compileOnly(ideaSdkDeps("openapi", "idea")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/plugins/kapt3/build.gradle.kts b/plugins/kapt3/build.gradle.kts index 9e7d96ebe49..2342fee2429 100644 --- a/plugins/kapt3/build.gradle.kts +++ b/plugins/kapt3/build.gradle.kts @@ -2,11 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations compile(project(":compiler:util")) compile(project(":compiler:cli")) compile(project(":compiler:backend")) @@ -17,15 +12,14 @@ dependencies { testCompile(commonDep("junit:junit")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} testsJar {} -tasks.withType { +projectTest { workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } diff --git a/plugins/lint/build.gradle.kts b/plugins/lint/build.gradle.kts index 5e1298b9b01..9b8c6aa965e 100644 --- a/plugins/lint/build.gradle.kts +++ b/plugins/lint/build.gradle.kts @@ -5,7 +5,6 @@ apply { } dependencies { - val compile by configurations compile(project(":compiler:frontend")) compile(project(":idea")) compile(project(":idea:idea-core")) @@ -16,9 +15,13 @@ dependencies { compile(ideaSdkDeps("guava")) } -configureKotlinProjectSources("android-annotations/src", - "lint-api/src", - "lint-checks/src", - "lint-idea/src") -configureKotlinProjectNoTests() +sourceSets { + "main" { + java.srcDirs("android-annotations/src", + "lint-api/src", + "lint-checks/src", + "lint-idea/src") + } + "test" {} +} diff --git a/plugins/noarg/noarg-cli/build.gradle.kts b/plugins/noarg/noarg-cli/build.gradle.kts index ffcdbc4bf8e..aed5d1df32a 100644 --- a/plugins/noarg/noarg-cli/build.gradle.kts +++ b/plugins/noarg/noarg-cli/build.gradle.kts @@ -4,8 +4,6 @@ description = "Kotlin NoArg Compiler Plugin" apply { plugin("kotlin") } dependencies { - val compileOnly by configurations - val runtime by configurations compileOnly(project(":compiler:frontend")) compileOnly(project(":compiler:frontend.java")) compileOnly(project(":compiler:backend")) @@ -15,8 +13,10 @@ dependencies { runtime(project(":kotlin-stdlib")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} val jar = runtimeJar { from(fileTree("$projectDir/src")) { include("META-INF/**") } diff --git a/plugins/noarg/noarg-ide/build.gradle.kts b/plugins/noarg/noarg-ide/build.gradle.kts index 9c0ad526cd7..341ee5a2f73 100644 --- a/plugins/noarg/noarg-ide/build.gradle.kts +++ b/plugins/noarg/noarg-ide/build.gradle.kts @@ -20,9 +20,10 @@ dependencies { } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() - +sourceSets { + "main" { projectDefault() } + "test" {} +} val jar: Jar by tasks diff --git a/plugins/plugins-tests/build.gradle.kts b/plugins/plugins-tests/build.gradle.kts index 10fe33a30df..a93463e216a 100644 --- a/plugins/plugins-tests/build.gradle.kts +++ b/plugins/plugins-tests/build.gradle.kts @@ -2,11 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations testCompile(project(":compiler:util")) testCompile(project(":compiler:backend")) testCompile(project(":compiler:cli")) @@ -35,8 +30,10 @@ dependencies { testRuntime(ideaPluginDeps("*.jar", plugin = "android")) } -configureKotlinProjectSources() -configureKotlinProjectTestsDefault() +sourceSets { + "main" {} + "test" { projectDefault() } +} testsJar {} diff --git a/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts b/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts index aa115c04016..c8f1180d7c7 100644 --- a/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts +++ b/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts @@ -15,7 +15,7 @@ dependencies { sourceSets { "main" { projectDefault() } - "test" { none() } + "test" {} } val jar = runtimeJar { diff --git a/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts b/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts index cc0194521e2..a2eb034c6fb 100644 --- a/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts +++ b/plugins/sam-with-receiver/sam-with-receiver-ide/build.gradle.kts @@ -14,8 +14,10 @@ dependencies { compile(project(":idea")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} val jar: Jar by tasks diff --git a/plugins/uast-kotlin-idea/build.gradle.kts b/plugins/uast-kotlin-idea/build.gradle.kts index 0d7575775e8..67d6dfe63a5 100644 --- a/plugins/uast-kotlin-idea/build.gradle.kts +++ b/plugins/uast-kotlin-idea/build.gradle.kts @@ -2,7 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations compile(project(":kotlin-stdlib")) compile(project(":core:util.runtime")) compile(project(":compiler:backend")) @@ -12,6 +11,8 @@ dependencies { buildVersion() } -configureKotlinProjectSourcesDefault() -configureKotlinProjectNoTests() +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/plugins/uast-kotlin/build.gradle.kts b/plugins/uast-kotlin/build.gradle.kts index 51657198558..97e478a232d 100644 --- a/plugins/uast-kotlin/build.gradle.kts +++ b/plugins/uast-kotlin/build.gradle.kts @@ -2,11 +2,6 @@ apply { plugin("kotlin") } dependencies { - val compile by configurations - val compileOnly by configurations - val testCompile by configurations - val testCompileOnly by configurations - val testRuntime by configurations compile(project(":kotlin-stdlib")) compile(project(":core:util.runtime")) compile(project(":compiler:backend")) @@ -14,7 +9,6 @@ dependencies { compile(project(":compiler:frontend.java")) compile(project(":compiler:light-classes")) compileOnly(ideaSdkDeps("openapi", "idea")) - buildVersion() testCompile(project(":kotlin-test:kotlin-test-jvm")) testCompile(project(":compiler.tests-common")) testCompile(commonDep("junit:junit")) @@ -25,15 +19,13 @@ dependencies { testRuntime(ideaSdkDeps("*.jar")) } -configureKotlinProjectSourcesDefault() -configureKotlinProjectTestsDefault() +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} testsJar {} - -tasks.withType { +projectTest { workingDir = rootDir - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") - ignoreFailures = true } diff --git a/prepare/android-lint/build.gradle.kts b/prepare/android-lint/build.gradle.kts index f637e328cfe..732e7cfbd9b 100644 --- a/prepare/android-lint/build.gradle.kts +++ b/prepare/android-lint/build.gradle.kts @@ -21,8 +21,10 @@ tasks.withType { } } -configureKotlinProjectSources() // no sources -configureKotlinProjectNoTests() +sourceSets { + "main" {} + "test" {} +} val jar: Jar by tasks diff --git a/prepare/compiler-client-embeddable/build.gradle.kts b/prepare/compiler-client-embeddable/build.gradle.kts index 06e89e3e5b5..bcb8adf3ac0 100644 --- a/prepare/compiler-client-embeddable/build.gradle.kts +++ b/prepare/compiler-client-embeddable/build.gradle.kts @@ -43,19 +43,18 @@ dependencies { testScriptRuntimeJar(project(":kotlin-script-runtime", configuration = "mainJar")) } -configureKotlinProjectSources() // no sources -configureKotlinProjectTests("libraries/tools/kotlin-compiler-client-embeddable-test/src", sourcesBaseDir = rootDir) +sourceSets { + "main" {} + "test" { + // TODO: move closer + java.srcDir("../../libraries/tools/kotlin-compiler-client-embeddable-test/src") + } +} -tasks.withType { +projectTest { dependsOnTaskIfExistsRec("dist", project = rootProject) workingDir = File(rootDir, "libraries/tools/kotlin-compiler-client-embeddable-test/src") - systemProperty("idea.is.unit.test", "true") - environment("NO_FS_ROOTS_ACCESS_CHECK", "true") systemProperty("kotlin.test.script.classpath", the().sourceSets.getByName("test").output.classesDirs.joinToString(File.pathSeparator)) - jvmArgs("-ea", "-XX:+HeapDumpOnOutOfMemoryError", "-Xmx1200m", "-XX:+UseCodeCacheFlushing", "-XX:ReservedCodeCacheSize=128m", "-Djna.nosys=true") - maxHeapSize = "1200m" - ignoreFailures = true - systemProperty("idea.is.unit.test", "true") systemProperty("compilerJar", testRuntimeCompilerJar.singleFile.canonicalPath) systemProperty("stdlibJar", testStdlibJar.singleFile.canonicalPath) systemProperty("scriptRuntimeJar", testScriptRuntimeJar.singleFile.canonicalPath) @@ -76,73 +75,3 @@ sourcesJar() javadocJar() publish() - -// TODO: remove after finalizing publishing (now due to the problems with sam-with-receiver, the code is not fully navigable in the buildSrc) -//tasks { -// "uploadArchives"(Upload::class) { -// -// val preparePublication by rootProject.tasks -// dependsOn(preparePublication) -// -// val username: String? by preparePublication.extra -// val password: String? by preparePublication.extra -// -// repositories { -// withConvention(MavenRepositoryHandlerConvention::class) { -// -// mavenDeployer { -// withGroovyBuilder { -// "repository"("url" to uri(preparePublication.extra["repoUrl"])) -// -// if (username != null && password != null) { -// "authentication"("userName" to username, "password" to password) -// } -// } -// -// pom.project { -// withGroovyBuilder { -// "licenses" { -// "license" { -// "name"("The Apache Software License, Version 2.0") -// "url"("http://www.apache.org/licenses/LICENSE-2.0.txt") -// "distribution"("repo") -// } -// } -// "name"("${project.group}:${project.name}") -// "packaging"("jar") -// // optionally artifactId can be defined here -// "description"(project.description) -// "url"("https://kotlinlang.org/") -// "licenses" { -// "license" { -// "name"("The Apache License, Version 2.0") -// "url"("http://www.apache.org/licenses/LICENSE-2.0.txt") -// } -// } -// "scm" { -// "url"("https://github.com/JetBrains/kotlin") -// "connection"("scm:git:https://github.com/JetBrains/kotlin.git") -// "developerConnection"("scm:git:https://github.com/JetBrains/kotlin.git") -// } -// "developers" { -// "developer" { -// "name"("Kotlin Team") -// "organization"("JetBrains") -// "organizationUrl"("https://www.jetbrains.com") -// } -// } -// } -// } -// pom.whenConfigured { -// dependencies.clear() -//// dependencies.removeIf { -//// withGroovyBuilder { -//// "scope"(*emptyArray()) == "test" -//// } -//// } -// } -// } -// } -// } -// } -//} diff --git a/prepare/formatter/build.gradle.kts b/prepare/formatter/build.gradle.kts index 6e7c5e84fe1..709d08c9b80 100644 --- a/prepare/formatter/build.gradle.kts +++ b/prepare/formatter/build.gradle.kts @@ -15,6 +15,8 @@ tasks.withType { from(fileTree("$rootDir/idea/formatter")) { include("src/**") } // Eclipse formatter sources navigation depends on this } -configureKotlinProjectSources() // no sources -configureKotlinProjectNoTests() +sourceSets { + "main" {} + "test" {} +} diff --git a/prepare/ide-lazy-resolver/build.gradle.kts b/prepare/ide-lazy-resolver/build.gradle.kts index 9461ce74a05..d4dd3c397ef 100644 --- a/prepare/ide-lazy-resolver/build.gradle.kts +++ b/prepare/ide-lazy-resolver/build.gradle.kts @@ -15,6 +15,8 @@ tasks.withType { from(fileTree("$rootDir/idea/ide-common")) { include("src/**") } // Eclipse formatter sources navigation depends on this } -configureKotlinProjectSources() // no sources -configureKotlinProjectNoTests() +sourceSets { + "main" {} + "test" {} +} diff --git a/prepare/mock-runtime-for-test/build.gradle.kts b/prepare/mock-runtime-for-test/build.gradle.kts index 632ae42efae..f9e7f81494b 100644 --- a/prepare/mock-runtime-for-test/build.gradle.kts +++ b/prepare/mock-runtime-for-test/build.gradle.kts @@ -18,22 +18,22 @@ jar.apply { archiveName = "kotlin-mock-runtime-for-test.jar" } -configure { - sourceSets["main"].apply { - (this as HasConvention).convention.getPlugin().kotlin.apply { - srcDir(File(rootDir, "core", "runtime.jvm", "src")) - .include("kotlin/TypeAliases.kt", - "kotlin/text/TypeAliases.kt") - srcDir(File(rootDir, "libraries", "stdlib", "src")) - .include("kotlin/collections/TypeAliases.kt", - "kotlin/jvm/JvmVersion.kt", - "kotlin/util/Standard.kt", - "kotlin/internal/Annotations.kt") - } - } +sourceSets { + "main" { + java.apply { + srcDir(File(rootDir, "core", "runtime.jvm", "src")) + .include("kotlin/TypeAliases.kt", + "kotlin/text/TypeAliases.kt") + srcDir(File(rootDir, "libraries", "stdlib", "src")) + .include("kotlin/collections/TypeAliases.kt", + "kotlin/jvm/JvmVersion.kt", + "kotlin/util/Standard.kt", + "kotlin/internal/Annotations.kt") + } + } + "test" {} } -configureKotlinProjectNoTests() tasks.withType { sourceCompatibility = "1.6"