e53f7e577ff6066080ad6241cb0e84acdbcf9391
[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 compile(type: Copy) {
52     group = "JPF Build"
53     description = "Compiles all JPF core sources."
54
55     // These are automatic generated tasks from the Java Gradle Plugin.
56     // Gradle is able to infer the ordering of the source sets
57     // due to the compileClasspath attribute
58     dependsOn compileTestJava, compileExamplesJava
59
60     // Copies build.properties file to the build directory
61     from "build.properties"
62     into sourceSets.main.java.outputDir.path + "/gov/nasa/jpf"
63 }
64
65 task jpfClassesJar(type: Jar) {
66     archiveName = "jpf-classes.jar"
67     destinationDir = file("${buildDir}")
68
69     description = "Creates the ${archiveName} file."
70     group = "JPF Jars"
71
72     dependsOn compile
73
74     from sourceSets.classes.java.outputDir
75     from sourceSets.annotations.java.outputDir
76     from(sourceSets.main.java.outputDir) {
77         include "gov/nasa/jpf/JPFShell.class"
78         include "gov/nasa/jpf/vm/Verify.class"
79         include "gov/nasa/jpf/util/TypeRef.class"
80         include "gov/nasa/jpf/util/test/TestJPF.class"
81         include "gov/nasa/jpf/util/test/TestMultiProcessJPF.class"
82         include "gov/nasa/jpf/util/test/TestJPFHelper.class"
83     }
84 }
85
86 task jpfJar(type: Jar) {
87     archiveName = "jpf.jar"
88     destinationDir = file("${buildDir}")
89
90     description = "Creates the ${archiveName} file."
91     group = "JPF Jars"
92
93     dependsOn compile
94
95     from sourceSets.main.java.outputDir
96     from sourceSets.peers.java.outputDir
97     from sourceSets.annotations.java.outputDir
98     from(sourceSets.classes.java.outputDir) {
99         include "org/junit/*.class"
100     }
101
102     manifest {
103         attributes(
104             "Built-By": System.getProperty("user.name"),
105             "Implementation-Vendor": "NASA Ames Research Center",
106             "Implementation-Title": "Java Pathfinder core system",
107             "Implementation-Version": "1234" //FIXME
108         )
109     }
110 }
111
112 task annotationsJar(type: Jar) {
113     archiveName = "jpf-annotations.jar"
114     destinationDir = file("${buildDir}")
115
116     description = "Creates the ${archiveName} file."
117     group = "JPF Jars"
118
119     dependsOn compile
120
121     from sourceSets.annotations.java.outputDir
122 }
123
124 task classloaderSpecificTestsJar(type: Jar) {
125     archiveName = "classloader_specific_tests.jar"
126     destinationDir = file("${buildDir}")
127
128     description = "Creates the ${archiveName} file."
129     group = "JPF Jars"
130
131     dependsOn compile
132
133     from(sourceSets.test.java.outputDir) {
134         include "classloader_specific_tests/*.class"
135     }
136 }
137
138 task runJpfJar(type: Jar) {
139     archiveName = "RunJPF.jar"
140     destinationDir = file("${buildDir}")
141
142     description = "Creates the ${archiveName} file."
143     group = "JPF Jars"
144
145     dependsOn compile
146
147     from(sourceSets.main.java.outputDir) {
148         include "gov/nasa/jpf/tool/Run.class"
149         include "gov/nasa/jpf/tool/RunJPF.class"
150         include "gov/nasa/jpf/Config.class"
151         include "gov/nasa/jpf/ConfigChangeListener.class"
152         include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
153         include "gov/nasa/jpf/JPFClassLoader.class"
154         include "gov/nasa/jpf/JPFShell.class"
155         include "gov/nasa/jpf/JPFException.class"
156         include "gov/nasa/jpf/JPFConfigException.class"
157         include "gov/nasa/jpf/JPFTargetException.class"
158         include "gov/nasa/jpf/util/JPFSiteUtils.class"
159         include "gov/nasa/jpf/util/FileUtils.class"
160         include "gov/nasa/jpf/util/StringMatcher.class"
161         include "gov/nasa/jpf/util/Pair.class"
162     }
163     manifest {
164         attributes(
165             "Built-By": System.getProperty("user.name"),
166             "Implementation-Vendor": "NASA Ames Research Center",
167             "Implementation-Title": "Java Pathfinder core launch system",
168             "Implementation-Version": "1234", //FIXME
169             "Main-Class": "gov.nasa.jpf.tool.RunJPF"
170         )
171     }
172 }
173
174 task runTestJar(type: Jar) {
175     archiveName = "RunTest.jar"
176     destinationDir = file("${buildDir}")
177
178     description = "Creates the ${archiveName} file."
179     group = "JPF Jars"
180
181     dependsOn compile
182
183     from(sourceSets.main.java.outputDir) {
184         include "gov/nasa/jpf/tool/Run.class"
185         include "gov/nasa/jpf/tool/RunTest.class"
186         include "gov/nasa/jpf/tool/RunTest\$Failed.class"
187         include "gov/nasa/jpf/Config.class"
188         include "gov/nasa/jpf/ConfigChangeListener.class"
189         include "gov/nasa/jpf/Config\$MissingRequiredKeyException.class"
190         include "gov/nasa/jpf/JPFClassLoader.class"
191         include "gov/nasa/jpf/JPFException.class"
192         include "gov/nasa/jpf/JPFConfigException.class"
193         include "gov/nasa/jpf/util/JPFSiteUtils.class"
194         include "gov/nasa/jpf/util/FileUtils.class"
195         include "gov/nasa/jpf/util/StringMatcher.class"
196         include "gov/nasa/jpf/util/DevNullPrintStream.class"
197     }
198     manifest {
199         attributes(
200             "Built-By": System.getProperty("user.name"),
201             "Implementation-Vendor": "NASA Ames Research Center",
202             "Implementation-Title": "Java Pathfinder test launch system",
203             "Implementation-Version": "1234", // FIXME
204             "Main-Class": "gov.nasa.jpf.tool.RunTest"
205         )
206     }
207 }
208
209 task buildJars {
210     group = "JPF Build"
211     description = "Generates the core JPF jar files."
212
213     dependsOn classloaderSpecificTestsJar, annotationsJar,
214               jpfClassesJar, jpfJar, runJpfJar,
215               runTestJar
216 }
217
218 test {
219     group = "JPF Build"
220     description = "Runs core regression tests."
221
222     dependsOn buildJars
223
224     enableAssertions = true
225     forkEvery = 1
226
227     maxHeapSize = "1024m"
228
229     include "**/*Test.class"
230     exclude "**/SplitInputStreamTest.class"
231     exclude "**/JPF_*.class"
232
233     // XXX Tests temporarily ignored because they are not fully supported in the Gradle build yet
234     new File("failing-tests.txt").eachLine { failedTestClass ->
235         def ignoredPath = "**/" + failedTestClass.replace(".", "/") + ".class"
236         exclude ignoredPath
237     }
238
239     testLogging {
240         events "passed", "skipped", "failed"
241     }
242
243     afterSuite { testDescriptor, result ->
244         if (!testDescriptor.parent) {
245             println "Test Execution: ${result.resultType}"
246
247             def summaryFields = ["${result.testCount} tests",
248                                  "${result.successfulTestCount} passed",
249                                  "${result.failedTestCount} failed",
250                                  "${result.skippedTestCount} skipped"]
251
252             println "Summary: " + summaryFields.join(", ")
253         }
254     }
255 }
256
257 defaultTasks "buildJars"