From 6c06c4e3fc99a2161a275019d340745bc11fd552 Mon Sep 17 00:00:00 2001 From: Anton Yalyshev Date: Thu, 26 Sep 2019 11:49:16 +0300 Subject: [PATCH] Group Id and Version fields generation doesn't need 193 bunches. It works well with previos versions. --- ...eMobileSharedMultiplatformModuleBuilder.kt | 4 +- ...ileSharedMultiplatformModuleBuilder.kt.193 | 205 --------------- ...nGradleSharedMultiplatformModuleBuilder.kt | 4 +- ...dleSharedMultiplatformModuleBuilder.kt.193 | 237 ------------------ 4 files changed, 4 insertions(+), 446 deletions(-) delete mode 100644 idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileSharedMultiplatformModuleBuilder.kt.193 delete mode 100644 idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleSharedMultiplatformModuleBuilder.kt.193 diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileSharedMultiplatformModuleBuilder.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileSharedMultiplatformModuleBuilder.kt index 5136c8c33ea..1898b60ff45 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileSharedMultiplatformModuleBuilder.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileSharedMultiplatformModuleBuilder.kt @@ -139,8 +139,8 @@ class KotlinGradleMobileSharedMultiplatformModuleBuilder : KotlinGradleAbstractM override fun buildMultiPlatformPart(): String { return """ - group 'com.example' - version '0.0.1' + group '${projectId?.groupId ?: "com.example"}' + version '${projectId?.version ?: "0.0.1"}' apply plugin: 'maven-publish' diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileSharedMultiplatformModuleBuilder.kt.193 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileSharedMultiplatformModuleBuilder.kt.193 deleted file mode 100644 index 83c78568311..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMobileSharedMultiplatformModuleBuilder.kt.193 +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2010-2018 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. - */ - -package org.jetbrains.kotlin.idea.configuration - -import com.intellij.openapi.vfs.VirtualFile -import java.io.BufferedWriter - -class KotlinGradleMobileSharedMultiplatformModuleBuilder : KotlinGradleAbstractMultiplatformModuleBuilder() { - - private val commonName: String = "common" - private var jvmTargetName: String = "jvm" - private var nativeTargetName: String = "ios" - - private val commonSourceName get() = "$commonName$productionSuffix" - private val commonTestName get() = "$commonName$testSuffix" - private val jvmSourceName get() = "$jvmTargetName$productionSuffix" - private val jvmTestName get() = "$jvmTargetName$testSuffix" - private val nativeSourceName get() = "$nativeTargetName$productionSuffix" - val nativeTestName get() = "$nativeTargetName$testSuffix" - - override val shouldEnableGradleMetadataPreview: Boolean = true - - override fun getBuilderId() = "kotlin.gradle.multiplatform.mobileshared" - - override fun getPresentableName() = "Mobile Shared Library | Gradle" - - override fun getDescription() = - "Multiplatform Gradle project allowing reuse of the same Kotlin code between two mobile platforms (JVM/Android and Native)" - - override fun createProjectSkeleton(rootDir: VirtualFile) { - val src = rootDir.createChildDirectory(this, "src") - - val commonMain = src.createKotlinSampleFileWriter(commonSourceName) - val commonTest = src.createKotlinSampleFileWriter(commonTestName, fileName = "SampleTests.kt") - val jvmMain = src.createKotlinSampleFileWriter(jvmSourceName, jvmTargetName) - val jvmTest = src.createKotlinSampleFileWriter(jvmTestName, fileName = "SampleTestsJVM.kt") - val nativeMain = src.createKotlinSampleFileWriter(nativeSourceName, nativeTargetName) - val nativeTest = src.createKotlinSampleFileWriter(nativeTestName, fileName = "SampleTestsNative.kt") - - try { - commonMain.write( - """ - package sample - - expect class Sample() { - fun checkMe(): Int - } - - expect object Platform { - fun name(): String - } - - fun hello(): String = "Hello from ${"$"}{Platform.name()}" - """.trimIndent() - ) - - jvmMain.write( - """ - package sample - - actual class Sample { - actual fun checkMe() = 42 - } - - actual object Platform { - actual fun name(): String = "JVM" - } - """.trimIndent() - ) - - nativeMain.write( - """ - package sample - - actual class Sample { - actual fun checkMe() = 7 - } - - actual object Platform { - actual fun name(): String = "iOS" - } - """.trimIndent() - ) - - commonTest.write( - """ - package sample - - import kotlin.test.Test - import kotlin.test.assertTrue - - class SampleTests { - @Test - fun testMe() { - assertTrue(Sample().checkMe() > 0) - } - } - """.trimIndent() - ) - - jvmTest.write( - """ - package sample - - import kotlin.test.Test - import kotlin.test.assertTrue - - class SampleTestsJVM { - @Test - fun testHello() { - assertTrue("JVM" in hello()) - } - } - """.trimIndent() - ) - - nativeTest.write( - """ - package sample - - import kotlin.test.Test - import kotlin.test.assertTrue - - class SampleTestsNative { - @Test - fun testHello() { - assertTrue("iOS" in hello()) - } - } - """.trimIndent() - ) - } finally { - listOf(commonMain, commonTest, jvmMain, jvmTest, nativeMain, nativeTest).forEach(BufferedWriter::close) - } - } - - override fun buildMultiPlatformPart(): String { - return """ - group '${projectId.groupId ?: "com.example"}' - version '${projectId.version ?: "0.0.1"}' - - apply plugin: 'maven-publish' - - kotlin { - jvm() - // This is for iPhone emulator - // Switch here to iosArm64 (or iosArm32) to build library for iPhone device - iosX64("$nativeTargetName") { - binaries { - framework() - } - } - sourceSets { - $commonSourceName { - dependencies { - implementation kotlin('stdlib-common') - } - } - $commonTestName { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - $jvmSourceName { - dependencies { - implementation kotlin('stdlib') - } - } - $jvmTestName { - dependencies { - implementation kotlin('test') - implementation kotlin('test-junit') - } - } - $nativeSourceName { - } - $nativeTestName { - } - } - } - - task $nativeTestName { - def device = project.findProperty("${nativeTargetName}Device")?.toString() ?: "iPhone 8" - dependsOn kotlin.targets.$nativeTargetName.binaries.getTest('DEBUG').linkTaskName - group = JavaBasePlugin.VERIFICATION_GROUP - description = "Runs tests for target '$nativeTargetName' on an iOS simulator" - - doLast { - def binary = kotlin.targets.$nativeTargetName.binaries.getTest('DEBUG').outputFile - exec { - commandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath - } - } - } - - configurations { - compileClasspath - } - """.trimIndent() - } -} \ No newline at end of file diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleSharedMultiplatformModuleBuilder.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleSharedMultiplatformModuleBuilder.kt index 068b21f7d66..4bf4566b6da 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleSharedMultiplatformModuleBuilder.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleSharedMultiplatformModuleBuilder.kt @@ -175,8 +175,8 @@ class KotlinGradleSharedMultiplatformModuleBuilder : KotlinGradleAbstractMultipl override fun buildMultiPlatformPart(): String { return """ - group 'com.example' - version '0.0.1' + group '${projectId?.groupId ?: "com.example"}' + version '${projectId?.version ?: "0.0.1"}' apply plugin: 'maven-publish' diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleSharedMultiplatformModuleBuilder.kt.193 b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleSharedMultiplatformModuleBuilder.kt.193 deleted file mode 100644 index 525402f3ee7..00000000000 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleSharedMultiplatformModuleBuilder.kt.193 +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2010-2018 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. - */ - -package org.jetbrains.kotlin.idea.configuration - -import com.intellij.openapi.vfs.VirtualFile -import org.jetbrains.kotlin.konan.target.presetName -import java.io.BufferedWriter - -class KotlinGradleSharedMultiplatformModuleBuilder : KotlinGradleAbstractMultiplatformModuleBuilder() { - - private val commonName: String = "common" - private var jvmTargetName: String = "jvm" - private var jsTargetName: String = "js" - private var nativeTargetName: String = defaultNativeTarget.userTargetName - - private val commonSourceName get() = "$commonName$productionSuffix" - private val commonTestName get() = "$commonName$testSuffix" - private val jvmSourceName get() = "$jvmTargetName$productionSuffix" - private val jvmTestName get() = "$jvmTargetName$testSuffix" - private val jsSourceName get() = "$jsTargetName$productionSuffix" - private val jsTestName get() = "$jsTargetName$testSuffix" - private val nativeSourceName get() = "$nativeTargetName$productionSuffix" - val nativeTestName get() = "$nativeTargetName$testSuffix" - - override val shouldEnableGradleMetadataPreview: Boolean = true - - override fun getBuilderId() = "kotlin.gradle.multiplatform.shared" - - override fun getPresentableName() = "Multiplatform Library | Gradle" - - override fun getDescription() = - "Multiplatform Gradle project allowing reuse of the same Kotlin code between all three main platforms (JVM, JS, and Native)" - - override fun createProjectSkeleton(rootDir: VirtualFile) { - val src = rootDir.createChildDirectory(this, "src") - - val commonMain = src.createKotlinSampleFileWriter(commonSourceName) - val commonTest = src.createKotlinSampleFileWriter(commonTestName, fileName = "SampleTests.kt") - val jvmMain = src.createKotlinSampleFileWriter(jvmSourceName, jvmTargetName) - val jvmTest = src.createKotlinSampleFileWriter(jvmTestName, fileName = "SampleTestsJVM.kt") - val jsMain = src.createKotlinSampleFileWriter(jsSourceName, jsTargetName) - val jsTest = src.createKotlinSampleFileWriter(jsTestName, fileName = "SampleTestsJS.kt") - val nativeMain = src.createKotlinSampleFileWriter(nativeSourceName, nativeTargetName) - val nativeTest = src.createKotlinSampleFileWriter(nativeTestName, fileName = "SampleTestsNative.kt") - - try { - commonMain.write( - """ - package sample - - expect class Sample() { - fun checkMe(): Int - } - - expect object Platform { - val name: String - } - - fun hello(): String = "Hello from ${"$"}{Platform.name}" - """.trimIndent() - ) - - jvmMain.write( - """ - package sample - - actual class Sample { - actual fun checkMe() = 42 - } - - actual object Platform { - actual val name: String = "JVM" - } - """.trimIndent() - ) - - jsMain.write( - """ - package sample - - actual class Sample { - actual fun checkMe() = 12 - } - - actual object Platform { - actual val name: String = "JS" - } - """.trimIndent() - ) - - nativeMain.write( - """ - package sample - - actual class Sample { - actual fun checkMe() = 7 - } - - actual object Platform { - actual val name: String = "Native" - } - """.trimIndent() - ) - - commonTest.write( - """ - package sample - - import kotlin.test.Test - import kotlin.test.assertTrue - - class SampleTests { - @Test - fun testMe() { - assertTrue(Sample().checkMe() > 0) - } - } - """.trimIndent() - ) - - jvmTest.write( - """ - package sample - - import kotlin.test.Test - import kotlin.test.assertTrue - - class SampleTestsJVM { - @Test - fun testHello() { - assertTrue("JVM" in hello()) - } - } - """.trimIndent() - ) - - jsTest.write( - """ - package sample - - import kotlin.test.Test - import kotlin.test.assertTrue - - class SampleTestsJS { - @Test - fun testHello() { - assertTrue("JS" in hello()) - } - } - """.trimIndent() - ) - - nativeTest.write( - """ - package sample - - import kotlin.test.Test - import kotlin.test.assertTrue - - class SampleTestsNative { - @Test - fun testHello() { - assertTrue("Native" in hello()) - } - } - """.trimIndent() - ) - } finally { - listOf(commonMain, commonTest, jvmMain, jvmTest, jsMain, jsTest, nativeMain, nativeTest).forEach(BufferedWriter::close) - } - } - - override fun buildMultiPlatformPart(): String { - return """ - group '${projectId.groupId ?: "com.example"}' - version '${projectId.version ?: "0.0.1"}' - - apply plugin: 'maven-publish' - - kotlin { - jvm() - js { - browser { - } - nodejs { - } - } - // For ARM, should be changed to iosArm32 or iosArm64 - // For Linux, should be changed to e.g. linuxX64 - // For MacOS, should be changed to e.g. macosX64 - // For Windows, should be changed to e.g. mingwX64 - ${defaultNativeTarget.presetName}("${defaultNativeTarget.userTargetName}") - sourceSets { - $commonSourceName { - dependencies { - implementation kotlin('stdlib-common') - } - } - $commonTestName { - dependencies { - implementation kotlin('test-common') - implementation kotlin('test-annotations-common') - } - } - $jvmSourceName { - dependencies { - implementation kotlin('stdlib-jdk8') - } - } - $jvmTestName { - dependencies { - implementation kotlin('test') - implementation kotlin('test-junit') - } - } - $jsSourceName { - dependencies { - implementation kotlin('stdlib-js') - } - } - $jsTestName { - dependencies { - implementation kotlin('test-js') - } - } - $nativeSourceName { - } - $nativeTestName { - } - } - } - """.trimIndent() - } -} \ No newline at end of file