Created
December 19, 2011 23:07
build.gradle with something similar to Maven's profiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'signing' | |
version = '0.5.3-SNAPSHOT' | |
isReleaseVersion = !version.endsWith("SNAPSHOT") | |
sourceCompatibility = 1.5 | |
//targetCompatibility has the same value as sourceCompatibility by default | |
//to enable fancy test reports with ReportNG | |
isReportNGEnabled = hasProperty("reports") | |
springVersion = '3.0.4.RELEASE' | |
slf4jVersion = '1.6.1' | |
repositories { | |
mavenCentral() | |
if (isReportNGEnabled) { | |
mavenRepo urls: 'http://download.java.net/maven/2/' | |
} | |
} | |
dependencies { | |
//TODO: MZA: Make it "provided" - see: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/build.gradle?view=markup | |
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion | |
compile group: 'javax.servlet', name: 'servlet-api', version: '2.5' | |
testCompile group: 'org.springframework', name: 'spring-core', version: springVersion | |
testCompile group: 'org.springframework', name: 'spring-beans', version: springVersion | |
testCompile group: 'org.springframework', name: 'spring-test', version: springVersion | |
testCompile group: 'org.springframework', name: 'spring-context', version: springVersion | |
testCompile(group: 'org.testng', name: 'testng', version: '5.11', classifier: 'jdk15') { | |
exclude group: 'junit', name: 'junit' | |
} | |
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.8.5' | |
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '0.9.26' | |
testCompile group: 'org.slf4j', name: 'jcl-over-slf4j', version: slf4jVersion | |
if (isReportNGEnabled) { | |
testCompile 'org.uncommons:reportng:1.1.2' | |
testCompile 'org.testng:testng:5.14.2' | |
} | |
} | |
test { | |
useTestNG() | |
if (isReportNGEnabled) { | |
options { | |
listeners << 'org.uncommons.reportng.HTMLReporter' | |
listeners << 'org.uncommons.reportng.JUnitXMLReporter' | |
} | |
useDefaultListeners = false | |
workingDir = 'build/' | |
} | |
} | |
//Generate source and javadoc JARs | |
//TODO: MZA: Change to generate additional jars only when needed (e.g. dist, release) | |
task sourcesJar(type: Jar, dependsOn: classes) { | |
classifier = 'sources' | |
from sourceSets.main.allSource | |
} | |
task javadocJar(type: Jar, dependsOn: javadoc) { | |
classifier = 'javadoc' | |
from javadoc.destinationDir | |
} | |
artifacts { | |
archives sourcesJar | |
archives javadocJar | |
} | |
//TODO: MZA: animal-sniffer gradle plugin seems to be not available - any workaround? | |
//Signing | |
//TODO: MZA: Problem with "checksum mismatch at 0 of 20" (wrong password?) when using gragle.properties | |
project['signing.keyId'] = "24875D73" | |
project['signing.password'] = "gradle" | |
project['signing.secretKeyRingFile'] = file("secKeyRingFile.gpg").absolutePath | |
signing { | |
if (isReleaseVersion) { | |
sign configurations.archives | |
} | |
} | |
import org.gradle.plugins.signing.Sign | |
gradle.taskGraph.whenReady { taskGraph -> | |
if (taskGraph.allTasks.any { it instanceof Sign }) { | |
// Use Java 6's console to read from the console - for interactive release | |
Console console = System.console() | |
console.printf "\n\nCreated packages will be sign.\n" | |
allprojects*.setProperty("signing.password", console.readPassword("Enter password for PGP private key with ID " + project['signing.keyId'] + ": ")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment