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) {
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) {
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/**/*"
139 include "nbproject/**/*"
140 include "eclipse/**/*"
143 include "jpf.properties"
144 include "build.properties"
145 include "LICENSE-2.0.txt"
149 task dist(type: Zip) {
151 description = "Builds binary distribution"
153 baseName = project.name
154 version = "git rev-parse --short HEAD".execute().text.trim()
157 destinationDir = buildDir
158 includeEmptyDirs = false
161 include "jpf.properties"
162 include "build.properties"
165 include "${buildDir.name}/**/*.jar"
168 task createJpfClassesJar(type: Jar) {
169 archiveName = "jpf-classes.jar"
170 destinationDir = file("${buildDir}")
173 description = "Creates the ${archiveName} file."
176 dependsOn copyResources
178 from sourceSets.classes.java.outputDir
179 from sourceSets.annotations.java.outputDir
180 from(sourceSets.main.java.outputDir) {
181 include "gov/nasa/jpf/JPFShell.class"
182 include "gov/nasa/jpf/vm/Verify.class"
183 include "gov/nasa/jpf/util/TypeRef.class"
184 include "gov/nasa/jpf/util/test/TestJPF.class"
185 include "gov/nasa/jpf/util/test/TestMultiProcessJPF.class"
186 include "gov/nasa/jpf/util/test/TestJPFHelper.class"
190 task createJpfJar(type: Jar) {
191 archiveName = "jpf.jar"
192 destinationDir = file("${buildDir}")
195 description = "Creates the ${archiveName} file."
198 dependsOn copyResources
200 from sourceSets.main.java.outputDir
201 from sourceSets.peers.java.outputDir
202 from sourceSets.annotations.java.outputDir
203 from(sourceSets.classes.java.outputDir) {
204 include "org/junit/*.class"
208 attributes "Implementation-Title": "Java Pathfinder core system"
209 from manifestCommonAttrbutes
213 task createAnnotationsJar(type: Jar) {
214 archiveName = "jpf-annotations.jar"
215 destinationDir = file("${buildDir}")
218 description = "Creates the ${archiveName} file."
221 dependsOn copyResources
223 from sourceSets.annotations.java.outputDir
226 task createClassloaderSpecificTestsJar(type: Jar) {
227 archiveName = "classloader_specific_tests.jar"
228 destinationDir = file("${buildDir}")
231 description = "Creates the ${archiveName} file."
234 dependsOn copyResources
236 from(sourceSets.test.java.outputDir) {
237 include "classloader_specific_tests/*.class"
241 task createRunJpfJar(type: Jar) {
242 archiveName = "RunJPF.jar"
243 destinationDir = file("${buildDir}")
245 description = "Creates the ${archiveName} file."
249 dependsOn copyResources
251 from(sourceSets.main.java.outputDir) {
252 include "gov/nasa/jpf/tool/Run.class"
253 include "gov/nasa/jpf/tool/RunJPF.class"
254 include "gov/nasa/jpf/Config.class"
255 include "gov/nasa/jpf/ConfigChangeListener.class"
256 include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
257 include "gov/nasa/jpf/JPFClassLoader.class"
258 include "gov/nasa/jpf/JPFShell.class"
259 include "gov/nasa/jpf/JPFException.class"
260 include "gov/nasa/jpf/JPFConfigException.class"
261 include "gov/nasa/jpf/JPFTargetException.class"
262 include "gov/nasa/jpf/util/JPFSiteUtils.class"
263 include "gov/nasa/jpf/util/FileUtils.class"
264 include "gov/nasa/jpf/util/StringMatcher.class"
265 include "gov/nasa/jpf/util/Pair.class"
269 "Implementation-Title": "Java Pathfinder core launch system",
270 "Main-Class": "gov.nasa.jpf.tool.RunJPF"
272 from manifestCommonAttrbutes
276 task createRunTestJar(type: Jar) {
277 archiveName = "RunTest.jar"
278 destinationDir = file("${buildDir}")
280 description = "Creates the ${archiveName} file."
284 dependsOn copyResources
286 from(sourceSets.main.java.outputDir) {
287 include "gov/nasa/jpf/tool/Run.class"
288 include "gov/nasa/jpf/tool/RunTest.class"
289 include "gov/nasa/jpf/tool/RunTest\$Failed.class"
290 include "gov/nasa/jpf/Config.class"
291 include "gov/nasa/jpf/ConfigChangeListener.class"
292 include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
293 include "gov/nasa/jpf/JPFClassLoader.class"
294 include "gov/nasa/jpf/JPFException.class"
295 include "gov/nasa/jpf/JPFConfigException.class"
296 include "gov/nasa/jpf/util/JPFSiteUtils.class"
297 include "gov/nasa/jpf/util/FileUtils.class"
298 include "gov/nasa/jpf/util/StringMatcher.class"
299 include "gov/nasa/jpf/util/DevNullPrintStream.class"
303 "Implementation-Title": "Java Pathfinder test launch system",
304 "Main-Class": "gov.nasa.jpf.tool.RunTest"
306 from manifestCommonAttrbutes
312 description = "Generates all core JPF jar files."
314 dependsOn createClassloaderSpecificTestsJar
315 dependsOn createAnnotationsJar
316 dependsOn createJpfClassesJar
317 dependsOn createJpfJar
318 dependsOn createRunJpfJar
319 dependsOn createRunTestJar
324 description = "Runs core regression tests."
328 enableAssertions = true
331 maxHeapSize = "1024m"
333 include "**/*Test.class"
334 exclude "**/SplitInputStreamTest.class"
335 exclude "**/JPF_*.class"
338 events "passed", "skipped", "failed"
341 afterSuite { testDescriptor, result ->
342 if (!testDescriptor.parent) {
343 println "Test Execution: ${result.resultType}"
345 def summaryFields = ["${result.testCount} tests",
346 "${result.successfulTestCount} passed",
347 "${result.failedTestCount} failed",
348 "${result.skippedTestCount} skipped"]
350 println "Summary: " + summaryFields.join(", ")
355 defaultTasks "buildJars"