Last active
February 21, 2018 08:42
-
-
Save ov7a/9e203ba27755d35c0557bb87bee40cd4 to your computer and use it in GitHub Desktop.
build.gradle quasar kotlin app example
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
apply plugin: 'java' | |
apply plugin: 'idea' | |
apply plugin: 'kotlin' | |
buildscript { | |
ext.kotlin_version = '1.1.51' | |
ext.quasar_version = '0.7.9' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") | |
} | |
} | |
configurations { | |
quasar | |
} | |
repositories { | |
mavenCentral() | |
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } | |
} | |
dependencies { | |
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version") | |
compile("co.paralleluniverse:quasar-core:$quasar_version:jdk8") | |
compile("co.paralleluniverse:quasar-actors:$quasar_version") | |
compile("co.paralleluniverse:quasar-kotlin:$quasar_version") | |
quasar "co.paralleluniverse:quasar-core:$quasar_version:jdk8" | |
//... some more deps | |
} | |
tasks.withType(JavaForkOptions) { | |
//uncomment if there are problems with fibers | |
//systemProperty 'co.paralleluniverse.fibers.verifyInstrumentation', 'true' | |
jvmArgs "-javaagent:${(++configurations.quasar.iterator())}" | |
} | |
task release(dependsOn: ['build']) { | |
group = "Build" | |
def targetDir = "$buildDir/release" | |
doLast { | |
copy { | |
from("src/main/resources/application.yml") | |
into targetDir | |
} | |
copy { | |
from "$buildDir/libs/${project.name}.jar" | |
into targetDir | |
} | |
copy { | |
from(configurations.quasar.files) | |
into "$targetDir/libs" | |
} | |
createRunScript("$targetDir/${project.name}.bat", "bat") | |
createRunScript("$targetDir/${project.name}.sh", "sh") | |
} | |
} | |
def createRunScript(String scriptPath, String type) { | |
def file = new File(scriptPath) | |
file.createNewFile() | |
file.setExecutable(true) | |
def preamble = "@echo off" | |
if (type == "sh") { | |
preamble = "#!/bin/bash" | |
} | |
def deps = configurations.quasar.files.collect { "-Xbootclasspath/a:\"libs/${it.name}\"" }.join(" ") | |
def flags = "-Dco.paralleluniverse.fibers.detectRunawayFibers=false" | |
def quasarAgent = configurations.quasar.files.find { it.name.contains("quasar-core") }.name | |
file.text = """$preamble | |
java -classpath "./*.jar" -javaagent:"libs/$quasarAgent" $deps $flags -jar ${project.name}.jar | |
""" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment