apply plugin: 'java' apply plugin: 'maven' defaultTasks 'run' repositories { mavenCentral() flatDir dirs: ( new File(System.properties['user.home'], 'webapp-base/local/repos')) } dependencies { compile( [group: 'commons-logging', name: 'commons-logging', version: '1.1.1'] ) { transitive = false } runtime( [group: 'commons-logging', name: 'commons-logging', version: '1.1.1'], [name: 'org.springframework.core', version: '3.1.0.M1'] //) { transitive = false } Why the hell doesn't this work? ) } task(rtjars, type: Copy).from(configurations.runtime.files).into(libsDir) task setman (dependsOn: rtjars) << { println '================================' def deplibs = [] configurations.runtime.files.collect { deplibs << it.name } println 'DEPLIBS: ' + deplibs.join(' ') jar { manifest { attributes( 'main-class': 'pkga.Main', 'class-path': deplibs.join(' ') ) } } } jar.dependsOn << setman task run (dependsOn: assemble) << { println configurations.runtime.files javaexec { main = '-jar'; args = [jar.archivePath, 'par1', 'par2'] } } /* uploadArchives { repositories.mavenDeployer { repository(url: "file://tmp/fake-repos/") } } */ // Required by uploadArchives: group = 'grpId' organization = 'Me' /* // Following, pasted directly from Gradle user guide, has no effect // upon either 'uploadArchives' nor explicit POM writing (explictly as shown // in the "writeNewPom" example in Gradle use guide): configure(install.repositories.mavenInstaller) { pom.project { version '1.0Maven' artifactId 'myName' } } // The following, as touted at // http://linkedjava.blogspot.com/2011/06/gradle-build-to-create-pom.html , // added inside the 'pom.project' block above, also has no effect: //groupId 'your.group.id' */ /* // Following, pasted directly from, // http://www.mail-archive.com/user@gradle.codehaus.org/msg05389.html , // has no effect upon either 'uploadArchives' nor explicit POM writing. configure(install.repositories.mavenInstaller) { pom.project { name 'GroovyCSV' // packaging 'jar' description 'Library for parsing csv in Groovy' url 'http://github.com/xlson/groovycsv' inceptionYear '2010' scm { url 'http://github.com/xlson/groovycsv' connection 'http://github.com/xlson/groovycsv' } 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 'donald' name 'donald duck' email 'don...@duck.org' url 'http://www.donaldduck.org' organization = 'acme' // <-- note we use assignment here organizationUrl 'http://acme.org' roles { role 'architect' } timezone '-6' } } } // Mess with the generated xml to add the packaging back in // This could probably be cleaner, if I knew the Groovy xml classes better pom.withXml { XmlProvider xmlProvider -> def xml = xmlProvider.asString() def pomXml = new XmlParser().parse( new ByteArrayInputStream(xml.toString().bytes)) pomXml.version[0] + { packaging('jar') } def newXml = new StringWriter() def printer = new XmlNodePrinter(new PrintWriter(newXml)) printer.preserveWhitespace = true printer.print(pomXml) xml.setLength(0) xml.append(newXml.toString()) } } */ // From http://blog.andresteingress.com/2011/01/14/using-gradle-in-practice/ uploadArchives { repositories.mavenDeployer { configuration = configurations.archives // Blaine modifies to use his own repository //repository(url: "file://tmp/fake-repos/") //repository(mavenCentral()) //repository(flatDir(name: 'fileRepo', dirs: '/tmp/fakerepos')) repositories { flatDir(name: 'fileRepo', dirs: '/tmp/fakerepos') } pom.project { name 'GContracts - Contract-Oriented Programming for Groovy' packaging 'jar' description 'GContracts provides annotations to implement interface contracts aka design by contract in Groovy classes.' url 'http://github.com/andresteingress/gcontracts' inceptionYear '2010' scm { url 'scm:git:file:///Users/andre/Development/gcontracts' connection 'scm:git:file:///Users/andre/Development/gcontracts' } licenses { license { name 'BSD License' comments """ Blaine shortens... """ distribution 'repo' } } developers { developer { id 'andre' name 'Andre Steingress' email 'me@andresteingress.com' url 'http://www.andresteingress.com' // see: http://www.mail-archive.com/user@gradle.codehaus.org/msg05368.html // organization 'Andre Steingress' // organizationUrl 'http://www.andresteingress.com' roles{ role 'Developer' } timezone '+1' } } } } } task writeNewPom << { pom { project { inceptionYear '2008' licenses { license { name 'The Apache Software License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' distribution 'repo' } } } }.writeTo("/tmp/newpom.xml") }