3ab3ce00ca898956bbe40adddbc65e1ca751c1d9
[jpf-core.git] / build.gradle
1 apply plugin: "java"
2
3 sourceCompatibility = 1.8
4 targetCompatibility = 1.8
5
6 repositories {
7     mavenCentral()
8 }
9
10 dependencies {
11     testImplementation "junit:junit:4.12"
12 }
13
14 sourceSets {
15     annotations {
16         java.srcDirs = ["src/annotations"]
17         java.outputDir = file("${buildDir}/annotations")
18     }
19     main {
20         java.srcDirs = ["src/main"]
21         java.outputDir = file("${buildDir}/main")
22         compileClasspath += sourceSets.annotations.output
23     }
24     examples {
25         java.srcDirs = ["src/examples"]
26         java.outputDir = file("${buildDir}/examples")
27         compileClasspath += sourceSets.main.output
28     }
29     classes {
30         java.srcDirs = ["src/classes"]
31         java.outputDir = file("${buildDir}/classes")
32         compileClasspath += sourceSets.main.output + sourceSets.annotations.output
33     }
34     peers {
35         java.srcDirs = ["src/peers"]
36         java.outputDir = file("${buildDir}/peers")
37         compileClasspath += sourceSets.main.output + sourceSets.annotations.output
38     }
39     test {
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
44     }
45 }
46
47 clean {
48     group = "JPF Build"
49 }
50
51 task generateVersion {
52     description = "Generates the .version file with the current revision hash"
53     group = "JPF Build Properties"
54
55     doLast {
56         def revision = "git rev-parse HEAD".execute().text
57         new File(".version").withWriter("utf-8") { writer ->
58             writer.writeLine revision
59         }
60     }
61 }
62
63 task compile(type: Copy) {
64     group = "JPF Build"
65     description = "Compiles all JPF core sources."
66
67     // These are automatic generated tasks from the Java Gradle Plugin.
68     // Gradle is able to infer the ordering of the source sets
69     // due to the compileClasspath attribute
70     dependsOn compileTestJava, compileExamplesJava, generateVersion
71
72     // Copies build.properties file to the build directory
73     from "build.properties"
74     into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
75
76     // Copies .version file to the build directory
77     from ".version"
78     into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
79 }
80
81 task jpfClassesJar(type: Jar) {
82     archiveName = "jpf-classes.jar"
83     destinationDir = file("${buildDir}")
84
85     description = "Creates the ${archiveName} file."
86     group = "JPF Jars"
87
88     dependsOn compile
89
90     from sourceSets.classes.java.outputDir
91     from sourceSets.annotations.java.outputDir
92     from(sourceSets.main.java.outputDir) {
93         include "gov/nasa/jpf/JPFShell.class"
94         include "gov/nasa/jpf/vm/Verify.class"
95         include "gov/nasa/jpf/util/TypeRef.class"
96         include "gov/nasa/jpf/util/test/TestJPF.class"
97         include "gov/nasa/jpf/util/test/TestMultiProcessJPF.class"
98         include "gov/nasa/jpf/util/test/TestJPFHelper.class"
99     }
100 }
101
102 task jpfJar(type: Jar) {
103     archiveName = "jpf.jar"
104     destinationDir = file("${buildDir}")
105
106     description = "Creates the ${archiveName} file."
107     group = "JPF Jars"
108
109     dependsOn compile
110
111     from sourceSets.main.java.outputDir
112     from sourceSets.peers.java.outputDir
113     from sourceSets.annotations.java.outputDir
114     from(sourceSets.classes.java.outputDir) {
115         include "org/junit/*.class"
116     }
117
118     manifest {
119         attributes(
120             "Built-By": System.getProperty("user.name"),
121             "Implementation-Vendor": "NASA Ames Research Center",
122             "Implementation-Title": "Java Pathfinder core system",
123             "Implementation-Version": "1234" //FIXME
124         )
125     }
126 }
127
128 task annotationsJar(type: Jar) {
129     archiveName = "jpf-annotations.jar"
130     destinationDir = file("${buildDir}")
131
132     description = "Creates the ${archiveName} file."
133     group = "JPF Jars"
134
135     dependsOn compile
136
137     from sourceSets.annotations.java.outputDir
138 }
139
140 task classloaderSpecificTestsJar(type: Jar) {
141     archiveName = "classloader_specific_tests.jar"
142     destinationDir = file("${buildDir}")
143
144     description = "Creates the ${archiveName} file."
145     group = "JPF Jars"
146
147     dependsOn compile
148
149     from(sourceSets.test.java.outputDir) {
150         include "classloader_specific_tests/*.class"
151     }
152 }
153
154 task runJpfJar(type: Jar) {
155     archiveName = "RunJPF.jar"
156     destinationDir = file("${buildDir}")
157
158     description = "Creates the ${archiveName} file."
159     group = "JPF Jars"
160
161     dependsOn compile
162
163     from(sourceSets.main.java.outputDir) {
164         include "gov/nasa/jpf/tool/Run.class"
165         include "gov/nasa/jpf/tool/RunJPF.class"
166         include "gov/nasa/jpf/Config.class"
167         include "gov/nasa/jpf/ConfigChangeListener.class"
168         include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
169         include "gov/nasa/jpf/JPFClassLoader.class"
170         include "gov/nasa/jpf/JPFShell.class"
171         include "gov/nasa/jpf/JPFException.class"
172         include "gov/nasa/jpf/JPFConfigException.class"
173         include "gov/nasa/jpf/JPFTargetException.class"
174         include "gov/nasa/jpf/util/JPFSiteUtils.class"
175         include "gov/nasa/jpf/util/FileUtils.class"
176         include "gov/nasa/jpf/util/StringMatcher.class"
177         include "gov/nasa/jpf/util/Pair.class"
178     }
179     manifest {
180         attributes(
181             "Built-By": System.getProperty("user.name"),
182             "Implementation-Vendor": "NASA Ames Research Center",
183             "Implementation-Title": "Java Pathfinder core launch system",
184             "Implementation-Version": "1234", //FIXME
185             "Main-Class": "gov.nasa.jpf.tool.RunJPF"
186         )
187     }
188 }
189
190 task runTestJar(type: Jar) {
191     archiveName = "RunTest.jar"
192     destinationDir = file("${buildDir}")
193
194     description = "Creates the ${archiveName} file."
195     group = "JPF Jars"
196
197     dependsOn compile
198
199     from(sourceSets.main.java.outputDir) {
200         include "gov/nasa/jpf/tool/Run.class"
201         include "gov/nasa/jpf/tool/RunTest.class"
202         include "gov/nasa/jpf/tool/RunTest\$Failed.class"
203         include "gov/nasa/jpf/Config.class"
204         include "gov/nasa/jpf/ConfigChangeListener.class"
205         include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
206         include "gov/nasa/jpf/JPFClassLoader.class"
207         include "gov/nasa/jpf/JPFException.class"
208         include "gov/nasa/jpf/JPFConfigException.class"
209         include "gov/nasa/jpf/util/JPFSiteUtils.class"
210         include "gov/nasa/jpf/util/FileUtils.class"
211         include "gov/nasa/jpf/util/StringMatcher.class"
212         include "gov/nasa/jpf/util/DevNullPrintStream.class"
213     }
214     manifest {
215         attributes(
216             "Built-By": System.getProperty("user.name"),
217             "Implementation-Vendor": "NASA Ames Research Center",
218             "Implementation-Title": "Java Pathfinder test launch system",
219             "Implementation-Version": "1234", // FIXME
220             "Main-Class": "gov.nasa.jpf.tool.RunTest"
221         )
222     }
223 }
224
225 task buildJars {
226     group = "JPF Build"
227     description = "Generates the core JPF jar files."
228
229     dependsOn classloaderSpecificTestsJar, annotationsJar,
230               jpfClassesJar, jpfJar, runJpfJar,
231               runTestJar
232 }
233
234 test {
235     group = "JPF Build"
236     description = "Runs core regression tests."
237
238     dependsOn buildJars
239
240     enableAssertions = true
241     forkEvery = 1
242
243     maxHeapSize = "1024m"
244
245     include "**/*Test.class"
246     exclude "**/SplitInputStreamTest.class"
247     exclude "**/JPF_*.class"
248
249     testLogging {
250         events "passed", "skipped", "failed"
251     }
252
253     afterSuite { testDescriptor, result ->
254         if (!testDescriptor.parent) {
255             println "Test Execution: ${result.resultType}"
256
257             def summaryFields = ["${result.testCount} tests",
258                                  "${result.successfulTestCount} passed",
259                                  "${result.failedTestCount} failed",
260                                  "${result.skippedTestCount} skipped"]
261
262             println "Summary: " + summaryFields.join(", ")
263         }
264     }
265 }
266
267 defaultTasks "buildJars"