group = 'org.apache.subversion' version = '1.9.3' project.ext { release = false target = '1.5' } apply from: 'build.pom.gradle' buildscript { apply from: 'build.defaults.gradle' configurations.all { resolutionStrategy { cacheChangingModulesFor 0, 'seconds' cacheDynamicVersionsFor 0, 'seconds' } } repositories { maven { url project.ext.buildPluginRepositoryURL } } dependencies { classpath 'org.tmatesoft.build:build:0.9.9' } } task wrapper(type: Wrapper) {} configure(rootProject) { apply plugin : 'java' apply plugin : 'signing' apply plugin : 'build' targetCompatibility = target sourceCompatibility = target dependencies { testCompile 'junit:junit:3.8.2' } test.enabled = false sourceSets { main { java { srcDir 'src/subversion/subversion/bindings/javahl/src' } } test { java { srcDir 'src/subversion/subversion/bindings/javahl/tests' } } } project.ext.pythonTestsDir = file('src/subversion/subversion/tests/cmdline') jar { metaInf { from rootProject.file('LICENSE.txt') } } task sourcesJar(type: Jar) { from sourceSets.main.java.srcDirs classifier = 'sources' } task javadocJar(type: Jar, dependsOn: javadoc) { description="Builds Javadoc Jar" from "$docsDir/javadoc" classifier = 'javadoc' } task testsJar(type: Jar, dependsOn: testClasses) { appendix = 'tests' metaInf { from rootProject.file('LICENSE.txt') } from sourceSets.test.output.classesDir from (sourceSets.test.java.srcDirs) { include 'data/**' } } task testSourcesJar(type: Jar) { from sourceSets.test.java.srcDirs appendix = 'tests' classifier = 'sources' } task pythonTar(type: Tar, dependsOn: compileJava) { baseName = 'svn-python' compression = Compression.GZIP into('svn-python-tests') { from pythonTestsDir include '**/*.py' include '**/*.sh' fileMode = 0755 } into('svn-python-tests') { from pythonTestsDir exclude '**/*.py' exclude '**/*.sh' exclude '**/entries-dump' } } artifacts { maven jar, sourcesJar, javadocJar, testsJar, testSourcesJar, pythonTar } compileJava << { exec { commandLine 'src/build/build-subversion.sh' args project.rootDir.absolutePath, 'svn-binaries' } } task binariesTar(dependsOn: compileJava) << { File archiveFile = new File(distsDir, 'svn-binaries.tgz') String artifactName = 'svn-binaries' mkdir(distsDir) exec { commandLine 'tar' args '-C', buildDir.absolutePath, '-czvf', archiveFile.absolutePath, 'svn-binaries' } configurations.maven.artifacts.add(new org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact(artifactName, "tgz", "tgz", null, new Date(), archiveFile)) } assemble.dependsOn pythonTar, binariesTar task uploadApi(type: Upload) { repositories.mavenDeployer { addFilter('svn-javahl-api') { artifact, file -> return file == jar.archivePath || file == sourcesJar.archivePath || file == javadocJar.archivePath || file == new File(jar.archivePath.path + '.asc') || file == new File(sourcesJar.archivePath.path + '.asc') || file == new File(javadocJar.archivePath.path + '.asc') } pom('svn-javahl-api').artifactId = 'svn-javahl-api' pom('svn-javahl-api').version = buildVersion.baseVersion pom('svn-javahl-api').project { name pomName description pomDescription url pomUrl licenses { license { name project.licenses[0]['name'] url project.licenses[0]['url'] } } developers { developer { id project.developers[0]['id'] name project.developers[0]['name'] } } scm { url project.scm['url'] connection project.scm['connection'] } } pom('svn-javahl-api').whenConfigured { p -> p.dependencies.clear() } } } task uploadTests(type: Upload) { repositories.mavenDeployer { addFilter('svn-javahl-tests') { artifact, file -> return file == testsJar.archivePath || file == testSourcesJar.archivePath } pom('svn-javahl-tests').version = buildVersion.baseVersion pom('svn-javahl-tests').artifactId = 'svn-javahl-tests' pom('svn-javahl-tests').whenConfigured { p -> def dep = p.dependencies.find { dep-> dep.groupId == 'junit' } dep.scope = 'compile' def clazz = dep.class p.dependencies.add(createDependency(clazz, project.group, 'svn-javahl-api', 'compile', buildVersion.baseVersion)) } } } task uploadPythonTests(type: Upload) { repositories.mavenDeployer { addFilter('svn-python') { artifact, file -> return file == pythonTar.archivePath } pom('svn-python').version = buildVersion.baseVersion pom('svn-python').artifactId = 'svn-python-tests' pom('svn-python').whenConfigured { p -> p.dependencies.clear() } } } task uploadSvnBinaries(type: Upload, dependsOn: binariesTar) { repositories.mavenDeployer { addFilter('svn-binaries') { artifact, file -> return artifact.name == 'svn-binaries' } pom('svn-binaries').version = buildVersion.baseVersion pom('svn-binaries').artifactId = 'svn-binaries' pom('svn-binaries').whenConfigured { p -> p.dependencies.clear() } } } task upload(dependsOn : [uploadApi, uploadTests, uploadPythonTests, uploadSvnBinaries]) {} } def createDependency(Class clazz, String group, String id, String scope, String version) { def dep = clazz.newInstance() dep.groupId = group dep.artifactId = id dep.scope = scope dep.version = version return dep }