Skip to content

Commit

Permalink
convert to 'kotlin-multiplatform'
Browse files Browse the repository at this point in the history
  • Loading branch information
msink committed Nov 5, 2018
1 parent 993aedd commit 6d8dca5
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ environment:

build_script:
- gradlew --no-daemon --info build run
- pushd build\bin && 7z a hello-windows.zip hello && popd

artifacts:
- path: build\konan\bin\mingw_x64\Hello-windows.exe
- path: build\bin\hello-windows.zip
name: build

deploy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.gradle
/build/

Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ matrix:
script:
- ./gradlew --no-daemon --info build run

after_success:
- cd build/bin && tar -czf "hello-${TRAVIS_OS_NAME}.tgz" hello && cd ../..

deploy:
provider: releases
api_key:
secure: i0eHy2xhVgC34izkbBIu+cHRg3hgzGgM4KdckdIOcTmCrJsqXiW+LHqlP35iYJIVM4maETh7zrbnTLXMqQmstnVgocaDSRYJsgjHI2/rUkM2EFmNMTz5KGknIVvzMlhZfxO7iHXjeWQZ7mgXL0Ysij7WtZpDir34Xllr3FvDc0YrJE74SazMzU3pzQ/xiitvsBgmB7zoO2oZ/ivgjoGObPf5v1HPEzveG6G8lUYlJJF5u2C3Njkz6N3gaVKLaKfEi77+ss7N6M29dnbstC+3Xa5AUj9Fwix7/1/DsnqinmsDyedlATYA5dY0HtfJ6LpDn82dmyfxHtEMz6/yrCNmxLu83X0ogRpTKgiz8Ee7tLaioQJLzFXLF/QjoNNHopzUI5IZHk2YCa/9FKW8S3jwtE47+bm1uI4WmRVhvsIJUl+kPu4nafHQz4wymmE89pUFnffrgQRWqRGYmHjF1vBpOA8a1qAgofbkPA8q7tUHbnjwTmJF2Fiu8F/wte2Pew6amook082bp9utAGhJuZWBipXipdOZd38/8v5Odyw4zqGTfH7LUUoOjD5zzwrvQDK6IFiddFzKZWVrY+94aKf/Jkn+s8zXlaER8dE8Cc2P8g4PEdGSnonEuAMkj5e0P/uBS59K3caBpHePgtBljxr7z2frmL3XNJ983BA8IsYlil8=
file: build/konan/bin/**/Hello-*.kexe
file: build/bin/hello-*.tgz
file_glob: true
skip_cleanup: true
on:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
- windows-x64 (appveyor)
- linux-x64 (travis)
- macos-x64 (travis)

Use the following Gradle commands
* to build: `./gradlew assemble`
* to test: `./gradlew check`
* to run: `./gradlew runProgram`
46 changes: 26 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
apply plugin: 'konan'
plugins {
id 'kotlin-multiplatform' version '1.3.0'
}

konanArtifacts {
program('Hello') {
target('linux') {
artifactName 'Hello-linux'
}
target('macbook') {
artifactName 'Hello-macos'
}
target('mingw') {
artifactName 'Hello-windows'
}
}
repositories {
mavenCentral()
}

buildscript {
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
final def os = org.gradle.internal.os.OperatingSystem.current()

kotlin {
final def hostPreset = os.isWindows() ? presets.mingwX64
: os.isLinux() ? presets.linuxX64
: os.isMacOsX() ? presets.macosX64
: /* ??? */ null
targets {
fromPreset(hostPreset, 'hello') {
compilations.main {
outputKinds 'EXECUTABLE'
entryPoint 'sample.hello.main'
}
}
}
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"
task runProgram {
def buildType = 'DEBUG' // 'RELEASE'
dependsOn kotlin.targets.hello.compilations.main.linkTaskName('EXECUTABLE', buildType)
doLast {
exec {
executable kotlin.targets.hello.compilations.main.getBinary('EXECUTABLE', buildType)
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
15 changes: 15 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.id == "kotlin-multiplatform") {
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}")
}
}
}

repositories {
mavenCentral()
}
}

rootProject.name = 'hello'
9 changes: 9 additions & 0 deletions src/helloMain/kotlin/Hello.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package sample.hello

fun hello(): String = "Hello, Kotlin/Native!"

fun main() {
val a = 43
val b = listOf(1, 2, 3)
println("$a: $b: " + hello())
}
11 changes: 11 additions & 0 deletions src/helloTest/kotlin/HelloTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package sample.hello

import kotlin.test.Test
import kotlin.test.assertTrue

class SampleTests {
@Test
fun testHello() {
assertTrue("Kotlin/Native" in hello())
}
}
3 changes: 0 additions & 3 deletions src/main/kotlin/Hello.kt

This file was deleted.

0 comments on commit 6d8dca5

Please sign in to comment.