-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from danger/gradle-5-support
Updated travis ci for gradle 5 support
- Loading branch information
Showing
25 changed files
with
295 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' } | ||
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } | ||
} | ||
|
||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
apply plugin: 'kotlin' | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' } | ||
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } | ||
maven { url 'https://plugins.gradle.org/m2/' } | ||
} | ||
|
||
dependencies { | ||
compileOnly gradleApi() | ||
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin' | ||
implementation 'org.jetbrains.kotlin:kotlin-stdlib' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Reuse Kotlin version from the root project. | ||
File rootProjectGradlePropertiesFile = file("${rootProject.projectDir}/../gradle.properties") | ||
if (!rootProjectGradlePropertiesFile.isFile()) { | ||
throw new Exception("File $rootProjectGradlePropertiesFile does not exist or is not a file") | ||
} | ||
|
||
Properties rootProjectProperties = new Properties() | ||
rootProjectGradlePropertiesFile.withInputStream { inputStream -> | ||
rootProjectProperties.load(inputStream) | ||
if (!rootProjectProperties.containsKey('kotlin_version')) { | ||
throw new Exception("No 'kotlin_version' property in $rootProjectGradlePropertiesFile file") | ||
} | ||
} | ||
|
||
gradle.beforeProject { project -> | ||
rootProjectProperties.forEach { String key, value -> | ||
if (!project.hasProperty(key)) | ||
project.ext[key] = value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license | ||
* that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
import org.gradle.api.NamedDomainObjectCollection | ||
import org.gradle.api.NamedDomainObjectContainer | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.ExtraPropertiesExtension | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation | ||
|
||
/* | ||
* This file includes internal short-cuts visible only inside of the 'buildSrc' module. | ||
*/ | ||
|
||
internal val hostOs by lazy { System.getProperty("os.name") } | ||
internal val userHome by lazy { System.getProperty("user.home") } | ||
|
||
internal val Project.ext: ExtraPropertiesExtension | ||
get() = extensions.getByName("ext") as ExtraPropertiesExtension | ||
|
||
internal val Project.kotlin: KotlinMultiplatformExtension | ||
get() = extensions.getByName("kotlin") as KotlinMultiplatformExtension | ||
|
||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.macosX64: KotlinTargetPreset<*> | ||
get() = getByName(::macosX64.name) as KotlinTargetPreset<*> | ||
|
||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.linuxX64: KotlinTargetPreset<*> | ||
get() = getByName(::linuxX64.name) as KotlinTargetPreset<*> | ||
|
||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.mingwX64: KotlinTargetPreset<*> | ||
get() = getByName(::mingwX64.name) as KotlinTargetPreset<*> | ||
|
||
internal val NamedDomainObjectContainer<out KotlinCompilation>.main: KotlinNativeCompilation | ||
get() = getByName(::main.name) as KotlinNativeCompilation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license | ||
* that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
@file:JvmName("MPPTools") | ||
|
||
import groovy.lang.Closure | ||
import org.gradle.api.Project | ||
import org.gradle.api.Task | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset | ||
import java.nio.file.Paths | ||
|
||
/* | ||
* This file includes short-cuts that may potentially be implemented in Kotlin MPP Gradle plugin in the future. | ||
*/ | ||
|
||
// Short-cuts for detecting the host OS. | ||
@get:JvmName("isMacos") | ||
val isMacos by lazy { hostOs == "Mac OS X" } | ||
|
||
@get:JvmName("isWindows") | ||
val isWindows by lazy { hostOs.startsWith("Windows") } | ||
|
||
@get:JvmName("isLinux") | ||
val isLinux by lazy { hostOs == "Linux" } | ||
|
||
// Short-cuts for mostly used paths. | ||
@get:JvmName("mingwPath") | ||
val mingwPath by lazy { System.getenv("MINGW64_DIR") ?: "c:/msys64/mingw64" } | ||
|
||
@get:JvmName("kotlinNativeDataPath") | ||
val kotlinNativeDataPath by lazy { | ||
System.getenv("KONAN_DATA_DIR") ?: Paths.get(userHome, ".konan").toString() | ||
} | ||
|
||
// A short-cut for evaluation of the default host Kotlin/Native preset. | ||
@JvmOverloads | ||
fun defaultHostPreset( | ||
subproject: Project, | ||
whitelist: List<KotlinTargetPreset<*>> = listOf(subproject.kotlin.presets.macosX64, subproject.kotlin.presets.linuxX64, subproject.kotlin.presets.mingwX64) | ||
): KotlinTargetPreset<*> { | ||
|
||
if (whitelist.isEmpty()) | ||
throw Exception("Preset whitelist must not be empty in Kotlin/Native ${subproject.displayName}.") | ||
|
||
val presetCandidate = when { | ||
isMacos -> subproject.kotlin.presets.macosX64 | ||
isLinux -> subproject.kotlin.presets.linuxX64 | ||
isWindows -> subproject.kotlin.presets.mingwX64 | ||
else -> null | ||
} | ||
|
||
val preset = if (presetCandidate != null && presetCandidate in whitelist) | ||
presetCandidate | ||
else | ||
throw Exception("Host OS '$hostOs' is not supported in Kotlin/Native ${subproject.displayName}.") | ||
|
||
subproject.ext.set("hostPreset", preset) | ||
|
||
return preset | ||
} | ||
|
||
// A short-cut to add a Kotlin/Native run task. | ||
@JvmOverloads | ||
fun createRunTask( | ||
subproject: Project, | ||
name: String, | ||
target: KotlinTarget, | ||
configureClosure: Closure<Any>? = null | ||
): Task { | ||
val task = subproject.tasks.create(name, RunKotlinNativeTask::class.java, target) | ||
task.configure(configureClosure ?: task.emptyConfigureClosure()) | ||
return task | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license | ||
* that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
import groovy.lang.Closure | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.Task | ||
import org.gradle.api.tasks.TaskAction | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget | ||
import javax.inject.Inject | ||
|
||
open class RunKotlinNativeTask @Inject constructor( | ||
private val myTarget: KotlinTarget | ||
): DefaultTask() { | ||
|
||
var buildType = "RELEASE" | ||
var workingDir: Any = project.projectDir | ||
private var myArgs: List<String> = emptyList() | ||
private val myEnvironment: MutableMap<String, Any> = mutableMapOf() | ||
|
||
fun args(vararg args: Any) { | ||
myArgs = args.map { it.toString() } | ||
} | ||
|
||
fun environment(map: Map<String, Any>) { | ||
myEnvironment += map | ||
} | ||
|
||
override fun configure(configureClosure: Closure<Any>): Task { | ||
val task = super.configure(configureClosure) | ||
this.dependsOn += myTarget.compilations.main.linkTaskName("EXECUTABLE", buildType) | ||
return task | ||
} | ||
|
||
@TaskAction | ||
fun run() { | ||
project.exec { | ||
it.executable = myTarget.compilations.main.getBinary("EXECUTABLE", buildType).toString() | ||
it.args = myArgs | ||
it.environment = myEnvironment | ||
it.workingDir(workingDir) | ||
} | ||
} | ||
|
||
internal fun emptyConfigureClosure() = object : Closure<Any>(this) { | ||
override fun call(): RunKotlinNativeTask { | ||
return this@RunKotlinNativeTask | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' version '1.3.0' | ||
id 'org.jetbrains.kotlin.jvm' | ||
id 'maven-publish' | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.konan' version "1.3.11" | ||
id 'kotlin-multiplatform' | ||
} | ||
|
||
konan.targets = ['linux', 'macbook', 'mingw'] | ||
|
||
konanArtifacts { | ||
program("danger-kotlin") { | ||
enableOptimizations(true) | ||
kotlin { | ||
targets { | ||
fromPreset(MPPTools.defaultHostPreset(project), 'runner') { | ||
compilations.main.outputKinds 'EXECUTABLE' | ||
compilations.main.entryPoint 'com.danger.runner.main' | ||
} | ||
} | ||
} | ||
|
||
task('osName') { | ||
doLast { | ||
println "OS_TARGET=$org.jetbrains.kotlin.konan.target.HostManager.host" | ||
} | ||
|
||
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.runner) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
kotlin.code.style=official | ||
kotlin.import.noCommonSourceSets=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
zipStorePath=wrapper/dists |
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...-kotlin/src/main/kotlin/DangerJSRunner.kt → ...otlin/com/danger/runner/DangerJSRunner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
package com.danger.runner | ||
import platform.posix.* | ||
|
||
fun runDangerJS(command: String, args: List<String>) { | ||
|
7 changes: 4 additions & 3 deletions
7
...er-kotlin/src/main/kotlin/DangerKotlin.kt → .../kotlin/com/danger/runner/DangerKotlin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...tlin/src/main/kotlin/EditCommandRunner.kt → ...in/com/danger/runner/EditCommandRunner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
package com.danger.runner | ||
import platform.posix.* | ||
|
||
fun runEditCommand() { | ||
|
1 change: 1 addition & 0 deletions
1
danger-kotlin/src/main/kotlin/Runner.kt → ...erMain/kotlin/com/danger/runner/Runner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
package com.danger.runner | ||
import platform.posix.* | ||
|
||
const val TMP_INPUT_JSON_FILE = "danger_in.json" | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
kotlin.code.style=official | ||
kotlin.import.noCommonSourceSets=true | ||
kotlin_version=1.3.0 | ||
kotlin.code.style=official |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,18 @@ | ||
include ':danger-kotlin', 'danger-kotlin-library' | ||
pluginManagement { | ||
resolutionStrategy { | ||
eachPlugin { | ||
if (requested.id.id == "kotlin-multiplatform") { | ||
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}") | ||
} | ||
} | ||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
} | ||
|
||
include ':danger-kotlin-library' | ||
|
||
if (MPPTools.isMacos() || MPPTools.isLinux() || MPPTools.isWindows()) { | ||
include ':danger-kotlin' | ||
} |