mobibot/build.gradle
Erik C. Thauvin 2c78d713eb Using Jacoco snapshot.
Using src/main/java and src/main/kotlin.
2021-04-28 19:50:56 -07:00

223 lines
5.3 KiB
Groovy

plugins {
id 'application'
id 'checkstyle'
id 'com.github.ben-manes.versions' version '0.38.0'
id 'com.github.spotbugs' version '4.7.0'
id 'idea'
id 'io.gitlab.arturbosch.detekt' version '1.16.0'
id 'jacoco'
id 'java'
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
id 'org.jetbrains.kotlin.jvm' version '1.5.0'
id 'org.jetbrains.kotlin.kapt' version '1.5.0'
id 'org.sonarqube' version '3.1.1'
id 'pmd'
}
defaultTasks 'deploy'
final def packageName = 'net.thauvin.erik.mobibot'
final def deployDir = 'deploy'
final def semverProcessor = "net.thauvin.erik:semver:1.2.0"
ext.versions = [
log4j : '2.14.1',
pmd : '6.34.0',
spotbugs: '4.2.3'
]
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
kapt(semverProcessor)
compileOnly(semverProcessor)
implementation 'pircbot:pircbot:1.5.0'
compileOnly 'pircbot:pircbot:1.5.0:sources'
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation 'com.rometools:rome:1.15.0'
implementation 'commons-cli:commons-cli:1.4'
implementation 'commons-net:commons-net:3.8.0'
implementation 'net.aksingh:owm-japis:2.5.3.0'
implementation 'net.objecthunter:exp4j:0.4.8'
implementation 'net.thauvin.erik:pinboard-poster:1.0.3'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-RC'
implementation 'org.json:json:20210307'
implementation 'org.jsoup:jsoup:1.13.1'
implementation 'org.twitter4j:twitter4j-core:4.0.7'
implementation "org.apache.logging.log4j:log4j-api:$versions.log4j"
implementation "org.apache.logging.log4j:log4j-core:$versions.log4j"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:$versions.log4j"
compileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs"
testCompileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs"
testImplementation 'org.assertj:assertj-core:3.19.0'
testImplementation 'org.testng:testng:7.4.0'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
spotbugsPlugins 'com.mebigfatguy.sb-contrib:sb-contrib:7.4.7'
}
test {
useTestNG() {
options.suites('src/test/resources/testng.xml')
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kapt {
arguments {
arg("semver.project.dir", projectDir)
}
}
application {
mainClassName = packageName + '.Mobibot'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
compileJava {
dependsOn('incrementBuildMeta')
options.compilerArgs += ['-Xlint:unchecked', '-Xlint:deprecation']
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = '11'
}
}
spotbugs {
toolVersion.set("$versions.spotbugs")
excludeFilter.set(file("$projectDir/config/spotbugs/excludeFilter.xml"))
tasks.spotbugsMain {
reports.create("html") {
enabled = true
}
}
tasks.spotbugsTest {
reports.create("html") {
enabled = true
}
}
}
pmd {
toolVersion = versions.pmd
ignoreFailures = true
ruleSets = []
ruleSetFiles = files("${projectDir}/config/pmd.xml")
consoleOutput = true
}
detekt {
ignoreFailures = true // Baseline is incomplete and fails on various CIs, not sure why.
baseline = file("${projectDir}/config/detekt/baseline.xml")
}
javadoc {
options.tags = ['created']
options.author = true
options.links('http://www.jibble.org/javadocs/pircbot/', 'http://docs.oracle.com/javase/8/docs/api/')
}
jar {
manifest.attributes('Main-Class': mainClassName,
'Class-Path': '. ./lib/' + configurations.runtimeClasspath.collect { it.getName() }.join(' ./lib/'))
archiveVersion.set("")
}
clean {
doLast {
project.delete(fileTree(deployDir))
}
}
run {
args '-d'
}
incrementBuildMeta {
doFirst {
if (!System.getenv('CI')) {
buildMeta = sprintf("%03d", (buildMeta as Integer) + 1)
} else {
println "No increment on CIs."
}
}
}
sonarqube {
properties {
property "sonar.projectKey", "ethauvin_mobibot"
}
}
jacoco {
toolVersion = '0.8.7-SNAPSHOT'
}
jacocoTestReport {
dependsOn test
reports {
html.enabled = true
xml.enabled = true
}
}
tasks.withType(Checkstyle) {
reports {
xml.enabled = false
html.enabled = true
}
}
tasks.sonarqube {
dependsOn("jacocoTestReport")
}
task copyToDeploy(type: Copy) {
from('properties')
from jar
into deployDir
}
task copyToDeployLib(type: Copy) {
from(configurations.runtimeClasspath) {
exclude 'annotations-*.jar'
}
into deployDir + '/lib'
}
task deploy(dependsOn: ['clean', 'build', 'jar']) {
description = 'Copies all needed files to the ${deployDir} directory.'
group = 'Publishing'
outputs.dir deployDir
inputs.files copyToDeploy
inputs.files copyToDeployLib
doLast {
file(deployDir + '/logs').mkdir()
}
mustRunAfter clean
}
task release(dependsOn: ['wrapper', 'deploy']) {
group = 'Publishing'
description = 'Releases new version.'
}