Base for showing the thread that was selected.
[SquirrelJME.git] / build.gradle
blob68335e66e8445b55ce21b16d93dfa3657aff7d85
1 import java.nio.file.Files
2 import java.nio.file.StandardOpenOption
4 apply plugin: 'idea'
5 apply plugin: 'eclipse'
6 apply plugin: 'cc.squirreljme.plugin.general'
8 group = "cc.squirreljme"
9 description = "SquirrelJME is a Java ME 8 Virtual Machine for embedded " +
10         "and Internet of Things devices. It has the ultimate goal of being " +
11         "99.9% compatible with the Java ME standard."
12 version = squirreljmeVersion
14 // IntelliJ Configuration (because the root project is a bit different)
15 idea
17         module
18         {
19                 // Use the proper name for this module
20                 name = "SquirrelJME"
22                 // Exclude these directories so IntelliJ does not pick these up
23                 // in inspections and builds
24                 excludeDirs += file(".circleci")
25                 excludeDirs += file(".fossil-settings")
26                 excludeDirs += file(".github")
27                 excludeDirs += file(".idea")
28                 excludeDirs += file(".vscode")
29                 excludeDirs += file(".settings")
30                 excludeDirs += file("config")
31                 excludeDirs += file("gradle")
32                 excludeDirs += file("utils-dev")
33                 
34                 // These are auto-generated by Fossil and should be ignored
35                 excludeDirs += file("manifest")
36                 excludeDirs += file("manifest.uuid")
37                 
38                 // RatufaCoat files
39                 excludeDirs += file("ratufacoat/build")
40                 excludeDirs += file("ratufacoat/cmake-build-debug")
41                 excludeDirs += file("ratufacoat/cmake-build-release")
42                 excludeDirs += file("ratufacoat/.sample")
43                 
44                 // IntelliJ's own dependency matrix output (in "out")
45                 project.allprojects.each() { Project subProj ->
46                         excludeDirs += subProj.projectDir.toPath().resolve("out").toFile()
47                         
48                         // Eclipse Junk
49                         excludeDirs += subProj.projectDir.toPath().resolve(".settings").toFile()
50                         excludeDirs += subProj.projectDir.toPath().resolve("bin").toFile()
51                 }
52         }
55 allprojects {
56         apply plugin: 'eclipse'
57         
58         repositories
59         {
60                 mavenCentral()
61         }
62         
63         // Eclipse IDE
64         plugins.withType(JavaPlugin) {
65                 def settingsDir = projectDir.toPath().resolve(".settings")
66                 def buildShipPrefs = settingsDir.resolve("org.eclipse.buildship.core.prefs")
67                 def pathToRoot = projectDir.toPath().relativize(rootDir.toPath())
68                 
69                 // Clean fix
70                 task cleanEclipseFixBuild {
71                         group "squirreljme"
72                         description "Cleans up after build fixes."
73                         
74                         doFirst {
75                                 // Just delete the buildship preferences
76                                 Files.deleteIfExists(buildShipPrefs)
77                         }
78                 }
79                 
80                 // Fix build
81                 task eclipseFixBuild {
82                         group "squirreljme"
83                         description "Fixes Eclipse build due to missing expected files."
84                         
85                         // If clean and such is ran, this must always be followed by it
86                         // since we could accidentally destroy it
87                         mustRunAfter cleanEclipseFixBuild, cleanEclipseJdt
88                         
89                         doFirst {
90                                 // Setup settings directory first
91                                 Files.createDirectories(settingsDir)
92                                 
93                                 // Write missing Eclipse file
94                                 Files.write(
95                                         buildShipPrefs,
96                                         Arrays.asList(
97                                                 "connection.project.dir=" + pathToRoot,
98                                                 "eclipse.preferences.version=1"),
99                                         StandardOpenOption.CREATE,
100                                         StandardOpenOption.WRITE,
101                                         StandardOpenOption.TRUNCATE_EXISTING)
102                         }
103                 }
104                 
105                 // Fix for cyclic dependencies
106                 eclipse.jdt {
107                         // We are a Java 8 project
108                         sourceCompatibility = 1.8
109                         targetCompatibility = 1.8
110                         
111                         // Fix for Eclipse and VSCode breaking on "circular" dependencies
112                         file.withProperties { properties ->
113                                 properties["org.eclipse.jdt.core.builder.invalidClasspath"] = "warning"
114                                 properties["org.eclipse.jdt.core.circularClasspath"] = "warning"
115                                 properties["org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource"] = "warning"
116                         }
117                 }
118                 
119                 eclipseJdt.finalizedBy(eclipseFixBuild)
120                 cleanEclipseJdt.finalizedBy(cleanEclipseFixBuild)
121         }
124 // Generic root clean task, does nothing by default and just depends on
125 // others
126 tasks.register('clean') {