2 id "com.gradle.build-scan"
6 sourceCompatibility = 1.8
7 targetCompatibility = 1.8
9 ext.manifestCommonAttrbutes = manifest {
11 "Built-By": System.getProperty("user.name"),
12 "Implementation-Vendor": "NASA Ames Research Center",
13 "Implementation-Version": "1234" // FIXME
18 termsOfServiceUrl = 'https://gradle.com/terms-of-service'
19 termsOfServiceAgree = 'yes'
27 testImplementation "junit:junit:4.12"
32 java.srcDirs = ["src/annotations"]
33 java.outputDir = file("${buildDir}/annotations")
36 java.srcDirs = ["src/main"]
37 java.outputDir = file("${buildDir}/main")
38 compileClasspath += sourceSets.annotations.output
41 java.srcDirs = ["src/examples"]
42 java.outputDir = file("${buildDir}/examples")
43 compileClasspath += sourceSets.main.output
46 java.srcDirs = ["src/classes"]
47 java.outputDir = file("${buildDir}/classes")
48 compileClasspath += sourceSets.main.output + sourceSets.annotations.output
51 java.srcDirs = ["src/peers"]
52 java.outputDir = file("${buildDir}/peers")
53 compileClasspath += sourceSets.main.output + sourceSets.annotations.output
56 java.srcDirs = ["src/tests"]
57 java.outputDir = file("${buildDir}/tests")
58 compileClasspath += sourceSets.annotations.output + sourceSets.classes.output + sourceSets.peers.output
59 runtimeClasspath += compileClasspath
63 task generateVersion {
64 group = "JPF Build Resources"
65 description = "Generates the .version file with the current revision hash"
67 def revision = "git rev-parse HEAD".execute().text
68 new File(".version").withWriter("utf-8") { writer ->
69 writer.writeLine revision
74 task generateBuildInfo {
75 group = "JPF Build Resources"
76 description = "Generates the build.properties file."
79 // Must fail if there are uncommitted changes
80 def status = "git status --short".execute().text.trim()
81 if (!status.isEmpty()) {
82 throw new GradleException("There are uncomitted changes:\n " + status)
84 Properties info = new Properties()
86 def revision = "git rev-parse --short HEAD".execute().text.trim()
87 def userName = ["git", "log", "-1", "--format=%an <%ae>"].execute().text.trim()
88 def date = "git log -1 --format=%ci".execute().text.trim()
90 info.setProperty("revision", revision)
91 info.setProperty("date", date)
92 info.setProperty("author", userName)
93 info.setProperty("os.arch", System.getProperty("os.arch"))
94 info.setProperty("os.name", System.getProperty("os.name"))
95 info.setProperty("user.country", System.getProperty("user.country"))
96 info.setProperty("java.version", System.getProperty("java.version"))
98 def writer = new File("build.properties").newWriter("utf-8")
99 info.store(writer, "JPF core build info")
104 task copyResources(type: Copy) {
105 group = "JPF Build Resources"
106 description = "Copies .version and build.properties files to the build directory."
108 dependsOn generateBuildInfo
109 dependsOn generateVersion
111 from "build.properties"
112 into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
115 into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
120 description = "Compiles all JPF core sources."
122 // These are automatic generated tasks from the Java Gradle Plugin.
123 // Gradle is able to infer the order of the source sets
124 // due to the compileClasspath attribute
125 dependsOn compileTestJava
126 dependsOn compileExamplesJava
129 task srcDist(type: Zip) {
130 group = "JPF Distribution"
131 description = "Builds the source distribution."
133 baseName = project.name
134 version = "git rev-parse --short HEAD".execute().text.trim()
138 destinationDir = buildDir
139 includeEmptyDirs = false
142 include "build.gradle"
143 include "settings.gradle"
145 include "gradlew.bat"
146 include "gradle/**/*"
149 include "jpf.properties"
150 include "build.properties"
151 include "LICENSE-2.0.txt"
155 task dist(type: Zip) {
156 group = "JPF Distribution"
157 description = "Builds binary distribution."
159 baseName = project.name
160 version = "git rev-parse --short HEAD".execute().text.trim()
163 destinationDir = buildDir
164 includeEmptyDirs = false
167 include "jpf.properties"
168 include "build.properties"
171 include "${buildDir.name}/**/*.jar"
174 task createJpfClassesJar(type: Jar) {
175 archiveName = "jpf-classes.jar"
176 destinationDir = file("${buildDir}")
179 description = "Creates the ${archiveName} file."
182 dependsOn copyResources
184 from sourceSets.classes.java.outputDir
185 from sourceSets.annotations.java.outputDir
186 from(sourceSets.main.java.outputDir) {
187 include "gov/nasa/jpf/JPFShell.class"
188 include "gov/nasa/jpf/vm/Verify.class"
189 include "gov/nasa/jpf/util/TypeRef.class"
190 include "gov/nasa/jpf/util/test/TestJPF.class"
191 include "gov/nasa/jpf/util/test/TestMultiProcessJPF.class"
192 include "gov/nasa/jpf/util/test/TestJPFHelper.class"
196 task createJpfJar(type: Jar) {
197 archiveName = "jpf.jar"
198 destinationDir = file("${buildDir}")
201 description = "Creates the ${archiveName} file."
204 dependsOn copyResources
206 from sourceSets.main.java.outputDir
207 from sourceSets.peers.java.outputDir
208 from sourceSets.annotations.java.outputDir
209 from(sourceSets.classes.java.outputDir) {
210 include "org/junit/*.class"
214 attributes "Implementation-Title": "Java Pathfinder core system"
215 from manifestCommonAttrbutes
219 task createAnnotationsJar(type: Jar) {
220 archiveName = "jpf-annotations.jar"
221 destinationDir = file("${buildDir}")
224 description = "Creates the ${archiveName} file."
227 dependsOn copyResources
229 from sourceSets.annotations.java.outputDir
232 task createClassloaderSpecificTestsJar(type: Jar) {
233 archiveName = "classloader_specific_tests.jar"
234 destinationDir = file("${buildDir}")
237 description = "Creates the ${archiveName} file."
240 dependsOn copyResources
242 from(sourceSets.test.java.outputDir) {
243 include "classloader_specific_tests/*.class"
247 task createRunJpfJar(type: Jar) {
248 archiveName = "RunJPF.jar"
249 destinationDir = file("${buildDir}")
251 description = "Creates the ${archiveName} file."
255 dependsOn copyResources
257 from(sourceSets.main.java.outputDir) {
258 include "gov/nasa/jpf/tool/Run.class"
259 include "gov/nasa/jpf/tool/RunJPF.class"
260 include "gov/nasa/jpf/Config.class"
261 include "gov/nasa/jpf/ConfigChangeListener.class"
262 include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
263 include "gov/nasa/jpf/JPFClassLoader.class"
264 include "gov/nasa/jpf/JPFShell.class"
265 include "gov/nasa/jpf/JPFException.class"
266 include "gov/nasa/jpf/JPFConfigException.class"
267 include "gov/nasa/jpf/JPFTargetException.class"
268 include "gov/nasa/jpf/util/JPFSiteUtils.class"
269 include "gov/nasa/jpf/util/FileUtils.class"
270 include "gov/nasa/jpf/util/StringMatcher.class"
271 include "gov/nasa/jpf/util/Pair.class"
275 "Implementation-Title": "Java Pathfinder core launch system",
276 "Main-Class": "gov.nasa.jpf.tool.RunJPF"
278 from manifestCommonAttrbutes
282 task createRunTestJar(type: Jar) {
283 archiveName = "RunTest.jar"
284 destinationDir = file("${buildDir}")
286 description = "Creates the ${archiveName} file."
290 dependsOn copyResources
292 from(sourceSets.main.java.outputDir) {
293 include "gov/nasa/jpf/tool/Run.class"
294 include "gov/nasa/jpf/tool/RunTest.class"
295 include "gov/nasa/jpf/tool/RunTest\$Failed.class"
296 include "gov/nasa/jpf/Config.class"
297 include "gov/nasa/jpf/ConfigChangeListener.class"
298 include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
299 include "gov/nasa/jpf/JPFClassLoader.class"
300 include "gov/nasa/jpf/JPFException.class"
301 include "gov/nasa/jpf/JPFConfigException.class"
302 include "gov/nasa/jpf/util/JPFSiteUtils.class"
303 include "gov/nasa/jpf/util/FileUtils.class"
304 include "gov/nasa/jpf/util/StringMatcher.class"
305 include "gov/nasa/jpf/util/DevNullPrintStream.class"
309 "Implementation-Title": "Java Pathfinder test launch system",
310 "Main-Class": "gov.nasa.jpf.tool.RunTest"
312 from manifestCommonAttrbutes
318 description = "Generates all core JPF jar files."
320 dependsOn createClassloaderSpecificTestsJar
321 dependsOn createAnnotationsJar
322 dependsOn createJpfClassesJar
323 dependsOn createJpfJar
324 dependsOn createRunJpfJar
325 dependsOn createRunTestJar
329 description = "Runs core regression tests."
333 enableAssertions = true
336 maxHeapSize = "1024m"
338 include "**/*Test.class"
339 exclude "**/SplitInputStreamTest.class"
340 exclude "**/JPF_*.class"
343 events "passed", "skipped", "failed"
346 afterSuite { testDescriptor, result ->
347 if (!testDescriptor.parent) {
348 println "Test Execution: ${result.resultType}"
350 def summaryFields = ["${result.testCount} tests",
351 "${result.successfulTestCount} passed",
352 "${result.failedTestCount} failed",
353 "${result.skippedTestCount} skipped"]
355 println "Summary: " + summaryFields.join(", ")
360 defaultTasks "buildJars"