Remove intellij-core usages from kotlin-gradle-plugin-integration-tests
We can use only relocated intellij-core from kotlin-compiler-embeddable. Non-source usages do not resolve in IDE (which also breaks debugger).
This commit is contained in:
+4
-5
@@ -1,6 +1,5 @@
|
|||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtil
|
|
||||||
import org.gradle.api.logging.LogLevel
|
import org.gradle.api.logging.LogLevel
|
||||||
import org.jetbrains.kotlin.gradle.util.*
|
import org.jetbrains.kotlin.gradle.util.*
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
@@ -21,7 +20,7 @@ abstract class BaseGradleIT {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
workingDir = FileUtil.createTempDirectory("BaseGradleIT", null)
|
workingDir = createTempDir("BaseGradleIT")
|
||||||
acceptAndroidSdkLicenses()
|
acceptAndroidSdkLicenses()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +104,7 @@ abstract class BaseGradleIT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createNewWrapperDir(version: String): File =
|
private fun createNewWrapperDir(version: String): File =
|
||||||
FileUtil.createTempDirectory("GradleWrapper-", version, /* deleteOnExit */ true)
|
createTempDir("GradleWrapper-$version")
|
||||||
.apply {
|
.apply {
|
||||||
File(BaseGradleIT.resourcesRootFile, "GradleWrapper").copyRecursively(this)
|
File(BaseGradleIT.resourcesRootFile, "GradleWrapper").copyRecursively(this)
|
||||||
val wrapperProperties = File(this, "gradle/wrapper/gradle-wrapper.properties")
|
val wrapperProperties = File(this, "gradle/wrapper/gradle-wrapper.properties")
|
||||||
@@ -345,8 +344,8 @@ abstract class BaseGradleIT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun CompiledProject.assertContainFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String = ""): CompiledProject {
|
fun CompiledProject.assertContainFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String = ""): CompiledProject {
|
||||||
val expectedNormalized = expected.map(FileUtil::normalize).toSortedSet()
|
val expectedNormalized = expected.map(::normalizePath).toSortedSet()
|
||||||
val actualNormalized = actual.map(FileUtil::normalize).toSortedSet()
|
val actualNormalized = actual.map(::normalizePath).toSortedSet()
|
||||||
assertTrue(actualNormalized.containsAll(expectedNormalized), messagePrefix + "expected files: ${expectedNormalized.joinToString()}\n !in actual files: ${actualNormalized.joinToString()}")
|
assertTrue(actualNormalized.containsAll(expectedNormalized), messagePrefix + "expected files: ${expectedNormalized.joinToString()}\n !in actual files: ${actualNormalized.joinToString()}")
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -17,10 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.api.logging.LogLevel
|
import org.gradle.api.logging.LogLevel
|
||||||
import org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtil
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.CopyClassesToJavaOutputStatus
|
import org.jetbrains.kotlin.gradle.plugin.CopyClassesToJavaOutputStatus
|
||||||
import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE
|
import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
|
||||||
import org.jetbrains.kotlin.gradle.util.*
|
import org.jetbrains.kotlin.gradle.util.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -63,7 +61,7 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
|
|
||||||
val wd2 = FileUtil.createTempDirectory("testRunningInDifferentDir", null)
|
val wd2 = createTempDir("testRunningInDifferentDir")
|
||||||
wd1.copyRecursively(wd2)
|
wd1.copyRecursively(wd2)
|
||||||
wd1.deleteRecursively()
|
wd1.deleteRecursively()
|
||||||
assert(!wd1.exists())
|
assert(!wd1.exists())
|
||||||
|
|||||||
+65
@@ -1,6 +1,7 @@
|
|||||||
package org.jetbrains.kotlin.gradle.util
|
package org.jetbrains.kotlin.gradle.util
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
fun File.getFileByName(name: String): File =
|
fun File.getFileByName(name: String): File =
|
||||||
findFileByName(name) ?: throw AssertionError("Could not find file with name '$name' in $this")
|
findFileByName(name) ?: throw AssertionError("Could not find file with name '$name' in $this")
|
||||||
@@ -24,3 +25,67 @@ fun File.modify(transform: (String)->String) {
|
|||||||
writeText(transform(readText()))
|
writeText(transform(readText()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun createTempDir(prefix: String): File =
|
||||||
|
Files.createTempDirectory(prefix).toFile().apply {
|
||||||
|
deleteOnExit()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* converts back slashes to forward slashes
|
||||||
|
* removes double slashes inside the path, e.g. "x/y//z" => "x/y/z"
|
||||||
|
*
|
||||||
|
* Converted from com.intellij.openapi.util.io.FileUtil.normalize
|
||||||
|
*/
|
||||||
|
fun normalizePath(path: String): String {
|
||||||
|
var start = 0
|
||||||
|
var separator = false
|
||||||
|
if (isWindows) {
|
||||||
|
if (path.startsWith("//")) {
|
||||||
|
start = 2
|
||||||
|
separator = true
|
||||||
|
} else if (path.startsWith("\\\\")) {
|
||||||
|
return normalizeTail(0, path, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i in start until path.length) {
|
||||||
|
val c = path[i]
|
||||||
|
if (c == '/') {
|
||||||
|
if (separator) {
|
||||||
|
return normalizeTail(i, path, true)
|
||||||
|
}
|
||||||
|
separator = true
|
||||||
|
} else if (c == '\\') {
|
||||||
|
return normalizeTail(i, path, separator)
|
||||||
|
} else {
|
||||||
|
separator = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun normalizeTail(prefixEnd: Int, path: String, separator: Boolean): String {
|
||||||
|
var separator = separator
|
||||||
|
val result = StringBuilder(path.length)
|
||||||
|
result.append(path, 0, prefixEnd)
|
||||||
|
var start = prefixEnd
|
||||||
|
if (start == 0 && isWindows && (path.startsWith("//") || path.startsWith("\\\\"))) {
|
||||||
|
start = 2
|
||||||
|
result.append("//")
|
||||||
|
separator = true
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i in start until path.length) {
|
||||||
|
val c = path[i]
|
||||||
|
if (c == '/' || c == '\\') {
|
||||||
|
if (!separator) result.append('/')
|
||||||
|
separator = true
|
||||||
|
} else {
|
||||||
|
result.append(c)
|
||||||
|
separator = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString()
|
||||||
|
}
|
||||||
+2
-2
@@ -47,10 +47,10 @@ fun runProcess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun createGradleCommand(wrapperDir: File, tailParameters: List<String>): List<String> {
|
fun createGradleCommand(wrapperDir: File, tailParameters: List<String>): List<String> {
|
||||||
return if (isWindows())
|
return if (isWindows)
|
||||||
listOf("cmd", "/C", "${wrapperDir.absolutePath}/gradlew.bat") + tailParameters
|
listOf("cmd", "/C", "${wrapperDir.absolutePath}/gradlew.bat") + tailParameters
|
||||||
else
|
else
|
||||||
listOf("/bin/bash", "${wrapperDir.absolutePath}/gradlew") + tailParameters
|
listOf("/bin/bash", "${wrapperDir.absolutePath}/gradlew") + tailParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isWindows(): Boolean = System.getProperty("os.name")!!.contains("Windows")
|
val isWindows: Boolean = System.getProperty("os.name")!!.contains("Windows")
|
||||||
Reference in New Issue
Block a user