From c0de09e838282fa708125570971bdca15f905d06 Mon Sep 17 00:00:00 2001 From: Rocky Madden Date: Mon, 20 May 2013 16:30:52 -0600 Subject: Changed subproject folder naming. Updated Scala to 2.10.1. --- stringmetric-cli/build.gradle | 167 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100755 stringmetric-cli/build.gradle (limited to 'stringmetric-cli/build.gradle') diff --git a/stringmetric-cli/build.gradle b/stringmetric-cli/build.gradle new file mode 100755 index 0000000..c0d1b89 --- /dev/null +++ b/stringmetric-cli/build.gradle @@ -0,0 +1,167 @@ +apply plugin: 'maven' +apply plugin: 'signing' + +def isMavenDeployable = hasProperty('mavenRepositoryUrl') && hasProperty('mavenRepositoryUsername') && hasProperty('mavenRepositoryPassword') + +evaluationDependsOn(':stringmetric-core') + +dependencies { + compile project(':stringmetric-core') + + testCompile project(':stringmetric-core').sourceSets.test.output +} + +sourceSets { + main { + output.resourcesDir "${project.buildDir}/classes/main" + + java { + srcDir 'source/core/java' + } + resources { + srcDir 'source/core/resource' + } + scala { + srcDir 'source/core/scala' + } + } + test { + output.resourcesDir "${project.buildDir}/classes/test" + + java { + srcDir 'source/test/java' + } + resources { + srcDir 'source/test/resource' + } + scala { + srcDir 'source/test/scala' + } + } +} + +task tar(description: 'Assembles a compressed tar archive of source files.', dependsOn: [':stringmetric-cli:jar', ':stringmetric-core:jar']) { + ext.sourcePath = "${project.projectDir}/source/core/scala" + ext.outputPath = "${project.buildDir}" + ext.workingPath = "${project.buildDir}/${project.name}" + + inputs.dir new File(sourcePath) + outputs.dir new File(outputPath, 'generated') + outputs.upToDateWhen { + new File(workingPath).isDirectory() + } + + doLast { + // Clean up working directory and tar from last execution, should they exist. + ant.delete(dir: workingPath, failOnError: false) + ant.delete(file: "${project.buildDir}/${project.name}.tar.gz", failOnError: false) + + // Create project working directory. + ant.mkdir(dir: workingPath) + + // Create scalascript header file. + ant.echo(file: "${workingPath}/scalascript.sh", message: '#!/bin/bash\ndir="`dirname \\"$0\\"`"\ndir="`( cd \\"$dir\\" && pwd )`"\ncp=`echo $dir/*.jar|sed \'s/ /:/g\'`\nexec scala -classpath "$cp" -savecompiled "$0" "$@"\n!#\n//') + + // Copy source files to working directory. + ant.copy(toDir: workingPath, force: true, overwrite: true) { + fileset(dir: sourcePath) { + exclude(name: '**/cli/*.scala') + exclude(name: '**/package.scala') + } + filterchain { + concatfilter(prepend: "${workingPath}/scalascript.sh") + } + } + + // Delete scalascript header file. + ant.delete(file: "${workingPath}/scalascript.sh") + + // Flatten and remove file extension. + ant.move(toDir: workingPath) { + fileset(dir: workingPath) + chainedmapper { + mapper(type: 'flatten') + mapper(from: '*.scala', to: '*', type: 'glob') + } + } + + // Clean up emtpy folder(s) from flatten. + ant.delete(dir: "${workingPath}/org", includeEmptyDirs: true) + + // Copy project jars into place. + ant.copy(toDir: workingPath, force: true, overwrite: true) { + fileset(dir: "${project.buildDir}/libs") + } + ant.copy(toDir: workingPath, force: true, overwrite: true) { + fileset(dir: "${project(':stringmetric-core').buildDir}/libs") + } + + // Assemble compressed tar. + ant.tar(compression: 'gzip', destFile: "${project.buildDir}/${project.name}.tar.gz") { + tarfileset(dir: workingPath, fileMode: 755, prefix: project.name) + } + } +} + +if (isMavenDeployable) { + signing { + sign configurations.archives + } + + task scaladocJar(type: Jar, dependsOn: scaladoc) { + classifier = 'javadoc' + from "${project.buildDir}/docs/scaladoc" + } + + task sourceJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } + + artifacts { + archives jar + archives scaladocJar + archives sourceJar + } + + uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: mavenRepositoryUrl) { + authentication(userName: mavenRepositoryUsername, password: mavenRepositoryPassword) + } + + pom.project { + description "${parent.project.description}" + groupId "${parent.project.group}" + name "${project.name}" + packaging 'jar' + url "${parent.project.url}" + version "${parent.project.version}" + + developers { + developer { + id 'rockymadden' + name 'Rocky Madden' + } + } + + licenses { + license { + name 'Apache License v2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution 'repo' + } + } + + scm { + url "${parent.project.scm}" + connection "${parent.project.scm}" + } + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3