X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=blobdiff_plain;f=build.gradle;h=f1c0bf7f737a5491c346a6b69e221d003cd3b6a3;hp=3457b90e0eb08ce8c36436d790892b16865a1a5c;hb=36a0d6af50744d4a1e3d0528d49da172592fe389;hpb=33bf7444bbe18b51597fb80ae30b6a480328915f diff --git a/build.gradle b/build.gradle index 3457b90..f1c0bf7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,346 @@ -ant.importBuild "build.xml" +apply plugin: "java" -task check { - description = "This is a dummy task" +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +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 + } +} + +clean { + group = "JPF Build" +} + +task generateVersion { + description = "Generates the .version file with the current revision hash" + group = "JPF Build Properties" + + doLast { + def revision = "git rev-parse HEAD".execute().text + new File(".version").withWriter("utf-8") { writer -> + writer.writeLine revision + } + } +} + +task buildInfo { + group = "JPF Build Properties" + 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() + } +} + +task compile(type: Copy) { + group = "JPF Build" + description = "Compiles all JPF core sources." + + // These are automatic generated tasks from the Java Gradle Plugin. + // Gradle is able to infer the ordering of the source sets + // due to the compileClasspath attribute + dependsOn compileTestJava, compileExamplesJava, generateVersion + + // Copies build.properties file to the build directory + from "build.properties" + into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf" + + // Copies .version file to the build directory + from ".version" + into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf" +} + +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) { + archiveName = "jpf-classes.jar" + destinationDir = file("${buildDir}") + + description = "Creates the ${archiveName} file." + group = "JPF Jars" + + dependsOn compile + + from sourceSets.classes.java.outputDir + from sourceSets.annotations.java.outputDir + from(sourceSets.main.java.outputDir) { + include "gov/nasa/jpf/JPFShell.class" + include "gov/nasa/jpf/vm/Verify.class" + include "gov/nasa/jpf/util/TypeRef.class" + include "gov/nasa/jpf/util/test/TestJPF.class" + include "gov/nasa/jpf/util/test/TestMultiProcessJPF.class" + include "gov/nasa/jpf/util/test/TestJPFHelper.class" + } +} + +task jpfJar(type: Jar) { + archiveName = "jpf.jar" + destinationDir = file("${buildDir}") + + description = "Creates the ${archiveName} file." + group = "JPF Jars" + + dependsOn compile + + from sourceSets.main.java.outputDir + from sourceSets.peers.java.outputDir + from sourceSets.annotations.java.outputDir + from(sourceSets.classes.java.outputDir) { + include "org/junit/*.class" + } + + manifest { + attributes( + "Built-By": System.getProperty("user.name"), + "Implementation-Vendor": "NASA Ames Research Center", + "Implementation-Title": "Java Pathfinder core system", + "Implementation-Version": "1234" //FIXME + ) + } +} + +task annotationsJar(type: Jar) { + archiveName = "jpf-annotations.jar" + destinationDir = file("${buildDir}") + + description = "Creates the ${archiveName} file." + group = "JPF Jars" + + dependsOn compile + + from sourceSets.annotations.java.outputDir +} + +task classloaderSpecificTestsJar(type: Jar) { + archiveName = "classloader_specific_tests.jar" + destinationDir = file("${buildDir}") + + description = "Creates the ${archiveName} file." + group = "JPF Jars" + + dependsOn compile + + from(sourceSets.test.java.outputDir) { + include "classloader_specific_tests/*.class" + } +} + +task runJpfJar(type: Jar) { + archiveName = "RunJPF.jar" + destinationDir = file("${buildDir}") + + description = "Creates the ${archiveName} file." + group = "JPF Jars" + + dependsOn compile + + from(sourceSets.main.java.outputDir) { + include "gov/nasa/jpf/tool/Run.class" + include "gov/nasa/jpf/tool/RunJPF.class" + include "gov/nasa/jpf/Config.class" + include "gov/nasa/jpf/ConfigChangeListener.class" + include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class" + include "gov/nasa/jpf/JPFClassLoader.class" + include "gov/nasa/jpf/JPFShell.class" + include "gov/nasa/jpf/JPFException.class" + include "gov/nasa/jpf/JPFConfigException.class" + include "gov/nasa/jpf/JPFTargetException.class" + include "gov/nasa/jpf/util/JPFSiteUtils.class" + include "gov/nasa/jpf/util/FileUtils.class" + include "gov/nasa/jpf/util/StringMatcher.class" + include "gov/nasa/jpf/util/Pair.class" + } + 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" + ) + } } + +task runTestJar(type: Jar) { + archiveName = "RunTest.jar" + destinationDir = file("${buildDir}") + + description = "Creates the ${archiveName} file." + group = "JPF Jars" + + dependsOn compile + + from(sourceSets.main.java.outputDir) { + include "gov/nasa/jpf/tool/Run.class" + include "gov/nasa/jpf/tool/RunTest.class" + include "gov/nasa/jpf/tool/RunTest\$Failed.class" + include "gov/nasa/jpf/Config.class" + include "gov/nasa/jpf/ConfigChangeListener.class" + include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class" + include "gov/nasa/jpf/JPFClassLoader.class" + include "gov/nasa/jpf/JPFException.class" + include "gov/nasa/jpf/JPFConfigException.class" + include "gov/nasa/jpf/util/JPFSiteUtils.class" + include "gov/nasa/jpf/util/FileUtils.class" + include "gov/nasa/jpf/util/StringMatcher.class" + include "gov/nasa/jpf/util/DevNullPrintStream.class" + } + 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" + ) + } +} + +task buildJars { + group = "JPF Build" + description = "Generates the core JPF jar files." + + dependsOn buildInfo + + dependsOn classloaderSpecificTestsJar, annotationsJar, + jpfClassesJar, jpfJar, runJpfJar, + runTestJar +} + +test { + group = "JPF Build" + description = "Runs core regression tests." + + dependsOn buildJars + + enableAssertions = true + forkEvery = 1 + + maxHeapSize = "1024m" + + include "**/*Test.class" + exclude "**/SplitInputStreamTest.class" + exclude "**/JPF_*.class" + + testLogging { + events "passed", "skipped", "failed" + } + + afterSuite { testDescriptor, result -> + if (!testDescriptor.parent) { + println "Test Execution: ${result.resultType}" + + def summaryFields = ["${result.testCount} tests", + "${result.successfulTestCount} passed", + "${result.failedTestCount} failed", + "${result.skippedTestCount} skipped"] + + println "Summary: " + summaryFields.join(", ") + } + } +} + +defaultTasks "buildJars"