Skip to content

Instantly share code, notes, and snippets.

@falkoschumann
Last active October 20, 2023 19:45
Show Gist options
  • Save falkoschumann/8a970d7a2f29e906919aae37100d0aa9 to your computer and use it in GitHub Desktop.
Save falkoschumann/8a970d7a2f29e906919aae37100d0aa9 to your computer and use it in GitHub Desktop.
Gradle project starter
import org.apache.tools.ant.filters.FixCrLfFilter
import java.time.LocalDate
plugins {
id 'application'
id 'checkstyle'
id 'jacoco'
id 'java'
id 'com.diffplug.spotless' version '6.20.0'
id 'info.solidsoft.pitest' version '1.9.11'
id 'io.freefair.lombok' version '8.0.1'
id 'org.openjfx.javafxplugin' version '0.0.13'
}
group 'de.muspellheim'
version '0.1.0'
ext {
copyrightYear = LocalDate.now().year
}
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.1'
}
application {
mainClass = 'de.muspellheim.todos.TodosApplication'
mainModule = 'de.muspellheim.todos'
}
javafx {
version = "19"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
java {
sourceCompatibility = '17'
compileJava {
options.release = 17
options.encoding = 'utf-8'
options.compilerArgs.addAll(['-Xlint:all', '-Werror', '-implicit:class'])
}
compileTestJava {
options.release = 17
options.encoding = 'utf-8'
options.compilerArgs.addAll(['-Xlint:all', '-Werror', '-implicit:class'])
}
}
tasks {
processResources {
filesMatching('**/*.properties') {
expand([version: version, copyrightYear: copyrightYear])
}
}
}
distributions {
main {
contents {
from jar
from(projectDir) {
include 'README.md'
include 'CHANGELOG.md'
rename 'md', 'txt'
filter(FixCrLfFilter, eol: FixCrLfFilter.CrLf.newInstance('crlf'))
}
from "$projectDir/src/dist"
}
}
}
test {
useJUnitPlatform()
testLogging {
events 'passed', 'skipped', 'failed'
showExceptions = true
exceptionFormat 'full'
}
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
}
}
pitest {
junit5PluginVersion = '1.1.2'
timestampedReports = false
}
checkstyle {
toolVersion = "10.12.2"
var archive = configurations.checkstyle.filter {
it.name.startsWith("checkstyle")
}
config = resources.text.fromArchiveEntry(archive, "google_checks.xml")
configProperties 'org.checkstyle.google.suppressionfilter.config': file('config/checkstyle-suppressions.xml')
maxWarnings = 0
}
spotless {
java {
googleJavaFormat()
licenseHeaderFile 'config/LicenseHeader.txt'
}
}
#!/usr/bin/env bash
task=$1
case $task in
clean) ./gradlew clean ;;
format) ./gradlew spotlessApply ;;
test) ./gradlew test ;;
unit-tests) ./gradlew test --tests "*unit*" ;;
integration-tests) ./gradlew test --tests "*integration*" ;;
e2e-tests) ./gradlew test --tests "*e2e*" ;;
*) ./gradlew build ;;
esac
org.gradle.warning.mode = fail
lombok.addLombokGeneratedAnnotation = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment