Skip to content

Instantly share code, notes, and snippets.

@ov7a
Last active Feb 21, 2018
Embed
What would you like to do?
build.gradle quasar kotlin app example
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