3 sourceCompatibility = 1.8
4 targetCompatibility = 1.8
6 ext.manifestCommonAttrbutes = manifest {
8 "Built-By": System.getProperty("user.name"),
9 "Implementation-Vendor": "NASA Ames Research Center",
10 "Implementation-Version": "1234" // FIXME
19 testImplementation "junit:junit:4.12"
24 java.srcDirs = ["src/annotations"]
25 java.outputDir = file("${buildDir}/annotations")
28 java.srcDirs = ["src/main"]
29 java.outputDir = file("${buildDir}/main")
30 compileClasspath += sourceSets.annotations.output
33 java.srcDirs = ["src/examples"]
34 java.outputDir = file("${buildDir}/examples")
35 compileClasspath += sourceSets.main.output
38 java.srcDirs = ["src/classes"]
39 java.outputDir = file("${buildDir}/classes")
40 compileClasspath += sourceSets.main.output + sourceSets.annotations.output
43 java.srcDirs = ["src/peers"]
44 java.outputDir = file("${buildDir}/peers")
45 compileClasspath += sourceSets.main.output + sourceSets.annotations.output
48 java.srcDirs = ["src/tests"]
49 java.outputDir = file("${buildDir}/tests")
50 compileClasspath += sourceSets.annotations.output + sourceSets.classes.output + sourceSets.peers.output
51 runtimeClasspath += compileClasspath
55 task generateVersion {
56 group = "JPF Build Resources"
57 description = "Generates the .version file with the current revision hash"
59 def revision = "git rev-parse HEAD".execute().text
60 new File(".version").withWriter("utf-8") { writer ->
61 writer.writeLine revision
66 task generateBuildInfo {
67 group = "JPF Build Resources"
68 description = "Generates the build.properties file."
71 // Must fail if there are uncommitted changes
72 def status = "git status --short".execute().text.trim()
73 if (!status.isEmpty()) {
74 throw new GradleException("There are uncomitted changes:\n " + status)
76 Properties info = new Properties()
78 def revision = "git rev-parse --short HEAD".execute().text.trim()
79 def userName = ["git", "log", "-1", "--format=%an <%ae>"].execute().text.trim()
80 def date = "git log -1 --format=%ci".execute().text.trim()
82 info.setProperty("revision", revision)
83 info.setProperty("date", date)
84 info.setProperty("author", userName)
85 info.setProperty("os.arch", System.getProperty("os.arch"))
86 info.setProperty("os.name", System.getProperty("os.name"))
87 info.setProperty("user.country", System.getProperty("user.country"))
88 info.setProperty("java.version", System.getProperty("java.version"))
90 def writer = new File("build.properties").newWriter("utf-8")
91 info.store(writer, "JPF core build info")
96 task copyResources(type: Copy) {
97 group = "JPF Build Resources"
98 description = "Copies .version and build.properties files to the build directory."
100 dependsOn generateBuildInfo
101 dependsOn generateVersion
103 from "build.properties"
104 into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
107 into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
112 description = "Compiles all JPF core sources."
114 // These are automatic generated tasks from the Java Gradle Plugin.
115 // Gradle is able to infer the order of the source sets
116 // due to the compileClasspath attribute
117 dependsOn compileTestJava
118 dependsOn compileExamplesJava
121 task srcDist(type: Zip) {
122 group = "JPF Distribution"
123 description = "Builds the source distribution."
125 baseName = project.name
126 version = "git rev-parse --short HEAD".execute().text.trim()
130 destinationDir = buildDir
131 includeEmptyDirs = false
134 include "build.gradle"
135 include "settings.gradle"
137 include "gradlew.bat"
138 include "gradle/**/*"
141 include "jpf.properties"
142 include "build.properties"
143 include "LICENSE-2.0.txt"
147 task dist(type: Zip) {
148 group = "JPF Distribution"
149 description = "Builds binary distribution."
151 baseName = project.name
152 version = "git rev-parse --short HEAD".execute().text.trim()
155 destinationDir = buildDir
156 includeEmptyDirs = false
159 include "jpf.properties"
160 include "build.properties"
163 include "${buildDir.name}/**/*.jar"
166 task createJpfClassesJar(type: Jar) {
167 archiveName = "jpf-classes.jar"
168 destinationDir = file("${buildDir}")
171 description = "Creates the ${archiveName} file."
174 dependsOn copyResources
176 from sourceSets.classes.java.outputDir
177 from sourceSets.annotations.java.outputDir
178 from(sourceSets.main.java.outputDir) {
179 include "gov/nasa/jpf/JPFShell.class"
180 include "gov/nasa/jpf/vm/Verify.class"
181 include "gov/nasa/jpf/util/TypeRef.class"
182 include "gov/nasa/jpf/util/test/TestJPF.class"
183 include "gov/nasa/jpf/util/test/TestMultiProcessJPF.class"
184 include "gov/nasa/jpf/util/test/TestJPFHelper.class"
188 task createJpfJar(type: Jar) {
189 archiveName = "jpf.jar"
190 destinationDir = file("${buildDir}")
193 description = "Creates the ${archiveName} file."
196 dependsOn copyResources
198 from sourceSets.main.java.outputDir
199 from sourceSets.peers.java.outputDir
200 from sourceSets.annotations.java.outputDir
201 from(sourceSets.classes.java.outputDir) {
202 include "org/junit/*.class"
206 attributes "Implementation-Title": "Java Pathfinder core system"
207 from manifestCommonAttrbutes
211 task createAnnotationsJar(type: Jar) {
212 archiveName = "jpf-annotations.jar"
213 destinationDir = file("${buildDir}")
216 description = "Creates the ${archiveName} file."
219 dependsOn copyResources
221 from sourceSets.annotations.java.outputDir
224 task createClassloaderSpecificTestsJar(type: Jar) {
225 archiveName = "classloader_specific_tests.jar"
226 destinationDir = file("${buildDir}")
229 description = "Creates the ${archiveName} file."
232 dependsOn copyResources
234 from(sourceSets.test.java.outputDir) {
235 include "classloader_specific_tests/*.class"
239 task createRunJpfJar(type: Jar) {
240 archiveName = "RunJPF.jar"
241 destinationDir = file("${buildDir}")
243 description = "Creates the ${archiveName} file."
247 dependsOn copyResources
249 from(sourceSets.main.java.outputDir) {
250 include "gov/nasa/jpf/tool/Run.class"
251 include "gov/nasa/jpf/tool/RunJPF.class"
252 include "gov/nasa/jpf/Config.class"
253 include "gov/nasa/jpf/ConfigChangeListener.class"
254 include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
255 include "gov/nasa/jpf/JPFClassLoader.class"
256 include "gov/nasa/jpf/JPFShell.class"
257 include "gov/nasa/jpf/JPFException.class"
258 include "gov/nasa/jpf/JPFConfigException.class"
259 include "gov/nasa/jpf/JPFTargetException.class"
260 include "gov/nasa/jpf/util/JPFSiteUtils.class"
261 include "gov/nasa/jpf/util/FileUtils.class"
262 include "gov/nasa/jpf/util/StringMatcher.class"
263 include "gov/nasa/jpf/util/Pair.class"
267 "Implementation-Title": "Java Pathfinder core launch system",
268 "Main-Class": "gov.nasa.jpf.tool.RunJPF"
270 from manifestCommonAttrbutes
274 task createRunTestJar(type: Jar) {
275 archiveName = "RunTest.jar"
276 destinationDir = file("${buildDir}")
278 description = "Creates the ${archiveName} file."
282 dependsOn copyResources
284 from(sourceSets.main.java.outputDir) {
285 include "gov/nasa/jpf/tool/Run.class"
286 include "gov/nasa/jpf/tool/RunTest.class"
287 include "gov/nasa/jpf/tool/RunTest\$Failed.class"
288 include "gov/nasa/jpf/Config.class"
289 include "gov/nasa/jpf/ConfigChangeListener.class"
290 include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
291 include "gov/nasa/jpf/JPFClassLoader.class"
292 include "gov/nasa/jpf/JPFException.class"
293 include "gov/nasa/jpf/JPFConfigException.class"
294 include "gov/nasa/jpf/util/JPFSiteUtils.class"
295 include "gov/nasa/jpf/util/FileUtils.class"
296 include "gov/nasa/jpf/util/StringMatcher.class"
297 include "gov/nasa/jpf/util/DevNullPrintStream.class"
301 "Implementation-Title": "Java Pathfinder test launch system",
302 "Main-Class": "gov.nasa.jpf.tool.RunTest"
304 from manifestCommonAttrbutes
310 description = "Generates all core JPF jar files."
312 dependsOn createClassloaderSpecificTestsJar
313 dependsOn createAnnotationsJar
314 dependsOn createJpfClassesJar
315 dependsOn createJpfJar
316 dependsOn createRunJpfJar
317 dependsOn createRunTestJar
321 description = "Runs core regression tests."
325 enableAssertions = true
328 maxHeapSize = "1024m"
330 include "**/*Test.class"
331 exclude "**/SplitInputStreamTest.class"
332 exclude "**/JPF_*.class"
335 events "passed", "skipped", "failed"
338 afterSuite { testDescriptor, result ->
339 if (!testDescriptor.parent) {
340 println "Test Execution: ${result.resultType}"
342 def summaryFields = ["${result.testCount} tests",
343 "${result.successfulTestCount} passed",
344 "${result.failedTestCount} failed",
345 "${result.skippedTestCount} skipped"]
347 println "Summary: " + summaryFields.join(", ")
352 defaultTasks "buildJars"