3 sourceCompatibility = 1.8
4 targetCompatibility = 1.8
11 testImplementation "junit:junit:4.12"
16 java.srcDirs = ["src/annotations"]
17 java.outputDir = file("${buildDir}/annotations")
20 java.srcDirs = ["src/main"]
21 java.outputDir = file("${buildDir}/main")
22 compileClasspath += sourceSets.annotations.output
25 java.srcDirs = ["src/examples"]
26 java.outputDir = file("${buildDir}/examples")
27 compileClasspath += sourceSets.main.output
30 java.srcDirs = ["src/classes"]
31 java.outputDir = file("${buildDir}/classes")
32 compileClasspath += sourceSets.main.output + sourceSets.annotations.output
35 java.srcDirs = ["src/peers"]
36 java.outputDir = file("${buildDir}/peers")
37 compileClasspath += sourceSets.main.output + sourceSets.annotations.output
40 java.srcDirs = ["src/tests"]
41 java.outputDir = file("${buildDir}/tests")
42 compileClasspath += sourceSets.annotations.output + sourceSets.classes.output + sourceSets.peers.output
43 runtimeClasspath += compileClasspath
47 task generateVersion {
48 group = "JPF Resources"
49 description = "Generates the .version file with the current revision hash"
51 def revision = "git rev-parse HEAD".execute().text
52 new File(".version").withWriter("utf-8") { writer ->
53 writer.writeLine revision
59 group = "JPF Resources"
60 description = "Creates build info properties."
63 // Must fail if there are uncommitted changes
64 def status = "git status --short".execute().text.trim()
65 if (!status.isEmpty()) {
66 throw new GradleException("There are uncomitted changes:\n " + status)
68 Properties info = new Properties()
70 def revision = "git rev-parse --short HEAD".execute().text.trim()
71 def userName = ["git", "log", "-1", "--format=%an <%ae>"].execute().text.trim()
72 def date = "git log -1 --format=%ci".execute().text.trim()
74 info.setProperty("revision", revision)
75 info.setProperty("date", date)
76 info.setProperty("author", userName)
77 info.setProperty("os.arch", System.getProperty("os.arch"))
78 info.setProperty("os.name", System.getProperty("os.name"))
79 info.setProperty("user.country", System.getProperty("user.country"))
80 info.setProperty("java.version", System.getProperty("java.version"))
82 def writer = new File("build.properties").newWriter("utf-8")
83 info.store(writer, "JPF core build info")
88 task copyResources(type: Copy) {
89 group = "JPF Resources"
90 description = "Copies .version and build.properties files to the build directory."
93 dependsOn generateVersion
95 from "build.properties"
96 into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
99 into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
105 description = "Compiles all JPF core sources."
107 // These are automatic generated tasks from the Java Gradle Plugin.
108 // Gradle is able to infer the order of the source sets
109 // due to the compileClasspath attribute
110 dependsOn compileTestJava
111 dependsOn compileExamplesJava
114 task srcDist(type: Zip) {
116 description = "Builds the source distribution"
118 baseName = project.name
119 version = "git rev-parse --short HEAD".execute().text.trim()
123 destinationDir = buildDir
124 includeEmptyDirs = false
127 include "build.gradle"
128 include "settings.gradle"
130 include "gradlew.bat"
131 include "gradle/**/*"
132 include "nbproject/**/*"
133 include "eclipse/**/*"
136 include "jpf.properties"
137 include "build.properties"
138 include "LICENSE-2.0.txt"
142 task dist(type: Zip) {
144 description = "Builds binary distribution"
146 baseName = project.name
147 version = "git rev-parse --short HEAD".execute().text.trim()
150 destinationDir = buildDir
151 includeEmptyDirs = false
154 include "jpf.properties"
155 include "build.properties"
158 include "${buildDir.name}/**/*.jar"
161 task jpfClassesJar(type: Jar) {
162 archiveName = "jpf-classes.jar"
163 destinationDir = file("${buildDir}")
165 description = "Creates the ${archiveName} file."
169 dependsOn copyResources
171 from sourceSets.classes.java.outputDir
172 from sourceSets.annotations.java.outputDir
173 from(sourceSets.main.java.outputDir) {
174 include "gov/nasa/jpf/JPFShell.class"
175 include "gov/nasa/jpf/vm/Verify.class"
176 include "gov/nasa/jpf/util/TypeRef.class"
177 include "gov/nasa/jpf/util/test/TestJPF.class"
178 include "gov/nasa/jpf/util/test/TestMultiProcessJPF.class"
179 include "gov/nasa/jpf/util/test/TestJPFHelper.class"
183 task jpfJar(type: Jar) {
184 archiveName = "jpf.jar"
185 destinationDir = file("${buildDir}")
187 description = "Creates the ${archiveName} file."
191 dependsOn copyResources
193 from sourceSets.main.java.outputDir
194 from sourceSets.peers.java.outputDir
195 from sourceSets.annotations.java.outputDir
196 from(sourceSets.classes.java.outputDir) {
197 include "org/junit/*.class"
202 "Built-By": System.getProperty("user.name"),
203 "Implementation-Vendor": "NASA Ames Research Center",
204 "Implementation-Title": "Java Pathfinder core system",
205 "Implementation-Version": "1234" //FIXME
210 task annotationsJar(type: Jar) {
211 archiveName = "jpf-annotations.jar"
212 destinationDir = file("${buildDir}")
214 description = "Creates the ${archiveName} file."
218 dependsOn copyResources
220 from sourceSets.annotations.java.outputDir
223 task classloaderSpecificTestsJar(type: Jar) {
224 archiveName = "classloader_specific_tests.jar"
225 destinationDir = file("${buildDir}")
227 description = "Creates the ${archiveName} file."
231 dependsOn copyResources
233 from(sourceSets.test.java.outputDir) {
234 include "classloader_specific_tests/*.class"
238 task runJpfJar(type: Jar) {
239 archiveName = "RunJPF.jar"
240 destinationDir = file("${buildDir}")
242 description = "Creates the ${archiveName} file."
246 dependsOn copyResources
248 from(sourceSets.main.java.outputDir) {
249 include "gov/nasa/jpf/tool/Run.class"
250 include "gov/nasa/jpf/tool/RunJPF.class"
251 include "gov/nasa/jpf/Config.class"
252 include "gov/nasa/jpf/ConfigChangeListener.class"
253 include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
254 include "gov/nasa/jpf/JPFClassLoader.class"
255 include "gov/nasa/jpf/JPFShell.class"
256 include "gov/nasa/jpf/JPFException.class"
257 include "gov/nasa/jpf/JPFConfigException.class"
258 include "gov/nasa/jpf/JPFTargetException.class"
259 include "gov/nasa/jpf/util/JPFSiteUtils.class"
260 include "gov/nasa/jpf/util/FileUtils.class"
261 include "gov/nasa/jpf/util/StringMatcher.class"
262 include "gov/nasa/jpf/util/Pair.class"
266 "Built-By": System.getProperty("user.name"),
267 "Implementation-Vendor": "NASA Ames Research Center",
268 "Implementation-Title": "Java Pathfinder core launch system",
269 "Implementation-Version": "1234", //FIXME
270 "Main-Class": "gov.nasa.jpf.tool.RunJPF"
275 task runTestJar(type: Jar) {
276 archiveName = "RunTest.jar"
277 destinationDir = file("${buildDir}")
279 description = "Creates the ${archiveName} file."
283 dependsOn copyResources
285 from(sourceSets.main.java.outputDir) {
286 include "gov/nasa/jpf/tool/Run.class"
287 include "gov/nasa/jpf/tool/RunTest.class"
288 include "gov/nasa/jpf/tool/RunTest\$Failed.class"
289 include "gov/nasa/jpf/Config.class"
290 include "gov/nasa/jpf/ConfigChangeListener.class"
291 include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
292 include "gov/nasa/jpf/JPFClassLoader.class"
293 include "gov/nasa/jpf/JPFException.class"
294 include "gov/nasa/jpf/JPFConfigException.class"
295 include "gov/nasa/jpf/util/JPFSiteUtils.class"
296 include "gov/nasa/jpf/util/FileUtils.class"
297 include "gov/nasa/jpf/util/StringMatcher.class"
298 include "gov/nasa/jpf/util/DevNullPrintStream.class"
302 "Built-By": System.getProperty("user.name"),
303 "Implementation-Vendor": "NASA Ames Research Center",
304 "Implementation-Title": "Java Pathfinder test launch system",
305 "Implementation-Version": "1234", // FIXME
306 "Main-Class": "gov.nasa.jpf.tool.RunTest"
313 description = "Generates all core JPF jar files."
315 dependsOn classloaderSpecificTestsJar
316 dependsOn annotationsJar
317 dependsOn jpfClassesJar
325 description = "Runs core regression tests."
329 enableAssertions = true
332 maxHeapSize = "1024m"
334 include "**/*Test.class"
335 exclude "**/SplitInputStreamTest.class"
336 exclude "**/JPF_*.class"
339 events "passed", "skipped", "failed"
342 afterSuite { testDescriptor, result ->
343 if (!testDescriptor.parent) {
344 println "Test Execution: ${result.resultType}"
346 def summaryFields = ["${result.testCount} tests",
347 "${result.successfulTestCount} passed",
348 "${result.failedTestCount} failed",
349 "${result.skippedTestCount} skipped"]
351 println "Summary: " + summaryFields.join(", ")
356 defaultTasks "buildJars"