If JNI is not found, just use internal JNI.
[SquirrelJME.git] / build.gradle
blobbb4335be8b3a1c6877ce4e7c0d9687cab226c6c2
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                 // Flatpak
35                 excludeDirs += file(".flatpak-builder")
36                 excludeDirs += file("build-dir")
37                 
38                 // These are auto-generated by Fossil and should be ignored
39                 excludeDirs += file("manifest")
40                 excludeDirs += file("manifest.uuid")
41                 
42                 // NanoCoat files
43                 excludeDirs += file("nanocoat/build")
44                 excludeDirs += file("nanocoat/cmake-build-debug")
45                 excludeDirs += file("nanocoat/cmake-build-release")
46                 
47                 // RatufaCoat files
48                 excludeDirs += file("ratufacoat/build")
49                 excludeDirs += file("ratufacoat/cmake-build-debug")
50                 excludeDirs += file("ratufacoat/cmake-build-release")
51                 excludeDirs += file("ratufacoat/.sample")
52                 
53                 // IntelliJ's own dependency matrix output (in "out")
54                 project.allprojects.each() { Project subProj ->
55                         excludeDirs += subProj.projectDir.toPath().resolve("out").toFile()
56                         
57                         // Eclipse Junk
58                         excludeDirs += subProj.projectDir.toPath().resolve(".settings").toFile()
59                         excludeDirs += subProj.projectDir.toPath().resolve("bin").toFile()
60                 }
61         }
64 allprojects {
65         apply plugin: 'eclipse'
66         
67         repositories
68         {
69                 mavenCentral()
70         }
71         
72         // Eclipse IDE
73         plugins.withType(JavaPlugin) {
74                 def settingsDir = projectDir.toPath().resolve(".settings")
75                 def buildShipPrefs = settingsDir.resolve("org.eclipse.buildship.core.prefs")
76                 def pathToRoot = projectDir.toPath().relativize(rootDir.toPath())
77                 
78                 // Clean fix
79                 task cleanEclipseFixBuild {
80                         group "squirreljme"
81                         description "Cleans up after build fixes."
82                         
83                         doFirst {
84                                 // Just delete the buildship preferences
85                                 Files.deleteIfExists(buildShipPrefs)
86                         }
87                 }
88                 
89                 // Fix build
90                 task eclipseFixBuild {
91                         group "squirreljme"
92                         description "Fixes Eclipse build due to missing expected files."
93                         
94                         // If clean and such is ran, this must always be followed by it
95                         // since we could accidentally destroy it
96                         mustRunAfter cleanEclipseFixBuild, cleanEclipseJdt
97                         
98                         doFirst {
99                                 // Setup settings directory first
100                                 Files.createDirectories(settingsDir)
101                                 
102                                 // Write missing Eclipse file
103                                 Files.write(
104                                         buildShipPrefs,
105                                         Arrays.asList(
106                                                 "connection.project.dir=" + pathToRoot,
107                                                 "eclipse.preferences.version=1"),
108                                         StandardOpenOption.CREATE,
109                                         StandardOpenOption.WRITE,
110                                         StandardOpenOption.TRUNCATE_EXISTING)
111                         }
112                 }
113                 
114                 // Fix for cyclic dependencies
115                 eclipse.jdt {
116                         // We are a Java 8 project
117                         sourceCompatibility = 1.8
118                         targetCompatibility = 1.8
119                         
120                         // Fix for Eclipse and VSCode breaking on "circular" dependencies
121                         file.withProperties { properties ->
122                                 properties["org.eclipse.jdt.core.builder.invalidClasspath"] = "warning"
123                                 properties["org.eclipse.jdt.core.circularClasspath"] = "warning"
124                                 properties["org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource"] = "warning"
125                         }
126                 }
127                 
128                 eclipseJdt.finalizedBy(eclipseFixBuild)
129                 cleanEclipseJdt.finalizedBy(cleanEclipseFixBuild)
130         }
133 // Generic root clean task, does nothing by default and just depends on
134 // others
135 tasks.register('clean') {