230 lines
5.7 KiB
Groovy
230 lines
5.7 KiB
Groovy
plugins {
|
|
id 'checkstyle'
|
|
id 'java'
|
|
id 'jacoco'
|
|
id 'idea'
|
|
id 'application'
|
|
id 'maven'
|
|
id 'maven-publish'
|
|
id 'signing'
|
|
id 'pmd'
|
|
id 'com.github.ben-manes.versions' version '0.38.0'
|
|
id 'net.thauvin.erik.gradle.semver' version '1.0.4'
|
|
id 'com.github.spotbugs' version '4.7.0'
|
|
id 'org.sonarqube' version '3.1.1'
|
|
}
|
|
|
|
import com.github.spotbugs.snom.SpotBugsTask
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
defaultTasks 'deploy'
|
|
|
|
def deployDir = 'deploy'
|
|
|
|
def mavenName = 'HttpStatus'
|
|
def mavenDescription = 'HttpStatus JSP Tag Library'
|
|
def mavenUrl = 'https://github.com/ethauvin/HttpStatus'
|
|
def mavenLicense = 'The BSD 3-Clause License'
|
|
def mavenLicenseUrl = 'http://opensource.org/licenses/BSD-3-Clause'
|
|
def mavenScmCon = 'https://github.com/ethauvin/HttpStatus.git'
|
|
def mavenScmDevCon = 'git@github.com:ethauvin/HttpStatus.git'
|
|
|
|
def pkgLicenses = ['BSD 3-Clause']
|
|
def pkgIssueTrackerUrl = mavenUrl + '/issues'
|
|
def pkgLabels = ['jsp', 'tag library', 'http', 'status code', 'java']
|
|
|
|
group = 'net.thauvin.erik.httpstatus'
|
|
|
|
mainClassName = 'net.thauvin.erik.httpstatus.Reasons'
|
|
|
|
ext {
|
|
versions = [
|
|
spotbugs: '4.2.2'
|
|
]
|
|
}
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
implementation 'javax.servlet:javax.servlet-api:4.0.1'
|
|
implementation 'javax.servlet.jsp:jsp-api:2.2.1-b03'
|
|
implementation 'javax.el:javax.el-api:3.0.1-b06'
|
|
|
|
|
|
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
|
|
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"
|
|
|
|
testImplementation 'org.testng:testng:7.4.0'
|
|
}
|
|
|
|
tasks.withType(JavaCompile) {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
|
|
java {
|
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
targetCompatibility = JavaVersion.VERSION_1_8
|
|
withJavadocJar()
|
|
withSourcesJar()
|
|
}
|
|
|
|
javadoc {
|
|
doFirst {
|
|
title = mavenDescription + ' ' + project.version
|
|
}
|
|
options.source = 8
|
|
options.tags = ['created']
|
|
options.author = true
|
|
options.links('https://docs.oracle.com/javase/8/docs/api/')
|
|
options.addStringOption('Xdoclint:none', '-quiet')
|
|
}
|
|
|
|
jar {
|
|
manifest.attributes('Main-Class': mainClassName)
|
|
}
|
|
|
|
clean {
|
|
doLast {
|
|
project.delete(fileTree(deployDir))
|
|
}
|
|
}
|
|
|
|
test {
|
|
useTestNG()
|
|
}
|
|
|
|
spotbugs {
|
|
toolVersion = versions.spotbugs
|
|
excludeFilter = file("$projectDir/config/spotbugs/excludeFilter.xml")
|
|
}
|
|
|
|
pmd {
|
|
ignoreFailures = true
|
|
ruleSets = []
|
|
ruleSetFiles = files("${projectDir}/config/pmd.xml")
|
|
consoleOutput = true
|
|
}
|
|
|
|
tasks.withType(Checkstyle) {
|
|
reports {
|
|
xml.enabled = false
|
|
html.enabled = true
|
|
}
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
from components.java
|
|
groupId project.group
|
|
artifactId rootProject.name
|
|
|
|
pom {
|
|
name = mavenName
|
|
description = mavenDescription
|
|
url = mavenUrl
|
|
licenses {
|
|
license {
|
|
name = mavenLicense
|
|
url = mavenLicenseUrl
|
|
distribution = 'repo'
|
|
}
|
|
}
|
|
developers {
|
|
developer {
|
|
id = 'ethauvin'
|
|
name = 'Erik C. Thauvin'
|
|
email = 'erik@thauvin.net'
|
|
url = 'https://erik.thauvin.net/'
|
|
}
|
|
}
|
|
scm {
|
|
connection = 'scm:git:' + mavenScmCon
|
|
developerConnection = 'scm:git:' + mavenScmDevCon
|
|
url = mavenScmCon
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
uploadArchives {
|
|
repositories.mavenDeployer {
|
|
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
|
|
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
|
|
authentication(userName: ossrhUsername, password: ossrhPassword)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
signing {
|
|
useGpgCmd()
|
|
sign publishing.publications.mavenJava
|
|
}
|
|
|
|
task copyToDeploy(type: Copy) {
|
|
from(configurations.runtime) {
|
|
exclude 'javax.servlet-api-*.jar'
|
|
exclude 'jsp-api-*.jar'
|
|
}
|
|
from jar
|
|
into deployDir
|
|
}
|
|
|
|
task deploy(dependsOn: ['clean', 'build', 'copyToDeploy']) {
|
|
description = 'Copies all needed files to the ${deployDir} directory.'
|
|
group = 'Publishing'
|
|
outputs.dir deployDir
|
|
inputs.files copyToDeploy
|
|
mustRunAfter clean
|
|
}
|
|
|
|
task release(dependsOn: ['wrapper', 'deploy', 'pandoc', 'publishToMavenLocal']) {
|
|
group = 'Publishing'
|
|
description = 'Releases new version.'
|
|
}
|
|
|
|
task pandoc(type: Exec) {
|
|
group = 'Documentation'
|
|
def pandoc_args = ['--from', 'gfm',
|
|
'--to', 'html5',
|
|
'--metadata', "pagetitle=$mavenDescription",
|
|
'-s',
|
|
'-c', 'github-pandoc.css',
|
|
'-o', 'docs/README.html',
|
|
'README.md']
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
commandLine(['cmd', '/c', 'pandoc'] + pandoc_args)
|
|
} else {
|
|
executable 'pandoc'
|
|
args pandoc_args
|
|
}
|
|
standardOutput = new ByteArrayOutputStream()
|
|
ext.output = {
|
|
return standardOutput.toString()
|
|
}
|
|
}
|
|
|
|
jacocoTestReport {
|
|
reports {
|
|
xml.enabled true
|
|
}
|
|
}
|
|
|
|
sonarqube {
|
|
properties {
|
|
property("sonar.projectKey", "ethauvin_HttpStatus")
|
|
property("sonar.sourceEncoding", "UTF-8")
|
|
}
|
|
}
|
|
|
|
tasks.sonarqube {
|
|
dependsOn("jacocoTestReport")
|
|
}
|