gradle-plugin: Specify compiler version in project properties
This patch allows gradle-plugin user to specify a compiler version via project properties. The default version is 0.2. It also updates samples to use this new version of gradle plugin.
This commit is contained in:
@@ -7,7 +7,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.1"
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.1"
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.1"
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.1"
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.1"
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.1"
|
||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ publishing {
|
||||
artifact jar
|
||||
groupId 'org.jetbrains.kotlin'
|
||||
artifactId 'kotlin-native-gradle-plugin'
|
||||
version '0.1'
|
||||
version '0.2'
|
||||
pom.withXml { XmlProvider xml ->
|
||||
def stdlibDep = xml.asNode().appendNode("dependencies").appendNode("dependency")
|
||||
stdlibDep.appendNode("groupId", "org.jetbrains.kotlin")
|
||||
@@ -87,12 +87,11 @@ bintray {
|
||||
repo = 'kotlin-native-dependencies'
|
||||
name = 'kotlin-native-gradle-plugin'
|
||||
userOrg = 'jetbrains'
|
||||
// TODO: Specify license and github path
|
||||
//licenses = ['Apache-2.0']
|
||||
//vcsUrl = 'https://github.com/...'
|
||||
licenses = ['Apache-2.0']
|
||||
vcsUrl = 'https://github.com/JetBrains/kotlin-native'
|
||||
version {
|
||||
name = '0.1'
|
||||
desc = 'Kotlin Native Gradle plugin 0.1'
|
||||
name = '0.2'
|
||||
desc = 'Kotlin Native Gradle plugin 0.2'
|
||||
}
|
||||
publish = true // project.hasProperty("publish")
|
||||
override = project.hasProperty("override")
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.gradle.plugin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
@@ -11,7 +27,6 @@ open class CompilerDownloadTask: DefaultTask() {
|
||||
internal companion object {
|
||||
internal const val DOWNLOAD_URL = "http://download.jetbrains.com/kotlin/native"
|
||||
|
||||
internal val KONAN_NAME = "kotlin-native-${simpleOsName()}-${KonanPlugin.KONAN_VERSION}"
|
||||
private val KONAN_PARENT_DIR = "${System.getProperty("user.home")}/.konan"
|
||||
|
||||
internal fun simpleOsName(): String {
|
||||
@@ -32,9 +47,10 @@ open class CompilerDownloadTask: DefaultTask() {
|
||||
return
|
||||
}
|
||||
try {
|
||||
logger.info("Downloading Kotlin Native compiler from $DOWNLOAD_URL into $KONAN_PARENT_DIR")
|
||||
DependencyDownloader(File(KONAN_PARENT_DIR), DOWNLOAD_URL, listOf(KONAN_NAME)).run()
|
||||
project.extensions.extraProperties.set(KonanPlugin.KONAN_HOME_PROPERTY_NAME, "$KONAN_PARENT_DIR/$KONAN_NAME")
|
||||
val konanCompiler = "kotlin-native-${simpleOsName()}-${project.konanVersion}"
|
||||
logger.info("Downloading Kotlin Native compiler from $DOWNLOAD_URL/$konanCompiler into $KONAN_PARENT_DIR")
|
||||
DependencyDownloader(File(KONAN_PARENT_DIR), DOWNLOAD_URL, listOf(konanCompiler)).run()
|
||||
project.extensions.extraProperties.set(KonanPlugin.KONAN_HOME_PROPERTY_NAME, "$KONAN_PARENT_DIR/$konanCompiler")
|
||||
} catch (e: RuntimeException) {
|
||||
throw GradleScriptException("Cannot download Kotlin Native compiler", e)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.gradle.plugin
|
||||
|
||||
import org.gradle.api.Named
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.gradle.plugin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
@@ -63,6 +79,9 @@ open class KonanCompileTask: DefaultTask() {
|
||||
@Optional @Input var apiVersion : String? = null
|
||||
internal set
|
||||
|
||||
// TODO: Is there a better way to rerun tasks when the compiler version changes?
|
||||
@Input val konanVersion = project.konanVersion
|
||||
|
||||
// Task action ------------------------------------------------------------
|
||||
|
||||
protected fun buildArgs() = mutableListOf<String>().apply {
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.gradle.plugin
|
||||
|
||||
import org.gradle.api.Named
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.gradle.plugin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
@@ -51,6 +67,8 @@ open class KonanInteropTask: DefaultTask() {
|
||||
@InputFiles val headers = mutableSetOf<FileCollection>()
|
||||
@InputFiles val linkFiles = mutableSetOf<FileCollection>()
|
||||
|
||||
@Input val konanVersion = project.konanVersion
|
||||
|
||||
@TaskAction
|
||||
fun exec() {
|
||||
project.javaexec {
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.gradle.plugin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
@@ -11,7 +27,8 @@ import org.gradle.internal.reflect.Instantiator
|
||||
|
||||
/**
|
||||
* We use the follwing properties:
|
||||
* kotlin.native.home - directory where compiler is located (aka dist in konan project output)
|
||||
* konan.home - directory where compiler is located (aka dist in konan project output).
|
||||
* konan.version - a konan compiler version for downloading.
|
||||
*/
|
||||
|
||||
// konanHome extension is set by downloadKonanCompiler task.
|
||||
@@ -33,6 +50,9 @@ internal val Project.konanInteropContainer: KonanInteropContainer
|
||||
|
||||
internal val Project.konanCompilerDownloadTask get() = tasks.getByName(KonanPlugin.KONAN_DOWNLOAD_TASK_NAME)
|
||||
|
||||
internal val Project.konanVersion
|
||||
get() = findProperty(KonanPlugin.KONAN_VERSION_PROPERTY_NAME) as String? ?: KonanPlugin.DEFAULT_KONAN_VERSION
|
||||
|
||||
class KonanArtifactsContainer(val project: ProjectInternal): AbstractNamedDomainObjectContainer<KonanCompilerConfig>(
|
||||
KonanCompilerConfig::class.java,
|
||||
project.gradle.services.get(Instantiator::class.java)) {
|
||||
@@ -91,11 +111,12 @@ class KonanPlugin: Plugin<ProjectInternal> {
|
||||
companion object {
|
||||
internal const val COMPILER_EXTENSION_NAME = "konanArtifacts"
|
||||
internal const val INTEROP_EXTENSION_NAME = "konanInterop"
|
||||
internal const val KONAN_HOME_PROPERTY_NAME = "konan.home"
|
||||
internal const val KONAN_DOWNLOAD_TASK_NAME = "downloadKonanCompiler"
|
||||
|
||||
// TODO: Move in config.
|
||||
internal const val KONAN_VERSION = "0.1"
|
||||
internal const val KONAN_HOME_PROPERTY_NAME = "konan.home"
|
||||
internal const val KONAN_VERSION_PROPERTY_NAME = "konan.version"
|
||||
|
||||
internal const val DEFAULT_KONAN_VERSION = "0.2"
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# TODO: find a good name for the plugin
|
||||
implementation-class=org.jetbrains.kotlin.gradle.plugin.KonanPlugin
|
||||
Reference in New Issue
Block a user