Clean gradle scripts

This commit is contained in:
Hubert Van De Walle 2020-10-28 00:42:51 +01:00
parent cb58a4fbe0
commit c3fc6a4e88
7 changed files with 80 additions and 78 deletions

View File

@ -1,8 +1,9 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "1.4.10"
id("com.github.johnrengelman.shadow") version "6.1.0" apply false
kotlin("plugin.serialization") version "1.4.10"
}
kotlinDslPluginOptions {
experimentalWarning.set(false)
}
repositories {
@ -15,4 +16,5 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-serialization:1.4.10")
implementation("com.github.jengelman.gradle.plugins:shadow:6.1.0")
implementation("org.jlleitschuh.gradle:ktlint-gradle:9.4.1")
implementation("com.github.ben-manes:gradle-versions-plugin:0.28.0")
}

View File

@ -1,29 +1,12 @@
package be.simplenotes
import java.util.concurrent.TimeUnit.MINUTES
import kotlin.concurrent.thread
fun runCommand(vararg args: String, onError: () -> Unit) {
logging.captureStandardOutput(LogLevel.INFO)
ProcessBuilder(*args)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.directory(rootProject.projectDir)
.start()
.apply {
thread { inputStream.use { it.copyTo(System.out) } }
thread { errorStream.use { it.copyTo(System.out) } }
waitFor(2, MINUTES)
if (exitValue() != 0) onError()
}
}
tasks.create("dockerBuild") {
dependsOn("package")
doLast {
runCommand("docker", "build", "-t", "hubv/simplenotes:latest", ".") {
throw GradleException("Docker build failed")
exec {
commandLine("docker", "build", "-t", "hubv/simplenotes:latest", ".")
workingDir(rootProject.projectDir)
}
}
}
@ -32,8 +15,9 @@ tasks.create("dockerPush") {
dependsOn("dockerBuild")
doLast {
runCommand("docker", "push", "hubv/simplenotes:latest") {
throw GradleException("Docker Push failed")
exec {
commandLine("docker", "push", "hubv/simplenotes:latest")
workingDir(rootProject.projectDir)
}
}
}

View File

@ -1,57 +1,9 @@
package be.simplenotes
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
kotlin("jvm")
`java-library`
id("be.simplenotes.java-convention")
id("be.simplenotes.kotlin-convention")
id("be.simplenotes.junit-convention")
id("org.jlleitschuh.gradle.ktlint")
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url = uri("https://dl.bintray.com/arrow-kt/arrow-kt/") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
}
group = "be.simplenotes"
version = "1.0-SNAPSHOT"
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.4.10"))
}
tasks.withType<Test> {
useJUnitPlatform()
}
java {
sourceCompatibility = JavaVersion.VERSION_14
targetCompatibility = JavaVersion.VERSION_14
}
sourceSets {
val test by getting
test.resources.srcDir("${rootProject.projectDir}/simplenotes-test-resources/src/test/resources")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "14"
javaParameters = true
freeCompilerArgs = listOf(
"-Xinline-classes",
"-Xno-param-assertions",
"-Xno-call-assertions",
"-Xno-receiver-assertions"
)
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
id("com.github.ben-manes.versions")
}

View File

@ -0,0 +1,26 @@
package be.simplenotes
plugins {
java
`java-library`
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url = uri("https://dl.bintray.com/arrow-kt/arrow-kt/") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
}
group = "be.simplenotes"
version = "1.0-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_14
targetCompatibility = JavaVersion.VERSION_14
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}

View File

@ -0,0 +1,14 @@
package be.simplenotes
plugins {
java apply false
}
tasks.withType<Test> {
useJUnitPlatform()
}
sourceSets {
val test by getting
test.resources.srcDir("${rootProject.projectDir}/simplenotes-test-resources/src/test/resources")
}

View File

@ -0,0 +1,25 @@
package be.simplenotes
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm")
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.4.10"))
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "14"
javaParameters = true
freeCompilerArgs = listOf(
"-Xinline-classes",
"-Xno-param-assertions",
"-Xno-call-assertions",
"-Xno-receiver-assertions"
)
}
}

View File

@ -1,6 +1,5 @@
package be.simplenotes
plugins {
kotlin("jvm") apply false
kotlin("plugin.serialization")
}