-apply plugin: "java"
+plugins {
+ id "com.gradle.build-scan" version "1.14"
+ id "java"
+ id "jacoco"
+}
sourceCompatibility = 1.8
targetCompatibility = 1.8
+ext.manifestCommonAttrbutes = manifest {
+ attributes(
+ "Built-By": System.getProperty("user.name"),
+ "Implementation-Vendor": "NASA Ames Research Center",
+ "Implementation-Version": "1234" // FIXME
+ )
+}
+
+buildScan {
+ termsOfServiceUrl = 'https://gradle.com/terms-of-service'
+ termsOfServiceAgree = 'yes'
+}
+
+jacocoTestReport {
+ reports {
+ xml.enabled = true
+ html.enabled = false
+ }
+}
+
repositories {
mavenCentral()
}
}
}
-clean {
- group = "JPF Build"
+task generateVersion {
+ group = "JPF Build 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
+ }
+ }
+}
+
+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 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 copyResources(type: Copy) {
+ group = "JPF Build Resources"
+ description = "Copies .version and build.properties files to the build directory."
+
+ dependsOn generateBuildInfo
+ dependsOn generateVersion
+
+ from "build.properties"
+ into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
+
+ from ".version"
+ into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
}
-task compile(type: Copy) {
+task compile {
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
+ // Gradle is able to infer the order of the source sets
// due to the compileClasspath attribute
- dependsOn compileTestJava, compileExamplesJava
+ dependsOn compileTestJava
+ dependsOn compileExamplesJava
+}
- // Copies build.properties file to the build directory
- from "build.properties"
- into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
+task srcDist(type: Zip) {
+ group = "JPF Distribution"
+ 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 "src/**/*"
+ include "bin/**/*"
+ include "jpf.properties"
+ include "build.properties"
+ include "LICENSE-2.0.txt"
+ include "README.md"
}
-task jpfClassesJar(type: Jar) {
+task dist(type: Zip) {
+ group = "JPF Distribution"
+ 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 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
from sourceSets.classes.java.outputDir
from sourceSets.annotations.java.outputDir
}
}
-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
from sourceSets.main.java.outputDir
from sourceSets.peers.java.outputDir
}
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
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
from(sourceSets.test.java.outputDir) {
include "classloader_specific_tests/*.class"
}
}
-task runJpfJar(type: Jar) {
+task createRunJpfJar(type: Jar) {
archiveName = "RunJPF.jar"
destinationDir = file("${buildDir}")
group = "JPF Jars"
dependsOn compile
+ dependsOn copyResources
from(sourceSets.main.java.outputDir) {
include "gov/nasa/jpf/tool/Run.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"
)
+ from manifestCommonAttrbutes
}
}
-task runTestJar(type: Jar) {
+task createRunTestJar(type: Jar) {
archiveName = "RunTest.jar"
destinationDir = file("${buildDir}")
group = "JPF Jars"
dependsOn compile
+ dependsOn copyResources
from(sourceSets.main.java.outputDir) {
include "gov/nasa/jpf/tool/Run.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"
)
+ from manifestCommonAttrbutes
}
}
task buildJars {
group = "JPF Build"
- description = "Generates the core JPF jar files."
-
- dependsOn classloaderSpecificTestsJar, annotationsJar,
- jpfClassesJar, jpfJar, runJpfJar,
- runTestJar
+ description = "Generates all core JPF jar files."
+
+ dependsOn createClassloaderSpecificTestsJar
+ dependsOn createAnnotationsJar
+ dependsOn createJpfClassesJar
+ dependsOn createJpfJar
+ dependsOn createRunJpfJar
+ dependsOn createRunTestJar
}
test {
- group = "JPF Build"
description = "Runs core regression tests."
dependsOn buildJars