generators: extract OperationsMap generator to a separate source set

Refactor generators so that OperationsMapGenerator is in its own
source set with minimal dependencies.
This commit is contained in:
Ilya Gorbunov
2020-01-18 07:14:50 +03:00
parent 2251c27167
commit 7ec04a1bf9
4 changed files with 53 additions and 44 deletions
+49 -29
View File
@@ -4,45 +4,64 @@ plugins {
} }
sourceSets { sourceSets {
"main" { } "main" { java.srcDirs("main") }
"test" { projectDefault() } "test" { projectDefault() }
} }
val builtinsSourceSet = sourceSets.create("builtins") { fun extraSourceSet(name: String, extendMain: Boolean = true): Pair<SourceSet, Configuration> {
java.srcDir("builtins") val sourceSet = sourceSets.create(name) {
java.srcDir(name)
}
val api = configurations[sourceSet.apiConfigurationName]
if (extendMain) {
dependencies { api(mainSourceSet.output) }
configurations[sourceSet.runtimeOnlyConfigurationName]
.extendsFrom(configurations.runtimeClasspath.get())
}
return sourceSet to api
} }
val builtinsCompile by configurations
val (builtinsSourceSet, builtinsApi) = extraSourceSet("builtins", extendMain = false)
val (evaluateSourceSet, evaluateApi) = extraSourceSet("evaluate")
dependencies { dependencies {
compile(projectTests(":compiler:cli")) // for GeneratorsFileUtil
compile(projectTests(":idea:idea-maven")) api(kotlinStdlib())
compile(projectTests(":j2k")) api(intellijDep()) { includeJars("util") }
compile(projectTests(":nj2k"))
compile(projectTests(":libraries:tools:new-project-wizard:new-project-wizard-cli")) builtinsApi("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion") { isTransitive = false }
compile(projectTests(":idea:idea-android")) evaluateApi(project(":core:deserialization"))
compile(projectTests(":idea:scripting-support"))
compile(projectTests(":jps-plugin")) testImplementation(builtinsSourceSet.output)
compile(projectTests(":plugins:jvm-abi-gen")) testImplementation(evaluateSourceSet.output)
compile(projectTests(":plugins:android-extensions-compiler"))
compile(projectTests(":plugins:android-extensions-ide")) testImplementation(projectTests(":compiler:cli"))
compile(projectTests(":kotlin-annotation-processing")) testImplementation(projectTests(":idea:idea-maven"))
compile(projectTests(":kotlin-annotation-processing-cli")) testImplementation(projectTests(":j2k"))
compile(projectTests(":kotlin-allopen-compiler-plugin")) testImplementation(projectTests(":nj2k"))
compile(projectTests(":kotlin-noarg-compiler-plugin")) testImplementation(projectTests(":libraries:tools:new-project-wizard:new-project-wizard-cli"))
compile(projectTests(":kotlin-sam-with-receiver-compiler-plugin")) testImplementation(projectTests(":idea:idea-android"))
compile(projectTests(":kotlinx-serialization-compiler-plugin")) testImplementation(projectTests(":idea:scripting-support"))
compile(projectTests(":idea:jvm-debugger:jvm-debugger-test")) testImplementation(projectTests(":jps-plugin"))
compile(projectTests(":generators:test-generator")) testImplementation(projectTests(":plugins:jvm-abi-gen"))
compile(projectTests(":idea")) testImplementation(projectTests(":plugins:android-extensions-compiler"))
builtinsCompile("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion") testImplementation(projectTests(":plugins:android-extensions-ide"))
testImplementation(projectTests(":kotlin-annotation-processing"))
testImplementation(projectTests(":kotlin-annotation-processing-cli"))
testImplementation(projectTests(":kotlin-allopen-compiler-plugin"))
testImplementation(projectTests(":kotlin-noarg-compiler-plugin"))
testImplementation(projectTests(":kotlin-sam-with-receiver-compiler-plugin"))
testImplementation(projectTests(":kotlinx-serialization-compiler-plugin"))
testImplementation(projectTests(":idea:jvm-debugger:jvm-debugger-test"))
testImplementation(projectTests(":generators:test-generator"))
testImplementation(projectTests(":idea"))
testCompileOnly(project(":kotlin-reflect-api")) testCompileOnly(project(":kotlin-reflect-api"))
testCompile(builtinsSourceSet.output) testRuntimeOnly(intellijDep()) { includeJars("idea_rt") }
testRuntime(intellijDep()) { includeJars("idea_rt") } testRuntimeOnly(project(":kotlin-reflect"))
testRuntime(project(":kotlin-reflect"))
if (Ide.IJ()) { if (Ide.IJ()) {
testCompileOnly(jpsBuildTest()) testCompileOnly(jpsBuildTest())
testCompile(jpsBuildTest()) testImplementation(jpsBuildTest())
} }
} }
@@ -59,5 +78,6 @@ val generateProtoBufCompare by generator("org.jetbrains.kotlin.generators.protob
val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt") val generateGradleOptions by generator("org.jetbrains.kotlin.generators.arguments.GenerateGradleOptionsKt")
val generateBuiltins by generator("org.jetbrains.kotlin.generators.builtins.generateBuiltIns.GenerateBuiltInsKt", builtinsSourceSet) val generateBuiltins by generator("org.jetbrains.kotlin.generators.builtins.generateBuiltIns.GenerateBuiltInsKt", builtinsSourceSet)
val generateOperationsMap by generator("org.jetbrains.kotlin.generators.evaluate.GenerateOperationsMapKt", evaluateSourceSet)
testsJar() testsJar()
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2016 JetBrains s.r.o. * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
* 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.
*/ */
package org.jetbrains.kotlin.generators.evaluate package org.jetbrains.kotlin.generators.evaluate
@@ -6,7 +6,6 @@ package org.jetbrains.kotlin.generators.util
import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.test.KotlinTestUtils
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
import java.nio.file.Files import java.nio.file.Files
@@ -33,7 +32,7 @@ object GeneratorsFileUtil {
} }
val useTempFile = !SystemInfo.isWindows val useTempFile = !SystemInfo.isWindows
val tempFile = val tempFile =
if (useTempFile) File(KotlinTestUtils.tmpDir(file.name), file.name + ".tmp") else file if (useTempFile) File(createTempDir(file.name), file.name + ".tmp") else file
tempFile.writeText(newText, Charsets.UTF_8) tempFile.writeText(newText, Charsets.UTF_8)
println("File written: " + tempFile.absolutePath) println("File written: " + tempFile.absolutePath)
if (useTempFile) { if (useTempFile) {
@@ -10,6 +10,7 @@ dependencies {
testCompile(projectTests(":compiler:tests-common")) testCompile(projectTests(":compiler:tests-common"))
testCompile(kotlinStdlib()) testCompile(kotlinStdlib())
testCompile(commonDep("junit:junit")) testCompile(commonDep("junit:junit"))
testCompile(project(":generators"))
} }
sourceSets { sourceSets {