X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=blobdiff_plain;f=build.gradle;h=26ff9ba74b6d0990113f8bc4660cd9943672547b;hp=0f42ccc573ba80d32d021178f2721077bf56397b;hb=04ebd27427c10cd4ce8b3c579a444b5feeaf96e8;hpb=6c831a59566c0a5e8cce277f47e990bbc6b3babd diff --git a/build.gradle b/build.gradle index 0f42ccc..26ff9ba 100644 --- a/build.gradle +++ b/build.gradle @@ -7,98 +7,38 @@ repositories { mavenCentral() } -dependencies { - testImplementation "junit:junit:4.12" -} - -sourceSets { - annotations { - java.srcDirs = ["src/annotations"] - java.outputDir = file("${buildDir}/annotations") - } - main { - java.srcDirs = ["src/main"] - java.outputDir = file("${buildDir}/main") - compileClasspath += sourceSets.annotations.output - } - examples { - java.srcDirs = ["src/examples"] - java.outputDir = file("${buildDir}/examples") - compileClasspath += sourceSets.main.output - } - classes { - java.srcDirs = ["src/classes"] - java.outputDir = file("${buildDir}/classes") - compileClasspath += sourceSets.main.output + sourceSets.annotations.output - } - peers { - java.srcDirs = ["src/peers"] - java.outputDir = file("${buildDir}/peers") - compileClasspath += sourceSets.main.output + sourceSets.annotations.output - } - test { - java.srcDirs = ["src/tests"] - java.outputDir = file("${buildDir}/tests") - compileClasspath += sourceSets.annotations.output + sourceSets.classes.output + sourceSets.peers.output - runtimeClasspath += compileClasspath - } -} - -task generateVersion { - group = "JPF Resources" - description = "Generates the .version file with the current revision hash" - doLast { - def revision = "git rev-parse HEAD".execute().text - new File(".version").withWriter("utf-8") { writer -> - writer.writeLine revision +buildscript { + repositories { + maven { + url "https://plugins.gradle.org/m2/" } } -} - -task buildInfo { - group = "JPF Resources" - description = "Creates build info properties." - doLast { - - // Must fail if there are uncommitted changes - def status = "git status --short".execute().text.trim() - if (!status.isEmpty()) { - throw new GradleException("There are uncomitted changes:\n " + status) - } - Properties info = new Properties() - - def revision = "git rev-parse --short HEAD".execute().text.trim() - def userName = ["git", "log", "-1", "--format=%an <%ae>"].execute().text.trim() - def date = "git log -1 --format=%ci".execute().text.trim() - - info.setProperty("revision", revision) - info.setProperty("date", date) - info.setProperty("author", userName) - info.setProperty("os.arch", System.getProperty("os.arch")) - info.setProperty("os.name", System.getProperty("os.name")) - info.setProperty("user.country", System.getProperty("user.country")) - info.setProperty("java.version", System.getProperty("java.version")) - - def writer = new File("build.properties").newWriter("utf-8") - info.store(writer, "JPF core build info") - writer.close() + dependencies { + classpath "gradle.plugin.com.palantir.gradle.gitversion:gradle-git-version:0.11.0" } } -task copyResources(type: Copy) { - group = "JPF Resources" - description = "Copies .version and build.properties files to the build directory." - - dependsOn buildInfo - dependsOn generateVersion +dependencies { + testImplementation "junit:junit:4.12" +} - from "build.properties" - into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf" +apply plugin: "com.palantir.git-version" +version gitVersion() +def gitDetails = versionDetails() - from ".version" - into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf" +ext.manifestCommonAttrbutes = manifest { + attributes( + "Built-By": System.getProperty("user.name"), + "Implementation-Vendor": "NASA Ames Research Center", + "Specification-Version": gitDetails.lastTag, + "Implementation-Version": gitDetails.gitHashFull + ) } +apply from: "gradle/ide-support.gradle" +apply from: "gradle/distribution.gradle" +apply from: "gradle/source-sets.gradle" +apply from: "gradle/build-resources.gradle" task compile { group = "JPF Build" @@ -111,59 +51,12 @@ task compile { dependsOn compileExamplesJava } -task srcDist(type: Zip) { - group = "JPF Build" - description = "Builds the source distribution" - - baseName = project.name - version = "git rev-parse --short HEAD".execute().text.trim() - classifier = "src" - extension = "zip" - - destinationDir = buildDir - includeEmptyDirs = false - - from projectDir - include "build.gradle" - include "settings.gradle" - include "gradlew" - include "gradlew.bat" - include "gradle/**/*" - include "nbproject/**/*" - include "eclipse/**/*" - include "src/**/*" - include "bin/**/*" - include "jpf.properties" - include "build.properties" - include "LICENSE-2.0.txt" - include "README.md" -} - -task dist(type: Zip) { - group = "JPF Build" - description = "Builds binary distribution" - - baseName = project.name - version = "git rev-parse --short HEAD".execute().text.trim() - extension = "zip" - - destinationDir = buildDir - includeEmptyDirs = false - - from projectDir - include "jpf.properties" - include "build.properties" - include "bin/**/*" - include "lib/**/*" - include "${buildDir.name}/**/*.jar" -} - -task jpfClassesJar(type: Jar) { +task createJpfClassesJar(type: Jar) { archiveName = "jpf-classes.jar" destinationDir = file("${buildDir}") - description = "Creates the ${archiveName} file." group = "JPF Jars" + description = "Creates the ${archiveName} file." dependsOn compile dependsOn copyResources @@ -180,12 +73,12 @@ task jpfClassesJar(type: Jar) { } } -task jpfJar(type: Jar) { +task createJpfJar(type: Jar) { archiveName = "jpf.jar" destinationDir = file("${buildDir}") - description = "Creates the ${archiveName} file." group = "JPF Jars" + description = "Creates the ${archiveName} file." dependsOn compile dependsOn copyResources @@ -198,21 +91,17 @@ task jpfJar(type: Jar) { } manifest { - attributes( - "Built-By": System.getProperty("user.name"), - "Implementation-Vendor": "NASA Ames Research Center", - "Implementation-Title": "Java Pathfinder core system", - "Implementation-Version": "1234" //FIXME - ) + attributes "Implementation-Title": "Java Pathfinder core system" + from manifestCommonAttrbutes } } -task annotationsJar(type: Jar) { +task createAnnotationsJar(type: Jar) { archiveName = "jpf-annotations.jar" destinationDir = file("${buildDir}") - description = "Creates the ${archiveName} file." group = "JPF Jars" + description = "Creates the ${archiveName} file." dependsOn compile dependsOn copyResources @@ -220,12 +109,12 @@ task annotationsJar(type: Jar) { from sourceSets.annotations.java.outputDir } -task classloaderSpecificTestsJar(type: Jar) { +task createClassloaderSpecificTestsJar(type: Jar) { archiveName = "classloader_specific_tests.jar" destinationDir = file("${buildDir}") - description = "Creates the ${archiveName} file." group = "JPF Jars" + description = "Creates the ${archiveName} file." dependsOn compile dependsOn copyResources @@ -235,7 +124,7 @@ task classloaderSpecificTestsJar(type: Jar) { } } -task runJpfJar(type: Jar) { +task createRunJpfJar(type: Jar) { archiveName = "RunJPF.jar" destinationDir = file("${buildDir}") @@ -263,16 +152,14 @@ task runJpfJar(type: Jar) { } manifest { attributes( - "Built-By": System.getProperty("user.name"), - "Implementation-Vendor": "NASA Ames Research Center", "Implementation-Title": "Java Pathfinder core launch system", - "Implementation-Version": "1234", //FIXME "Main-Class": "gov.nasa.jpf.tool.RunJPF" ) + from manifestCommonAttrbutes } } -task runTestJar(type: Jar) { +task createRunTestJar(type: Jar) { archiveName = "RunTest.jar" destinationDir = file("${buildDir}") @@ -299,12 +186,10 @@ task runTestJar(type: Jar) { } manifest { attributes( - "Built-By": System.getProperty("user.name"), - "Implementation-Vendor": "NASA Ames Research Center", "Implementation-Title": "Java Pathfinder test launch system", - "Implementation-Version": "1234", // FIXME "Main-Class": "gov.nasa.jpf.tool.RunTest" ) + from manifestCommonAttrbutes } } @@ -312,23 +197,21 @@ task buildJars { group = "JPF Build" description = "Generates all core JPF jar files." - dependsOn classloaderSpecificTestsJar - dependsOn annotationsJar - dependsOn jpfClassesJar - dependsOn jpfJar - dependsOn runJpfJar - dependsOn runTestJar + dependsOn createClassloaderSpecificTestsJar + dependsOn createAnnotationsJar + dependsOn createJpfClassesJar + dependsOn createJpfJar + dependsOn createRunJpfJar + dependsOn createRunTestJar } test { - group = "JPF Build" description = "Runs core regression tests." dependsOn buildJars - enableAssertions = true forkEvery = 1 - + enableAssertions = true maxHeapSize = "1024m" include "**/*Test.class"