Removed build.properties and updated build.gradle
[jpf-core.git] / build.gradle
index e53f7e577ff6066080ad6241cb0e84acdbcf9391..f1c0bf7f737a5491c346a6b69e221d003cd3b6a3 100644 (file)
@@ -48,6 +48,48 @@ 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."
@@ -55,11 +97,62 @@ task compile(type: Copy) {
     // 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
+    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) {
@@ -209,6 +302,8 @@ task runTestJar(type: Jar) {
 task buildJars {
     group = "JPF Build"
     description = "Generates the core JPF jar files."
+    
+    dependsOn buildInfo
 
     dependsOn classloaderSpecificTestsJar, annotationsJar,
               jpfClassesJar, jpfJar, runJpfJar,
@@ -230,12 +325,6 @@ test {
     exclude "**/SplitInputStreamTest.class"
     exclude "**/JPF_*.class"
 
-    // XXX Tests temporarily ignored because they are not fully supported in the Gradle build yet
-    new File("failing-tests.txt").eachLine { failedTestClass ->
-        def ignoredPath = "**/" + failedTestClass.replace(".", "/") + ".class"
-        exclude ignoredPath
-    }
-
     testLogging {
         events "passed", "skipped", "failed"
     }