Use Gradle !
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package be.simplenotes
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import java.io.File
|
||||
import java.lang.ProcessBuilder.Redirect.PIPE
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
open class CssTask : DefaultTask() {
|
||||
|
||||
private val root = project.file(".").parent
|
||||
|
||||
@get:InputDirectory
|
||||
val templatesDir = File(root, "simplenotes-views/src/main/kotlin/be/simplenotes/views")
|
||||
|
||||
@get:InputDirectory
|
||||
val postCssDir = File(project.rootDir, "css/src")
|
||||
|
||||
@get:OutputDirectory
|
||||
val outputRootDir = File(project.buildDir, "generated-resources/css")
|
||||
|
||||
private val yarnRoot = File(project.rootDir, "css")
|
||||
private val cssIndex = File(postCssDir, "styles.pcss")
|
||||
|
||||
private val cssOutput = File(outputRootDir, "static/styles.css")
|
||||
private val manifestOutput = File(outputRootDir, "css-manifest.json")
|
||||
|
||||
@TaskAction
|
||||
fun generateCss() {
|
||||
// TODO: auto yarn install ?
|
||||
|
||||
outputRootDir.listFiles()?.let { it.forEach { it.delete() } }
|
||||
|
||||
ProcessBuilder("yarn", "run", "postcss", "build", "$cssIndex", "--output", "$cssOutput")
|
||||
.apply { environment()["MANIFEST"] = "$manifestOutput" }
|
||||
.redirectOutput(PIPE)
|
||||
.redirectError(PIPE)
|
||||
.directory(yarnRoot)
|
||||
.start()
|
||||
.apply {
|
||||
thread { inputStream.use { it.copyTo(System.out) } }
|
||||
thread { errorStream.use { it.copyTo(System.out) } }
|
||||
waitFor(30, TimeUnit.SECONDS)
|
||||
if (exitValue() != 0) throw GradleException(":/")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
@file:Suppress("SpellCheckingInspection")
|
||||
|
||||
package be.simplenotes
|
||||
|
||||
object Libs {
|
||||
const val arrowCore = "io.arrow-kt:arrow-core:0.11.0"
|
||||
const val commonsCompress = "org.apache.commons:commons-compress:1.20"
|
||||
const val flexmark = "com.vladsch.flexmark:flexmark:0.62.2"
|
||||
const val flexmarkGfmTasklist = "com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.62.2"
|
||||
const val flywayCore = "org.flywaydb:flyway-core:6.5.4"
|
||||
const val h2 = "com.h2database:h2:1.4.200"
|
||||
const val hikariCP = "com.zaxxer:HikariCP:3.4.3"
|
||||
const val http4kCore = "org.http4k:http4k-core:3.268.0"
|
||||
const val javaJwt = "com.auth0:java-jwt:3.10.3"
|
||||
const val javaxServlet = "javax.servlet:javax.servlet-api:4.0.1"
|
||||
const val jbcrypt = "org.mindrot:jbcrypt:0.4"
|
||||
const val jettyServer = "org.eclipse.jetty:jetty-server:9.4.32.v20200930"
|
||||
const val jettyServlet = "org.eclipse.jetty:jetty-servlet:9.4.32.v20200930"
|
||||
const val koinCore = "org.koin:koin-core:2.1.6"
|
||||
const val konform = "io.konform:konform-jvm:0.2.0"
|
||||
const val kotlinxHtml = "org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.1"
|
||||
const val kotlinxSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.0.0"
|
||||
const val ktormCore = "me.liuwj.ktorm:ktorm-core:3.0.0"
|
||||
const val ktormMysql = "me.liuwj.ktorm:ktorm-support-mysql:3.0.0"
|
||||
const val logbackClassic = "ch.qos.logback:logback-classic:1.2.3"
|
||||
const val luceneAnalyzersCommon = "org.apache.lucene:lucene-analyzers-common:8.6.1"
|
||||
const val luceneCore = "org.apache.lucene:lucene-core:8.6.1"
|
||||
const val luceneQueryParser = "org.apache.lucene:lucene-queryparser:8.6.1"
|
||||
const val mapstruct = "org.mapstruct:mapstruct:1.4.1.Final"
|
||||
const val mapstructProcessor = "org.mapstruct:mapstruct-processor:1.4.1.Final"
|
||||
const val mariadbClient = "org.mariadb.jdbc:mariadb-java-client:2.6.2"
|
||||
const val owaspHtmlSanitizer = "com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20200713.1"
|
||||
const val prettytime ="org.ocpsoft.prettytime:prettytime:4.0.5.Final"
|
||||
const val slf4jApi = "org.slf4j:slf4j-api:1.7.25"
|
||||
const val snakeyaml = "org.yaml:snakeyaml:1.26"
|
||||
|
||||
const val assertJ = "org.assertj:assertj-core:3.16.1"
|
||||
const val hamkrest = "com.natpryce:hamkrest:1.7.0.3"
|
||||
const val http4kTestingHamkrest = "org.http4k:http4k-testing-hamkrest:3.268.0"
|
||||
const val junit = "org.junit.jupiter:junit-jupiter:5.6.2"
|
||||
const val mockk = "io.mockk:mockk:1.10.0"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package be.simplenotes
|
||||
|
||||
import org.gradle.kotlin.dsl.register
|
||||
|
||||
plugins {
|
||||
java apply false
|
||||
}
|
||||
|
||||
tasks.register<CssTask>("css")
|
||||
|
||||
sourceSets {
|
||||
val main by getting
|
||||
val root = file("$buildDir/generated-resources/css")
|
||||
main.resources.srcDir(root)
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.create("dockerPush") {
|
||||
dependsOn("dockerBuild")
|
||||
|
||||
doLast {
|
||||
runCommand("docker", "push", "hubv/simplenotes:latest") {
|
||||
throw GradleException("Docker Push failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package be.simplenotes
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
tasks.withType<ShadowJar> {
|
||||
|
||||
archiveBaseName.set("app")
|
||||
manifest.attributes["Main-Class"] = "be.simplenotes.app.SimpleNotesKt"
|
||||
|
||||
mergeServiceFiles()
|
||||
|
||||
// minimize()
|
||||
|
||||
// include("org.mariadb.jdbc:mariadb-java-client")
|
||||
// include("com.h2database:h2")
|
||||
// include("org.jetbrains.kotlin:kotlin-reflect")
|
||||
// include("org.eclipse.jetty:*")
|
||||
// include("org.apache.lucene:*")
|
||||
// include("org.ocpsoft.prettytime:prettytime")
|
||||
|
||||
File(rootProject.projectDir, "buildSrc/src/main/resources/exclusions")
|
||||
.listFiles()!!
|
||||
.flatMap {
|
||||
it.readLines()
|
||||
.asSequence()
|
||||
.map { it.trim() }
|
||||
.filterNot { it.isBlank() }
|
||||
.filterNot { it.startsWith("#") }
|
||||
.asIterable()
|
||||
}.forEach { exclude(it) }
|
||||
|
||||
}
|
||||
|
||||
tasks.create("package") {
|
||||
rootProject.subprojects.forEach { dependsOn(":${it.name}:test") }
|
||||
|
||||
dependsOn("shadowJar")
|
||||
dependsOn("css")
|
||||
|
||||
doLast {
|
||||
println("SimpleNotes Packaged !")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package be.simplenotes
|
||||
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
java
|
||||
kotlin("jvm")
|
||||
`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"
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user