213 lines
5.6 KiB
Groovy
213 lines
5.6 KiB
Groovy
plugins {
|
|
id 'checkstyle'
|
|
id 'java'
|
|
id 'jacoco'
|
|
id 'maven-publish'
|
|
id 'pmd'
|
|
id 'com.jfrog.bintray' version '1.8.4'
|
|
id 'com.github.ben-manes.versions' version '0.21.0'
|
|
id 'net.thauvin.erik.gradle.semver' version '1.0.0'
|
|
id 'com.github.spotbugs' version '1.7.1'
|
|
id 'org.sonarqube' version '2.7'
|
|
}
|
|
|
|
import com.github.spotbugs.SpotBugsTask
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
defaultTasks 'check'
|
|
|
|
group = 'net.thauvin.erik'
|
|
|
|
def mavenName = 'SemVer'
|
|
def mavenDescription = 'Semantic Version Annotation Processor'
|
|
def mavenUrl = 'https://github.com/ethauvin/semver'
|
|
def mavenLicense = 'The BSD 3-Clause License'
|
|
def mavenLicenseUrl = 'http://opensource.org/licenses/BSD-3-Clause'
|
|
def mavenScmCon = 'https://github.com/ethauvin/semver.git'
|
|
def mavenScmDevCon = 'git@github.com:ethauvin/semver.git'
|
|
|
|
def pkgLicenses = ['BSD 3-Clause']
|
|
def pkgIssueTrackerUrl = mavenUrl + '/issues'
|
|
def pkgLabels = ['java', 'kotlin', 'annotation', 'processor', 'semantic', 'version']
|
|
|
|
sourceCompatibility = 1.8
|
|
targetCompatibility = 1.8
|
|
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
|
|
|
repositories {
|
|
mavenLocal()
|
|
jcenter()
|
|
}
|
|
|
|
dependencies {
|
|
implementation 'com.github.spullara.mustache.java:compiler:0.9.6'
|
|
|
|
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.9.0'
|
|
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3.sb'
|
|
|
|
compileOnly 'com.github.spotbugs:spotbugs-annotations:3.1.12'
|
|
testCompileOnly 'com.github.spotbugs:spotbugs-annotations:3.1.12'
|
|
|
|
|
|
testImplementation 'org.testng:testng:6.14.3'
|
|
}
|
|
|
|
pmd {
|
|
ruleSetFiles = files("config/pmd.xml")
|
|
ruleSets = []
|
|
}
|
|
|
|
bintray {
|
|
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
|
|
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
|
publications = ['MyPublication']
|
|
dryRun = false
|
|
pkg {
|
|
repo = 'maven'
|
|
name = mavenName
|
|
licenses = pkgLicenses
|
|
desc = mavenDescription
|
|
websiteUrl = mavenUrl
|
|
issueTrackerUrl = pkgIssueTrackerUrl
|
|
vcsUrl = mavenScmCon
|
|
labels = pkgLabels
|
|
publicDownloadNumbers = true
|
|
version {
|
|
gpg { sign = true }
|
|
}
|
|
}
|
|
}
|
|
|
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
group = 'Build'
|
|
description = 'Builds an archive of the javadoc docs.'
|
|
archiveClassifier = 'javadoc'
|
|
from javadoc.destinationDir
|
|
}
|
|
|
|
task sourceJar(type: Jar) {
|
|
group = 'Build'
|
|
description = 'Builds an archive of the source code.'
|
|
archiveClassifier = 'sources'
|
|
from sourceSets.main.allSource
|
|
}
|
|
|
|
artifacts {
|
|
archives javadocJar
|
|
archives sourceJar
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
MyPublication(MavenPublication) {
|
|
from components.java
|
|
artifact sourceJar
|
|
artifact javadocJar
|
|
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'
|
|
}
|
|
}
|
|
scm {
|
|
connection = "scm:git:" + mavenScmCon
|
|
developerConnection = "scm:git:" + mavenScmDevCon
|
|
url = mavenScmCon
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
javadoc {
|
|
doFirst {
|
|
title = "$mavenDescription $project.version API"
|
|
}
|
|
options.with {
|
|
tags = ['created']
|
|
author = true
|
|
//addBooleanOption('html4', true)
|
|
links('https://docs.oracle.com/javase/8/docs/api/')
|
|
addStringOption('Xdoclint:none', '-quiet')
|
|
}
|
|
}
|
|
|
|
test {
|
|
useTestNG()
|
|
}
|
|
|
|
tasks.withType(SpotBugsTask) {
|
|
reports {
|
|
xml.enabled = false
|
|
html.enabled = true
|
|
}
|
|
excludeFilter = file("$projectDir/config/spotbugs/excludeFilter.xml")
|
|
}
|
|
|
|
tasks.withType(Checkstyle) {
|
|
reports {
|
|
xml.enabled = false
|
|
html.enabled = true
|
|
}
|
|
}
|
|
|
|
bintrayUpload {
|
|
versionName = "$project.version"
|
|
versionDesc = "version $project.version"
|
|
versionVcsTag = "$project.version"
|
|
}
|
|
|
|
task release(dependsOn: ['wrapper', 'clean', 'publishToMavenLocal']) {
|
|
group = 'Publishing'
|
|
description = 'Releases new version to local maven repository.'
|
|
doFirst {
|
|
println("Version: $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()
|
|
}
|
|
}
|
|
|
|
sonarqube {
|
|
properties {
|
|
property("sonar.projectKey", "ethauvin_semver")
|
|
property("sonar.sourceEncoding", "UTF-8")
|
|
}
|
|
}
|
|
|
|
tasks.sonarqube {
|
|
dependsOn("jacocoTestReport")
|
|
}
|