mobibot/build.gradle

219 lines
5.2 KiB
Groovy

plugins {
id 'application'
id 'checkstyle'
id 'com.github.ben-manes.versions' version '0.28.0'
id 'com.github.spotbugs' version '4.4.4'
id 'idea'
id 'io.gitlab.arturbosch.detekt' version '1.10.0'
id 'jacoco'
id 'java'
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
id 'org.jetbrains.kotlin.jvm' version '1.3.72'
id 'org.sonarqube' version '3.0'
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"
mainClassName = packageName + '.Mobibot'
ext.versions = [
log4j : '2.13.3',
spotbugs: '4.0.6'
]
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
annotationProcessor semverProcessor
compileOnly semverProcessor
implementation 'pircbot:pircbot:1.5.0'
compileOnly 'pircbot:pircbot:1.5.0:sources'
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"
implementation 'org.apache.commons:commons-lang3:3.10'
//implementation 'org.apache.commons:commons-text:1.8'
implementation 'commons-cli:commons-cli:1.4'
implementation 'commons-net:commons-net:3.6'
//implementation 'com.squareup.okhttp3:okhttp:4.7.2'
implementation 'com.rometools:rome:1.14.1'
implementation 'org.json:json:20200518'
implementation 'org.jsoup:jsoup:1.13.1'
implementation 'net.objecthunter:exp4j:0.4.8'
implementation 'org.twitter4j:twitter4j-core:4.0.7'
implementation 'net.thauvin.erik:pinboard-poster:1.0.1'
implementation 'net.aksingh:owm-japis:2.5.3.0'
implementation platform('org.jetbrains.kotlin:kotlin-bom')
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
testImplementation 'org.testng:testng:7.2.0'
testImplementation 'org.assertj:assertj-core:3.16.1'
testImplementation 'org.mockito:mockito-core:3.4.0'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1'
spotbugsPlugins 'com.mebigfatguy.sb-contrib:sb-contrib:7.4.7'
compileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs"
testCompileOnly "com.github.spotbugs:spotbugs-annotations:$versions.spotbugs"
}
test {
useTestNG() {
options.suites('src/test/resources/testng.xml')
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileKotlin {
kotlinOptions {
jvmTarget = '11'
}
}
spotbugs {
toolVersion.set("$versions.spotbugs")
}
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
reports {
xml.enabled = true
html.enabled = true
}
excludeFilter.set(file("$projectDir/config/spotbugs/excludeFilter.xml"))
}
pmd {
toolVersion = '6.25.0'
ignoreFailures = true
ruleSets = []
ruleSetFiles = files("${projectDir}/config/pmd.xml")
consoleOutput = true
}
detekt {
baseline = file("detekt-baseline.xml")
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.annotationProcessorGeneratedSourcesDirectory = file("${projectDir}/src/generated/java")
options.compilerArgs += ["-Asemver.project.dir=$projectDir"]
}
compileJava {
dependsOn('incrementBuildMeta')
options.compilerArgs += ['-Xlint:unchecked', '-Xlint:deprecation']
}
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 '--v'
}
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.5'
}
jacocoTestReport {
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.'
}