Because I don't know sbt...
./gradlew clean test npm_i npm_run_build
[[toc]]
initialize new scala
project:
mkdir gradle-scala-application-howto cd gradle-scala-application-howto/ gradle init --type scala-library --package com.github.daggerok --project-name gradle-scala-application-howto --dsl kotlin
add to build.gradle.kts
file fatJar
task definition:
tasks { register<Jar>("fatJar") { archiveClassifier.set("all") duplicatesStrategy = DuplicatesStrategy.EXCLUDE manifest { attributes("Main-Class" to "com.github.daggerok.Main") } from(configurations.runtimeClasspath.get() .onEach { println("add from dependencies: ${it.name}") } .map { if (it.isDirectory) it else zipTree(it) }) val sourcesMain = sourceSets.main.get() sourcesMain.allSource.forEach { println("add from sources: ${it.name}") } from(sourcesMain.output) } }
then build and run, like so:
./gradlew clean fatJar java -jar build/libs/*-all.jar
add to build.gradle.kts
file these lines for better developer experience on tests execution:
import org.gradle.api.tasks.testing.logging.TestLogEvent.* tasks { withType<Test> { testLogging { showExceptions = true showStandardStreams = true events(PASSED, SKIPPED, FAILED) } } }
add to build.gradle.kts
file these lines for better developer experience on tests execution:
plugins { // Add Gradle NodeJS support id("com.moowork.node") version "1.3.1" } node { download = true }
prepare everything together with npm scrips and use gradle instead:
./gradlew npm_i # npm i ./gradlew npm_run build # npm run build
create .gitignore
file:
.idea/ *.iml *.ipr *.iws *.log* .gradle/ build/ /out/ .DS_Store node_modules/ .vuepress/dist/
just see .github/workflows/ci.yaml file as a the reference...