Bump Gradle version
[jpf-core.git] / build.gradle
index 0f42ccc573ba80d32d021178f2721077bf56397b..c8582eb28bdde00804d462cfb48babc8261ea42a 100644 (file)
@@ -1,8 +1,25 @@
-apply plugin: "java"
+plugins {
+    id "java"
+    id "eclipse"
+}
+
+def getCurrentVersion() {
+    "DEVELOPMENT-SNAPSHOT"
+}
+
+version = currentVersion
 
 sourceCompatibility = 1.8
 targetCompatibility = 1.8
 
+ext.manifestCommonAttrbutes = manifest {
+    attributes(
+        "Built-By": System.getProperty("user.name"),
+        "Implementation-Vendor": "NASA Ames Research Center",
+        "Implementation-Version": version
+    )
+}
+
 repositories {
     mavenCentral()
 }
@@ -45,7 +62,7 @@ sourceSets {
 }
 
 task generateVersion {
-    group = "JPF Resources"
+    group = "JPF Build Resources"
     description = "Generates the .version file with the current revision hash"
     doLast {
         def revision = "git rev-parse HEAD".execute().text
@@ -55,18 +72,14 @@ task generateVersion {
     }
 }
 
-task buildInfo {
-    group = "JPF Resources"
-    description = "Creates build info properties."
+task generateBuildInfo {
+    group = "JPF Build Resources"
+    description = "Generates the build.properties file."
     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 status  = "git status --short".execute().text.trim()
         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()
@@ -86,10 +99,10 @@ task buildInfo {
 }
 
 task copyResources(type: Copy) {
-    group = "JPF Resources"
+    group = "JPF Build Resources"
     description = "Copies .version and build.properties files to the build directory."
 
-    dependsOn buildInfo
+    dependsOn generateBuildInfo
     dependsOn generateVersion
 
     from "build.properties"
@@ -99,7 +112,6 @@ task copyResources(type: Copy) {
     into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
 }
 
-
 task compile {
     group = "JPF Build"
     description = "Compiles all JPF core sources."
@@ -112,11 +124,11 @@ task compile {
 }
 
 task srcDist(type: Zip) {
-    group = "JPF Build"
-    description = "Builds the source distribution"
+    group = "JPF Distribution"
+    description = "Builds the source distribution."
 
     baseName = project.name
-    version = "git rev-parse --short HEAD".execute().text.trim()
+    version = project.version
     classifier = "src"
     extension = "zip"
 
@@ -129,8 +141,6 @@ task srcDist(type: Zip) {
     include "gradlew"
     include "gradlew.bat"
     include "gradle/**/*"
-    include "nbproject/**/*"
-    include "eclipse/**/*"
     include "src/**/*"
     include "bin/**/*"
     include "jpf.properties"
@@ -140,11 +150,11 @@ task srcDist(type: Zip) {
 }
 
 task dist(type: Zip) {
-    group = "JPF Build"
-    description = "Builds binary distribution"
+    group = "JPF Distribution"
+    description = "Builds binary distribution."
 
     baseName = project.name
-    version = "git rev-parse --short HEAD".execute().text.trim()
+    version = project.version
     extension = "zip"
 
     destinationDir = buildDir
@@ -158,12 +168,12 @@ task dist(type: Zip) {
     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 +190,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 +208,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 +226,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 +241,7 @@ task classloaderSpecificTestsJar(type: Jar) {
     }
 }
 
-task runJpfJar(type: Jar) {
+task createRunJpfJar(type: Jar) {
     archiveName = "RunJPF.jar"
     destinationDir = file("${buildDir}")
 
@@ -263,16 +269,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 +303,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,16 +314,15 @@ 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
@@ -353,4 +354,22 @@ test {
     }
 }
 
+eclipse {
+    group = "JPF IDE Support"
+
+    project {
+        natures = ["org.eclipse.buildship.core.gradleprojectnature"]
+    }
+    classpath {
+        defaultOutputDir = buildDir
+        file {
+            whenMerged { classpath ->
+                classpath.entries.findAll{ entry -> entry.kind == "src" }*.every { srcNode ->
+                    srcNode.output = srcNode.output.replace("bin", "${buildDir.name}")
+                }
+            }
+        }
+    }
+}
+
 defaultTasks "buildJars"