make jps-plugin testable from IJ infrastructure
^KTIJ-20456
This commit is contained in:
@@ -285,6 +285,7 @@ extra["compilerArtifactsForIde"] = listOf(
|
|||||||
":prepare:ide-plugin-dependencies:kotlin-gradle-statistics-for-ide",
|
":prepare:ide-plugin-dependencies:kotlin-gradle-statistics-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:kotlin-jps-common-for-ide",
|
":prepare:ide-plugin-dependencies:kotlin-jps-common-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:kotlin-jps-plugin-classpath",
|
":prepare:ide-plugin-dependencies:kotlin-jps-plugin-classpath",
|
||||||
|
":prepare:ide-plugin-dependencies:kotlin-jps-plugin-tests-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:kotlinx-serialization-compiler-plugin-for-ide",
|
":prepare:ide-plugin-dependencies:kotlinx-serialization-compiler-plugin-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:noarg-compiler-plugin-for-ide",
|
":prepare:ide-plugin-dependencies:noarg-compiler-plugin-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide",
|
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2022 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.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -16,6 +16,8 @@ import org.jetbrains.kotlin.preloading.ClassPreloadingUtils
|
|||||||
import org.jetbrains.kotlin.preloading.Preloader
|
import org.jetbrains.kotlin.preloading.Preloader
|
||||||
import org.jetbrains.kotlin.test.KtAssert.assertTrue
|
import org.jetbrains.kotlin.test.KtAssert.assertTrue
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||||
|
import org.jetbrains.kotlin.utils.KotlinPaths
|
||||||
|
import org.jetbrains.kotlin.utils.KotlinPathsFromHomeDir
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -26,6 +28,9 @@ import java.util.regex.Pattern
|
|||||||
import java.util.zip.ZipOutputStream
|
import java.util.zip.ZipOutputStream
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
val PathUtil.kotlinPathsForDistDirectoryForTests: KotlinPaths
|
||||||
|
get() = System.getProperty("jps.kotlin.home")?.let(::File)?.let(::KotlinPathsFromHomeDir) ?: kotlinPathsForDistDirectory
|
||||||
|
|
||||||
object MockLibraryUtil {
|
object MockLibraryUtil {
|
||||||
private var compilerClassLoader = SoftReference<ClassLoader>(null)
|
private var compilerClassLoader = SoftReference<ClassLoader>(null)
|
||||||
|
|
||||||
@@ -230,7 +235,7 @@ object MockLibraryUtil {
|
|||||||
@Synchronized
|
@Synchronized
|
||||||
private fun createCompilerClassLoader(): ClassLoader {
|
private fun createCompilerClassLoader(): ClassLoader {
|
||||||
return ClassPreloadingUtils.preloadClasses(
|
return ClassPreloadingUtils.preloadClasses(
|
||||||
listOf(PathUtil.kotlinPathsForDistDirectory.compilerPath),
|
listOf(PathUtil.kotlinPathsForDistDirectoryForTests.compilerPath),
|
||||||
Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null
|
Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-14
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2022 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.jps.build
|
package org.jetbrains.kotlin.jps.build
|
||||||
@@ -66,6 +55,7 @@ import org.jetbrains.kotlin.platform.idePlatformKind
|
|||||||
import org.jetbrains.kotlin.platform.impl.isJavaScript
|
import org.jetbrains.kotlin.platform.impl.isJavaScript
|
||||||
import org.jetbrains.kotlin.platform.impl.isJvm
|
import org.jetbrains.kotlin.platform.impl.isJvm
|
||||||
import org.jetbrains.kotlin.platform.orDefault
|
import org.jetbrains.kotlin.platform.orDefault
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
@@ -325,11 +315,15 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected open fun doTest(testDataPath: String) {
|
protected open fun doTest(testDataPath: String) {
|
||||||
|
KotlinTestUtils.runTest(this::executeTest, this, testDataPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun executeTest(testDataPath: String) {
|
||||||
testDataDir = File(testDataPath)
|
testDataDir = File(testDataPath)
|
||||||
workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "aijt-jps-build", null)
|
workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "aijt-jps-build", null)
|
||||||
additionalCommandLineArguments = parseAdditionalArgs(File(testDataPath))
|
additionalCommandLineArguments = parseAdditionalArgs(File(testDataPath))
|
||||||
val buildLogFile = buildLogFinder.findBuildLog(testDataDir)
|
val buildLogFile = buildLogFinder.findBuildLog(testDataDir)
|
||||||
Disposer.register(testRootDisposable, Disposable { FileUtilRt.delete(workDir) })
|
Disposer.register(testRootDisposable) { FileUtilRt.delete(workDir) }
|
||||||
|
|
||||||
val modulesTxt = configureModules()
|
val modulesTxt = configureModules()
|
||||||
if (modulesTxt?.muted == true) return
|
if (modulesTxt?.muted == true) return
|
||||||
|
|||||||
+3
-15
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2022 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.jps.build
|
package org.jetbrains.kotlin.jps.build
|
||||||
@@ -23,7 +12,6 @@ import org.jetbrains.jps.model.java.JpsJavaLibraryType
|
|||||||
import org.jetbrains.jps.model.library.JpsLibrary
|
import org.jetbrains.jps.model.library.JpsLibrary
|
||||||
import org.jetbrains.jps.model.library.JpsOrderRootType
|
import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||||
import org.jetbrains.jps.model.module.JpsModule
|
import org.jetbrains.jps.model.module.JpsModule
|
||||||
import org.jetbrains.jps.util.JpsPathUtil
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@@ -60,7 +48,7 @@ abstract class AbstractKotlinJpsBuildTestCase : BaseKotlinJpsBuildTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TEST_DATA_PATH = "jps/jps-plugin/testData/"
|
val TEST_DATA_PATH get() = System.getProperty("pass.jps.testData.home") ?: "jps/jps-plugin/testData/"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
protected fun addKotlinStdlibDependency(modules: Collection<JpsModule>, exported: Boolean = false): JpsLibrary {
|
protected fun addKotlinStdlibDependency(modules: Collection<JpsModule>, exported: Boolean = false): JpsLibrary {
|
||||||
|
|||||||
+4
-14
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2022 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.jps.build
|
package org.jetbrains.kotlin.jps.build
|
||||||
@@ -44,6 +33,7 @@ import org.jetbrains.kotlin.jps.build.fixtures.EnableICFixture
|
|||||||
import org.jetbrains.kotlin.jps.incremental.createTestingCompilerEnvironment
|
import org.jetbrains.kotlin.jps.incremental.createTestingCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.jps.incremental.runJSCompiler
|
import org.jetbrains.kotlin.jps.incremental.runJSCompiler
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
|
import org.jetbrains.kotlin.test.kotlinPathsForDistDirectoryForTests
|
||||||
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import java.io.*
|
import java.io.*
|
||||||
@@ -167,7 +157,7 @@ abstract class AbstractJsLookupTrackerTest : AbstractLookupTrackerTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected open val jsStdlibFile: File
|
protected open val jsStdlibFile: File
|
||||||
get() = PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath
|
get() = PathUtil.kotlinPathsForDistDirectoryForTests.jsStdLibJarPath
|
||||||
|
|
||||||
protected open fun configureAdditionalArgs(args: K2JSCompilerArguments) {
|
protected open fun configureAdditionalArgs(args: K2JSCompilerArguments) {
|
||||||
args.outputFile = File(outDir, "out.js").canonicalPath
|
args.outputFile = File(outDir, "out.js").canonicalPath
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2022 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.jps.build
|
package org.jetbrains.kotlin.jps.build
|
||||||
@@ -66,6 +55,7 @@ import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.test.MockLibraryUtilExt
|
import org.jetbrains.kotlin.test.MockLibraryUtilExt
|
||||||
|
import org.jetbrains.kotlin.test.kotlinPathsForDistDirectoryForTests
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
@@ -243,7 +233,7 @@ open class KotlinJpsBuildTest : KotlinJpsBuildTestBase() {
|
|||||||
fun testKotlinJavaScriptProjectWithDirectoryAsStdlib() {
|
fun testKotlinJavaScriptProjectWithDirectoryAsStdlib() {
|
||||||
initProject()
|
initProject()
|
||||||
setupKotlinJSFacet()
|
setupKotlinJSFacet()
|
||||||
val jslibJar = PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath
|
val jslibJar = PathUtil.kotlinPathsForDistDirectoryForTests.jsStdLibJarPath
|
||||||
val jslibDir = File(workDir, "KotlinJavaScript")
|
val jslibDir = File(workDir, "KotlinJavaScript")
|
||||||
try {
|
try {
|
||||||
Decompressor.Zip(jslibJar).extract(jslibDir)
|
Decompressor.Zip(jslibJar).extract(jslibDir)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2022 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.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -9,40 +9,56 @@ import org.jetbrains.jps.model.JpsProject
|
|||||||
import org.jetbrains.jps.model.java.JpsJavaLibraryType
|
import org.jetbrains.jps.model.java.JpsJavaLibraryType
|
||||||
import org.jetbrains.jps.model.library.JpsLibrary
|
import org.jetbrains.jps.model.library.JpsLibrary
|
||||||
import org.jetbrains.jps.model.library.JpsOrderRootType
|
import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||||
|
import org.jetbrains.kotlin.test.kotlinPathsForDistDirectoryForTests
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
enum class KotlinJpsLibrary(val id: String, vararg val roots: File) {
|
enum class KotlinJpsLibrary(val id: String, roots: () -> Array<File>) {
|
||||||
MockRuntime(
|
MockRuntime(
|
||||||
"kotlin-mock-runtime",
|
"kotlin-mock-runtime",
|
||||||
PathUtil.kotlinPathsForDistDirectory.stdlibPath,
|
{
|
||||||
File(PathUtil.kotlinPathsForDistDirectory.libPath, "annotations-13.0.jar")
|
arrayOf(
|
||||||
|
PathUtil.kotlinPathsForDistDirectoryForTests.stdlibPath,
|
||||||
|
File(PathUtil.kotlinPathsForDistDirectoryForTests.libPath, "annotations-13.0.jar"),
|
||||||
|
)
|
||||||
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
JvmStdLib(
|
JvmStdLib(
|
||||||
"kotlin-stdlib",
|
"kotlin-stdlib",
|
||||||
PathUtil.kotlinPathsForDistDirectory.stdlibPath,
|
{
|
||||||
File(PathUtil.kotlinPathsForDistDirectory.libPath, "annotations-13.0.jar")
|
arrayOf(
|
||||||
|
PathUtil.kotlinPathsForDistDirectoryForTests.stdlibPath,
|
||||||
|
File(PathUtil.kotlinPathsForDistDirectoryForTests.libPath, "annotations-13.0.jar"),
|
||||||
|
)
|
||||||
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
JvmTest(
|
JvmTest(
|
||||||
"kotlin-test",
|
"kotlin-test",
|
||||||
PathUtil.kotlinPathsForDistDirectory.kotlinTestPath
|
{ arrayOf(PathUtil.kotlinPathsForDistDirectoryForTests.kotlinTestPath) },
|
||||||
),
|
),
|
||||||
|
|
||||||
JsStdLib(
|
JsStdLib(
|
||||||
"KotlinJavaScript",
|
"KotlinJavaScript",
|
||||||
PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath
|
{ arrayOf(PathUtil.kotlinPathsForDistDirectoryForTests.jsStdLibJarPath) }
|
||||||
),
|
),
|
||||||
JsTest(
|
JsTest(
|
||||||
"KotlinJavaScriptTest",
|
"KotlinJavaScriptTest",
|
||||||
PathUtil.kotlinPathsForDistDirectory.jsKotlinTestJarPath
|
{ arrayOf(PathUtil.kotlinPathsForDistDirectoryForTests.jsKotlinTestJarPath) }
|
||||||
),
|
),
|
||||||
Lombok(
|
Lombok(
|
||||||
"lombok",
|
"lombok",
|
||||||
PathUtil.kotlinPathsForDistDirectory.stdlibPath,
|
{
|
||||||
File(lombok.Lombok::class.java.protectionDomain.codeSource.location.toURI().path)
|
arrayOf(
|
||||||
|
PathUtil.kotlinPathsForDistDirectoryForTests.stdlibPath,
|
||||||
|
File(lombok.Lombok::class.java.protectionDomain.codeSource.location.toURI().path),
|
||||||
|
)
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
val roots: Array<File> by lazy(roots)
|
||||||
|
|
||||||
fun create(project: JpsProject): JpsLibrary {
|
fun create(project: JpsProject): JpsLibrary {
|
||||||
val library = project.addLibrary(id, JpsJavaLibraryType.INSTANCE)
|
val library = project.addLibrary(id, JpsJavaLibraryType.INSTANCE)
|
||||||
|
|
||||||
|
|||||||
+8
-16
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 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.jps.incremental
|
package org.jetbrains.kotlin.jps.incremental
|
||||||
@@ -23,16 +12,19 @@ import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
|||||||
import org.jetbrains.kotlin.compilerRunner.*
|
import org.jetbrains.kotlin.compilerRunner.*
|
||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
import org.jetbrains.kotlin.jps.build.KotlinBuilder
|
||||||
|
import org.jetbrains.kotlin.test.kotlinPathsForDistDirectoryForTests
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import java.io.*
|
import java.io.BufferedReader
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.io.PrintStream
|
||||||
|
import java.io.StringReader
|
||||||
|
|
||||||
fun createTestingCompilerEnvironment(
|
fun createTestingCompilerEnvironment(
|
||||||
messageCollector: MessageCollector,
|
messageCollector: MessageCollector,
|
||||||
outputItemsCollector: OutputItemsCollectorImpl,
|
outputItemsCollector: OutputItemsCollectorImpl,
|
||||||
services: Services
|
services: Services
|
||||||
): JpsCompilerEnvironment {
|
): JpsCompilerEnvironment {
|
||||||
val paths = PathUtil.kotlinPathsForDistDirectory
|
val paths = PathUtil.kotlinPathsForDistDirectoryForTests
|
||||||
|
|
||||||
val wrappedMessageCollector = MessageCollectorToOutputItemsCollectorAdapter(messageCollector, outputItemsCollector)
|
val wrappedMessageCollector = MessageCollectorToOutputItemsCollectorAdapter(messageCollector, outputItemsCollector)
|
||||||
return JpsCompilerEnvironment(
|
return JpsCompilerEnvironment(
|
||||||
paths,
|
paths,
|
||||||
|
|||||||
+7
-17
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2022 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.jvm.compiler
|
package org.jetbrains.kotlin.jvm.compiler
|
||||||
@@ -19,12 +8,12 @@ package org.jetbrains.kotlin.jvm.compiler
|
|||||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType
|
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType
|
||||||
import org.jetbrains.kotlin.build.JvmSourceRoot
|
import org.jetbrains.kotlin.build.JvmSourceRoot
|
||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
|
import org.jetbrains.kotlin.jps.build.AbstractKotlinJpsBuildTestCase
|
||||||
import org.jetbrains.kotlin.modules.KotlinModuleXmlBuilder
|
import org.jetbrains.kotlin.modules.KotlinModuleXmlBuilder
|
||||||
import org.jetbrains.kotlin.test.MockLibraryUtil
|
import org.jetbrains.kotlin.test.MockLibraryUtil
|
||||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
import org.jetbrains.kotlin.test.kotlinPathsForDistDirectoryForTests
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import org.junit.Ignore
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +23,8 @@ import java.io.File
|
|||||||
*/
|
*/
|
||||||
class ClasspathOrderTest : TestCaseWithTmpdir() {
|
class ClasspathOrderTest : TestCaseWithTmpdir() {
|
||||||
companion object {
|
companion object {
|
||||||
private val sourceDir = File(KtTestUtil.getTestDataPathBase() + "/classpathOrder").absoluteFile
|
private val sourceDir
|
||||||
|
get() = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "/../../../compiler/testData/classpathOrder").absoluteFile
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testClasspathOrderForCLI() {
|
fun testClasspathOrderForCLI() {
|
||||||
@@ -47,7 +37,7 @@ class ClasspathOrderTest : TestCaseWithTmpdir() {
|
|||||||
File(tmpdir, "output").absolutePath,
|
File(tmpdir, "output").absolutePath,
|
||||||
listOf(sourceDir),
|
listOf(sourceDir),
|
||||||
listOf(JvmSourceRoot(sourceDir)),
|
listOf(JvmSourceRoot(sourceDir)),
|
||||||
listOf(PathUtil.kotlinPathsForDistDirectory.stdlibPath),
|
listOf(PathUtil.kotlinPathsForDistDirectoryForTests.stdlibPath),
|
||||||
emptyList(),
|
emptyList(),
|
||||||
null,
|
null,
|
||||||
JavaModuleBuildTargetType.PRODUCTION.typeId,
|
JavaModuleBuildTargetType.PRODUCTION.typeId,
|
||||||
|
|||||||
+10
-19
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2022 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.modules;
|
package org.jetbrains.kotlin.modules;
|
||||||
@@ -20,15 +9,17 @@ import junit.framework.TestCase;
|
|||||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||||
import org.jetbrains.kotlin.build.JvmSourceRoot;
|
import org.jetbrains.kotlin.build.JvmSourceRoot;
|
||||||
import org.jetbrains.kotlin.config.IncrementalCompilation;
|
import org.jetbrains.kotlin.config.IncrementalCompilation;
|
||||||
|
import org.jetbrains.kotlin.jps.build.AbstractKotlinJpsBuildTestCase;
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class KotlinModuleXmlGeneratorTest extends TestCase {
|
public class KotlinModuleXmlGeneratorTest extends TestCase {
|
||||||
private final static String testDataPath = "jps/jps-plugin/testData/modules.xml";
|
private static String getTestDataPath() {
|
||||||
|
return AbstractKotlinJpsBuildTestCase.Companion.getTEST_DATA_PATH() + "/modules.xml";
|
||||||
|
}
|
||||||
|
|
||||||
public void testBasic() {
|
public void testBasic() {
|
||||||
String actual = new KotlinModuleXmlBuilder().addModule(
|
String actual = new KotlinModuleXmlBuilder().addModule(
|
||||||
@@ -45,7 +36,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
|
|||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
IncrementalCompilation.isEnabledForJvm()
|
IncrementalCompilation.isEnabledForJvm()
|
||||||
).asText().toString();
|
).asText().toString();
|
||||||
KotlinTestUtils.assertEqualsToFile(new File(testDataPath + "/basic.xml"), actual);
|
KotlinTestUtils.assertEqualsToFile(new File(getTestDataPath() + "/basic.xml"), actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFiltered() {
|
public void testFiltered() {
|
||||||
@@ -63,7 +54,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
|
|||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
IncrementalCompilation.isEnabledForJvm()
|
IncrementalCompilation.isEnabledForJvm()
|
||||||
).asText().toString();
|
).asText().toString();
|
||||||
KotlinTestUtils.assertEqualsToFile(new File(testDataPath + "/filtered.xml"), actual);
|
KotlinTestUtils.assertEqualsToFile(new File(getTestDataPath() + "/filtered.xml"), actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultiple() {
|
public void testMultiple() {
|
||||||
@@ -97,7 +88,7 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
|
|||||||
IncrementalCompilation.isEnabledForJvm()
|
IncrementalCompilation.isEnabledForJvm()
|
||||||
);
|
);
|
||||||
String actual = builder.asText().toString();
|
String actual = builder.asText().toString();
|
||||||
KotlinTestUtils.assertEqualsToFile(new File(testDataPath + "/multiple.xml"), actual);
|
KotlinTestUtils.assertEqualsToFile(new File(getTestDataPath() + "/multiple.xml"), actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testModularJdkRoot() {
|
public void testModularJdkRoot() {
|
||||||
@@ -115,6 +106,6 @@ public class KotlinModuleXmlGeneratorTest extends TestCase {
|
|||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
IncrementalCompilation.isEnabledForJvm()
|
IncrementalCompilation.isEnabledForJvm()
|
||||||
).asText().toString();
|
).asText().toString();
|
||||||
KotlinTestUtils.assertEqualsToFile(new File(testDataPath + "/modularJdkRoot.xml"), actual);
|
KotlinTestUtils.assertEqualsToFile(new File(getTestDataPath() + "/modularJdkRoot.xml"), actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
* Copyright 2010-2022 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.jps.build
|
package org.jetbrains.kotlin.jps.build
|
||||||
@@ -636,11 +625,11 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
// When JPS is run on TeamCity, it can not rely on Kotlin plugin layout,
|
// When JPS is run on TeamCity, it can not rely on Kotlin plugin layout,
|
||||||
// so the path to Kotlin is specified in a system property
|
// so the path to Kotlin is specified in a system property
|
||||||
private fun computeKotlinPathsForJpsPlugin(messageCollector: MessageCollectorAdapter): KotlinPaths? {
|
private fun computeKotlinPathsForJpsPlugin(messageCollector: MessageCollectorAdapter): KotlinPaths? {
|
||||||
if (System.getProperty("kotlin.jps.tests").equals("true", ignoreCase = true)) {
|
val jpsKotlinHome = System.getProperty(JPS_KOTLIN_HOME_PROPERTY)?.let { File(it) }
|
||||||
|
if (System.getProperty("kotlin.jps.tests").equals("true", ignoreCase = true) && jpsKotlinHome == null) {
|
||||||
return PathUtil.kotlinPathsForDistDirectory
|
return PathUtil.kotlinPathsForDistDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
val jpsKotlinHome = System.getProperty(JPS_KOTLIN_HOME_PROPERTY)?.let { File(it) }
|
|
||||||
return when {
|
return when {
|
||||||
jpsKotlinHome == null -> {
|
jpsKotlinHome == null -> {
|
||||||
messageCollector.report(ERROR, "Make sure that '$JPS_KOTLIN_HOME_PROPERTY' system property is set in JPS process")
|
messageCollector.report(ERROR, "Make sure that '$JPS_KOTLIN_HOME_PROPERTY' system property is set in JPS process")
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ idePluginDependency {
|
|||||||
"compiler/testData/diagnostics/helpers",
|
"compiler/testData/diagnostics/helpers",
|
||||||
"compiler/tests-spec/testData",
|
"compiler/tests-spec/testData",
|
||||||
"compiler/testData/diagnostics/testsWithStdLib",
|
"compiler/testData/diagnostics/testsWithStdLib",
|
||||||
"compiler/fir/raw-fir/psi2fir/testData"
|
"compiler/fir/raw-fir/psi2fir/testData",
|
||||||
|
"jps/jps-plugin/testData",
|
||||||
|
"compiler/testData/classpathOrder",
|
||||||
).forEach {
|
).forEach {
|
||||||
from(rootDir.resolve(it)) {
|
from(rootDir.resolve(it)) {
|
||||||
into(it)
|
into(it)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
}
|
||||||
|
|
||||||
|
publishTestJarsForIde(
|
||||||
|
listOf(
|
||||||
|
":jps:jps-plugin",
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -352,6 +352,7 @@ if (!buildProperties.inJpsBuildIdeaSync) {
|
|||||||
":prepare:ide-plugin-dependencies:kotlin-gradle-statistics-for-ide",
|
":prepare:ide-plugin-dependencies:kotlin-gradle-statistics-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:kotlin-jps-common-for-ide",
|
":prepare:ide-plugin-dependencies:kotlin-jps-common-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:kotlin-jps-plugin-classpath",
|
":prepare:ide-plugin-dependencies:kotlin-jps-plugin-classpath",
|
||||||
|
":prepare:ide-plugin-dependencies:kotlin-jps-plugin-tests-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:kotlinx-serialization-compiler-plugin-for-ide",
|
":prepare:ide-plugin-dependencies:kotlinx-serialization-compiler-plugin-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:noarg-compiler-plugin-for-ide",
|
":prepare:ide-plugin-dependencies:noarg-compiler-plugin-for-ide",
|
||||||
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide",
|
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide",
|
||||||
|
|||||||
Reference in New Issue
Block a user