Skip to content

Commit 304bf92

Browse files
SvyatoslavScherbinaSpace
authored and
Space
committed
Revert "[Gradle] Propagate offline mode to Native compiler"
This reverts commit 15a52f3
1 parent 91863f2 commit 304bf92

File tree

3 files changed

+6
-99
lines changed

3 files changed

+6
-99
lines changed

libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt

Lines changed: 5 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ import org.jetbrains.kotlin.konan.target.CompilerOutputKind
2121
import org.jetbrains.kotlin.konan.target.HostManager
2222
import org.jetbrains.kotlin.konan.target.KonanTarget
2323
import org.jetbrains.kotlin.konan.target.presetName
24-
import org.junit.*
25-
import org.junit.rules.TemporaryFolder
24+
import org.junit.Assume
25+
import org.junit.Ignore
26+
import org.junit.Rule
27+
import org.junit.Test
28+
import org.junit.rules.ErrorCollector
2629
import java.io.File
2730
import java.nio.file.Files
2831
import java.util.*
@@ -1093,81 +1096,6 @@ class GeneralNativeIT : BaseGradleIT() {
10931096
}
10941097
}
10951098

1096-
@Test
1097-
fun `check offline mode is propagated to the compiler`() = with(
1098-
transformNativeTestProjectWithPluginDsl(
1099-
"executables",
1100-
directoryPrefix = "native-binaries"
1101-
)
1102-
) {
1103-
val buildOptions = defaultBuildOptions()
1104-
1105-
val linkTask = ":linkDebugExecutableHost"
1106-
val compileTask = ":compileKotlinHost"
1107-
1108-
build(linkTask, options = buildOptions) {
1109-
assertSuccessful()
1110-
}
1111-
1112-
// Check that --offline works when all the dependencies are already downloaded:
1113-
val buildOptionsOffline = buildOptions.copy(freeCommandLineArgs = buildOptions.freeCommandLineArgs + "--offline")
1114-
1115-
build("clean", linkTask, options = buildOptionsOffline) {
1116-
assertSuccessful()
1117-
withNativeCommandLineArguments(compileTask, linkTask) {
1118-
assertTrue(it.contains("-Xoverride-konan-properties=airplaneMode=true"))
1119-
}
1120-
}
1121-
1122-
// Check that --offline fails when there are no downloaded dependencies:
1123-
val customKonanDataDir = tempDir.newFolder("konanOffline")
1124-
val buildOptionsOfflineWithCustomKonanDataDir = buildOptionsOffline.copy(
1125-
customEnvironmentVariables = buildOptionsOffline.customEnvironmentVariables +
1126-
("KONAN_DATA_DIR" to customKonanDataDir.absolutePath)
1127-
)
1128-
1129-
build("clean", linkTask, options = buildOptionsOfflineWithCustomKonanDataDir) {
1130-
assertFailed()
1131-
assertTasksNotExecuted(listOf(linkTask))
1132-
}
1133-
1134-
checkNoDependenciesDownloaded(customKonanDataDir)
1135-
1136-
// Check that the compiler is not extracted if it is not cached:
1137-
assertTrue(customKonanDataDir.deleteRecursively())
1138-
build(
1139-
"clean", linkTask, "-Pkotlin.native.version=1.6.20-M1-9999",
1140-
options = buildOptionsOfflineWithCustomKonanDataDir
1141-
) {
1142-
assertFailed()
1143-
assertTasksNotExecuted(listOf(linkTask, compileTask))
1144-
}
1145-
1146-
assertFalse(customKonanDataDir.exists())
1147-
}
1148-
1149-
private fun checkNoDependenciesDownloaded(customKonanDataDir: File) {
1150-
// Check that no files have actually been downloaded or extracted,
1151-
// except for maybe the compiler itself, which can be extracted from the Gradle cache
1152-
// (see NativeCompilerDownloader, it uses regular dependency resolution,
1153-
// so supports --offline properly by default).
1154-
val cacheDirName = "cache"
1155-
val dependenciesDirName = "dependencies"
1156-
1157-
fun assertDirectoryHasNothingButMaybe(directory: File, vararg names: String) {
1158-
assertEquals(emptyList(), directory.listFiles().orEmpty().map { it.name } - names)
1159-
}
1160-
1161-
assertDirectoryHasNothingButMaybe(File(customKonanDataDir, cacheDirName), ".lock")
1162-
assertDirectoryHasNothingButMaybe(File(customKonanDataDir, dependenciesDirName), ".extracted")
1163-
1164-
val customKonanDataDirFiles = customKonanDataDir.listFiles().orEmpty().map { it.name } - setOf(cacheDirName, dependenciesDirName)
1165-
if (customKonanDataDirFiles.isNotEmpty()) {
1166-
assertEquals(1, customKonanDataDirFiles.size, message = customKonanDataDirFiles.toString())
1167-
assertTrue(customKonanDataDirFiles.single().startsWith("kotlin-native-"), message = customKonanDataDirFiles.single())
1168-
}
1169-
}
1170-
11711099
@Test
11721100
fun allowToOverrideDownloadUrl() {
11731101
with(transformNativeTestProjectWithPluginDsl("native-parallel")) {
@@ -1263,15 +1191,5 @@ class GeneralNativeIT : BaseGradleIT() {
12631191
toolName: String = "konanc",
12641192
check: (Map<String, String>) -> Unit
12651193
) = taskPaths.forEach { taskPath -> check(extractNativeCustomEnvironment(taskPath, toolName)) }
1266-
1267-
@field:ClassRule
1268-
@JvmField
1269-
val tempDir = TemporaryFolder()
1270-
1271-
@JvmStatic
1272-
@AfterClass
1273-
fun deleteTempDir() {
1274-
tempDir.delete()
1275-
}
12761194
}
12771195
}

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinToolRunner.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ abstract class KotlinToolRunner(
5454
abstract val mustRunViaExec: Boolean
5555
open fun transformArgs(args: List<String>): List<String> = args
5656

57-
internal open val defaultArguments: List<String>
58-
get() = emptyList()
59-
6057
// for the purpose if there is a way to specify JVM args, for instance, straight in project configs
6158
open fun getCustomJvmArgs(): List<String> = emptyList()
6259

@@ -80,9 +77,8 @@ abstract class KotlinToolRunner(
8077

8178
fun run(args: List<String>) {
8279
checkClasspath()
83-
val argsWithDefault = args + defaultArguments
8480

85-
if (mustRunViaExec) runViaExec(argsWithDefault) else runInProcess(argsWithDefault)
81+
if (mustRunViaExec) runViaExec(args) else runInProcess(args)
8682
}
8783

8884
private fun runViaExec(args: List<String>) {

libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/nativeToolRunners.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,6 @@ internal class KotlinNativeCompilerRunner(project: Project) : KotlinNativeToolRu
175175

176176
return listOf(toolName, "@${argFile.absolutePath}")
177177
}
178-
179-
override val defaultArguments: List<String>
180-
get() = mutableListOf<String>().apply {
181-
if (project.gradle.startParameter.isOffline) {
182-
add("-Xoverride-konan-properties=airplaneMode=true")
183-
}
184-
}
185178
}
186179

187180
/** Platform libraries generation tool. Runs the cinterop tool under the hood. */

0 commit comments

Comments
 (0)