HttpStatus/build.gradle

187 lines
No EOL
4.1 KiB
Groovy

plugins {
id "com.jfrog.bintray" version "1.5"
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'
apply plugin: 'maven'
apply plugin: 'maven-publish'
import org.apache.tools.ant.taskdefs.condition.Os
defaultTasks 'deploy'
def deployDir = 'deploy'
def localProps = 'local.properties'
def isRelease = 'release' in gradle.startParameter.taskNames
def mavenGroupId = 'net.thauvin.erik.httpstatus'
def getVersion(isIncrement = false)
{
def propsFile = 'version.properties'
def majorKey = 'version.major'
def minorKey = 'version.minor'
def patchKey = 'version.patch'
def metaKey = 'version.buildmeta'
def preKey = 'version.prerelease'
if (isIncrement)
{
ant.propertyfile(file: propsFile) {
entry(key: patchKey,
type: 'int',
default: '-1',
operation: '+')
}
}
def p = new Properties()
file(propsFile).withInputStream { stream -> p.load(stream) }
def metadata = p.getProperty(metaKey, '')
def prerelease = p.getProperty(preKey, '')
return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') +
(prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : ''))
}
version = getVersion();
mainClassName = 'net.thauvin.erik.httpstatus.Reasons'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
repositories {
mavenCentral()
}
dependencies {
compile 'servletapi:servlet-api:+'
compile 'javax.servlet.jsp:jsp-api:+'
testCompile 'org.testng:testng:+'
}
bintray {
def p = new Properties()
file(localProps).withInputStream { stream -> p.load(stream) }
user = p.getProperty('bintrayUser');
key = p.getProperty('bintrayApiKey');
publications = ['MyPublication']
pkg {
repo = 'maven'
name = 'HttpStatus'
licenses = ['BSD 3-Clause']
desc = 'HttpStatus JSP Tag Library'
websiteUrl = 'https://github.com/ethauvin/HttpStatus'
issueTrackerUrl = 'https://github.com/ethauvin/HttpStatus/issues'
vcsUrl = 'https://github.com/ethauvin/HttpStatus.git'
labels = ['jsp', 'tag library', 'http', 'status code', 'java']
publicDownloadNumbers = true
version {
name = project.version
desc = 'Version ' + project.version
vcsTag = project.version
gpg {
sign = true
}
}
}
}
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId mavenGroupId
artifactId rootProject.name
version project.version
}
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
group = 'Build'
description = 'Builds an archive of the javadoc docs.'
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
group = 'Build'
description = 'Builds an archive of the source code.'
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar
archives sourcesJar
}
javadoc {
options.tags = ['created']
options.author = true
}
compileJava {
doFirst {
project.version = getVersion(isRelease)
}
//options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
jar {
manifest.attributes('Main-Class': mainClassName)
}
clean {
delete deployDir
}
test {
useTestNG()
}
task wrapper(type: Wrapper) {
gradleVersion = gradle.gradleVersion
}
task copyToDeploy(type: Copy) {
from(configurations.runtime) {
exclude 'servlet-api-*.jar'
exclude 'jsp-api-*.jar'
}
from jar
into deployDir
}
task deploy(dependsOn: ['build', 'copyToDeploy']) {
description = "Copies all needed files to the ${deployDir} directory."
group = "Publishing"
outputs.dir deployDir
inputs.files copyToDeploy
mustRunAfter clean
}
task release(dependsOn: ['deploy', 'wrapper']) << {
group = "Publishing"
description = "Releases new version."
isRelease = true
}
task pandoc(type: Exec) {
group = "Documentation"
def pandoc_args = ['--from', 'markdown_github', '--to', 'html5', '-s', '-o', 'README.html', 'README.md']
if (Os.isFamily(Os.FAMILY_WINDOWS))
{
commandLine(['cmd', '/c', 'pandoc'] + pandoc_args)
}
else
{
executable '/usr/local/bin/pandoc'
args pandoc_args
}
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
}