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 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'] 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 'javax.servlet:javax.servlet-api:3.1.0' compile 'javax.servlet.jsp:jsp-api:2.2' testCompile 'org.testng:testng:6.9.10' } 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 = mavenName licenses = pkgLicenses desc = mavenDescription websiteUrl = mavenUrl issueTrackerUrl = pkgIssueTrackerUrl vcsUrl = mavenScmCon labels = pkgLabels publicDownloadNumbers = true version { name = project.version desc = 'Version ' + project.version vcsTag = project.version gpg { sign = true } } } } def pomConfig = { 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 } } publishing { publications { MyPublication(MavenPublication) { from components.java artifact sourcesJar artifact javadocJar groupId mavenGroupId artifactId rootProject.name version project.version pom.withXml { def root = asNode() root.appendNode('name', mavenName) root.appendNode('description', mavenDescription) root.appendNode('url', mavenUrl) root.children().last() + pomConfig } } } } 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 'javax.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() } }