Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
171 lines (144 sloc) 4.91 KB
#!groovy
// The above triggers groovy syntax highlighting in vim
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
sourceCompatibility = 1.5
targetCompatibility = 1.5
group = 'net.saliman'
archivesBaseName = 'groovy-liquibase-dsl'
version = '1.0.2'
ext.isSnapshot = version.endsWith('SNAPSHOT')
if ( isSnapshot ) {
println 'using snapshot'
ext.mavenCentralUploadUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
} else {
println 'using staging'
ext.mavenCentralUploadUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
configurations {
archives
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compile 'org.codehaus.groovy:groovy:2.4.1'
compile 'org.codehaus.groovy:groovy-sql:2.4.1'
compile 'org.liquibase:liquibase-core:3.3.2'
testCompile 'junit:junit:4.12'
testRuntime 'com.h2database:h2:1.4.185'
archives 'org.apache.maven.wagon:wagon-ssh:2.8'
archives 'org.apache.maven.wagon:wagon-ssh-external:2.8'
}
task sourceJar(type: Jar) {
description = 'An archive of the source code for Maven Central'
classifier = 'sources'
from sourceSets.main.allSource
}
task groovydocJar(type: Jar, dependsOn: groovydoc) {
description = 'An archive of the GroovyDocs for Maven Central'
classifier = 'javadoc'
from groovydoc
}
artifacts {
archives jar, groovydocJar, sourceJar
}
signing {
sign configurations.archives
}
// Only *Require* signing if we are uploading a non snapshot version. If we
// do need to sign, make sure we've got the properties we need to do the
// signing.
import org.gradle.plugins.signing.Sign
gradle.taskGraph.whenReady { taskGraph ->
tasks.withType(org.gradle.plugins.signing.Sign).all {
required = taskGraph.hasTask(':uploadArchives') && !isSnapshot
if ( required ) {
// Use Java's console to read from the console (no good for a CI
// environment)
Console console = System.console()
console.printf '\n\nWe have to sign some things in this build...\n\n'
if ( !project.hasProperty('signing.keyId') ) {
def id = console.readLine('PGP Public Key Id: ')
allprojects { ext.'signing.keyId' = id }
}
if ( !project.hasProperty('signing.secretKeyRingFile') ) {
def file = console.readLine('PGP Secret Key Ring File (absolute path): ')
allprojects { ext.'signing.secretKeyRingFile' = file }
}
if ( !project.hasProperty('signing.password') ) {
def password = console.readPassword('PGP Private Key Password: ')
allprojects { ext.'signing.password' = password }
}
console.printf '\nThanks.\n\n'
}
}
}
uploadArchives {
// We can't use taskGraph.whenReady because it doesn't resolve until after
// configuration. The startParameter is not as good, but it probably
// good enough for our purposes.
if ( gradle.startParameter.taskNames.contains('uploadArchives') ) {
// Use Java's console to read from the console (no good for a CI
// environment)
Console console = System.console()
console.printf '\n\nWe have to upload some things in this build...\n\n'
if ( !project.hasProperty('mavenCentralUsername') ) {
def mavenCentralUsername = console.readLine('Maven Central Username: ')
allprojects { ext.'mavenCentralUsername' = mavenCentralUsername }
}
if ( !project.hasProperty('mavenCentralPassword') ) {
def mavenCentralPassword = console.readLine('Maven Central Password: ')
allprojects { ext.'mavenCentralPassword' = mavenCentralPassword }
}
repositories {
mavenDeployer {
if ( signing.signatory ) {
beforeDeployment { signing.signPom(it) }
}
configuration = configurations.archives
//repository(url: 'file://$buildDir/m2repo')
repository(url: mavenCentralUploadUrl) {
authentication(userName: mavenCentralUsername,
password: mavenCentralPassword)
releases(updatePolicy: 'always')
snapshots(updatePolicy: 'always')
}
pom.project(pomConfiguration)
}
}
}
}
def getPomConfiguration() {
return {
name('Groovy Liquibase DSL')
description('A Groovy-based DSL for the Liquibase database refactoring tool.')
url('https://github.com/tlberglund/groovy-liquibase')
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id('tlberglund')
name('Tim Berglund')
email('tlberglund@gmail.com')
}
developer {
id 'stevesaliman'
name 'Steven C. Saliman'
email 'support@saliman.net'
}
}
scm {
connection('scm:https://tlberglund@github.com/tlberglund/groovy-liquibase')
developerConnection('scm:git@github.com:tlberglund/groovy-liquibase.git')
url('https://github.com/tlberglund/groovy-liquibase')
}
}
}