1 import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
2 import org.gradle.util.VersionNumber
5 id "de.set.ecj" version "1.4.1" apply false
9 group = "cc.squirreljme.modules"
10 description = "Modules which are a part of SquirrelJME."
12 // Helper function to normalize the Maven version
13 static VersionNumber normalizeMavenVersion(Object __inVersion) {
14 VersionNumber inVersion = VersionNumber.parse(__inVersion.toString())
16 // If this is an even version, then this is a release version
17 if ((inVersion.minor % 2) == 0)
20 // Otherwise odd numbers are considered to be "snapshot" versions
21 return VersionNumber.parse(inVersion.toString() + "-SNAPSHOT")
27 // This is 1.8 because 1.7 is not really available
28 jdkName = "squirreljme-8"
32 // Every sub-project needs SquirrelJME specific pieces
34 // Apply ECJ for compilation? (Such as too new of Java)
35 if (project.hasProperty("squirreljmeEcjEnabled") &&
36 project.squirreljmeEcjEnabled) {
37 apply plugin: "de.set.ecj"
40 apply plugin: "java-library"
41 apply plugin: "java-test-fixtures"
42 apply plugin: "cc.squirreljme.plugin"
44 apply plugin: "maven-publish"
45 apply plugin: "signing"
47 // The Java versions this works with
48 sourceCompatibility = 8
49 targetCompatibility = 8
54 // This is 1.8 because 1.7 is not really available
55 jdkName = "squirreljme-8"
57 // However, everything targets 1.7 otherwise
58 languageLevel = new IdeaLanguageLevel("1.7")
59 targetBytecodeVersion = JavaVersion.VERSION_1_7
63 // Disable native header generation when using ECJ as it does not have
64 // the -h option. See:
65 // https://github.com/gradle/gradle/issues/12904#issuecomment-619212927
66 if (project.hasProperty("squirreljmeEcjEnabled") &&
67 project.squirreljmeEcjEnabled) {
68 tasks.withType(JavaCompile) {
69 options.headerOutputDirectory.convention((Directory)null)
73 // Configure the compiler
75 // Java ME 8 is effectively Java 7, but use Java 8 here
76 compileJava.sourceCompatibility = JavaVersion.VERSION_1_7
77 compileJava.targetCompatibility = JavaVersion.VERSION_1_8
79 // All files are always in UTF-8 format
80 compileJava.options.encoding = "utf-8"
82 // Emit deprecation errors
83 compileJava.options.deprecation = true
86 compileJava.options.debug = true
87 compileJava.options.debugOptions.setDebugLevel("source,lines,vars")
90 compileTestJava.sourceCompatibility = compileJava.sourceCompatibility
91 compileTestJava.targetCompatibility = compileJava.targetCompatibility
92 compileTestJava.options.encoding = compileJava.options.encoding
93 compileTestJava.options.verbose = compileJava.options.verbose
94 compileTestJava.options.deprecation = compileJava.options.deprecation
95 compileTestJava.options.debug = compileJava.options.debug
96 compileTestJava.options.debugOptions = compileJava.options.debugOptions
99 javadoc.options.source = "1.7"
100 javadoc.options.tags = [ "squirreljme.property",
103 "squirreljme.syscallparam",
104 "squirreljme.syscallreturn",
105 "squirreljme.tsiparam",
106 "squirreljme.configtype",
107 "squirreljme.uiwidgetparam" ]
109 // Build sources and JavaDoc as well
114 // Enable SquirrelJME Tests
115 apply from: project.rootProject.findProject(":emulators:emulator-base").
116 projectDir.toPath().resolve("enable-testing.gradle").toFile()
120 // What is being published?
122 maven(MavenPublication) {
123 // Adjustments to the Maven POM
125 /*System.err.printf("Name/Desc: %s %s%n", project.squirreljme.swmName ?: project.name, project.description)
126 name = project.squirreljme.swmName ?: project.name
127 description = project.description*/
128 url = "https://squirreljme.cc/"
130 // SquirrelJME started to exist in 2016!
131 inceptionYear = "2016"
135 name = "GNU General Public License v3"
136 url = "https://squirreljme.cc/file?name=LICENSE&ci=trunk"
142 id = "stephanie.gawroriski"
143 name = "Stephanie Gawroriski"
144 email = "xerthesquirrel@gmail.com"
150 name = "Stephanie Gawroriski"
151 email = "xerthesquirrel@gmail.com"
152 roles = [ "Primary Developer" ]
153 timezone = "America/New_York"
154 url = "https://shadowtail.dev/"
159 url = "https://squirreljme.cc/"
160 connection = "fossil:https://squirreljme.cc/"
165 url = "https://squirreljme.cc/"
170 url = "https://github.com/SquirrelJME/SquirrelJME/issues"
175 url = "https://app.circleci.com/pipelines/github/SquirrelJME"
179 // Lazy evaluation of the project name and description so that it
180 // uses the proper name for Maven and otherwise
181 asNode().appendNode("name", project.squirreljme.swmName ?: project.name)
182 asNode().appendNode("description", project.description)
184 def propMap = asNode().appendNode("properties")
186 // Properties that are needed by Maven, although
187 // not recommended to use Maven for building
188 propMap.appendNode("maven.compiler.source",
190 propMap.appendNode("maven.compiler.target",
192 propMap.appendNode("project.build.sourceEncoding",
195 // SquirrelJME properties
196 if (project.squirreljme.swmType != null)
197 propMap.appendNode("squirreljme.type",
198 project.squirreljme.swmType)
199 propMap.appendNode("squirreljme.vendor",
200 project.squirreljme.swmVendor)
201 propMap.appendNode("squirreljme.errorCode",
202 project.squirreljme.javaDocErrorCode)
203 propMap.appendNode("squirreljme.configurations",
204 Objects.toString(project.squirreljme.definedConfigurations))
205 propMap.appendNode("squirreljme.profiles",
206 Objects.toString(project.squirreljme.definedProfiles))
207 propMap.appendNode("squirreljme.standards",
208 Objects.toString(project.squirreljme.definedStandards))
209 propMap.appendNode("squirreljme.midlets",
210 Objects.toString(project.squirreljme.midlets))
214 // Normal information
215 groupId = "cc.squirreljme.modules"
216 artifactId = project.name
217 version = normalizeMavenVersion(rootProject.version)
219 // What is being published?
224 // Where is this to be published?
226 // Publishing to local Maven
229 // OSSRH Repository (https://oss.sonatype.org/)
231 url = (normalizeMavenVersion(rootProject.version)
232 .toString().endsWith("-SNAPSHOT") ?
233 "https://oss.sonatype.org/content/repositories/snapshots/" :
234 "https://oss.sonatype.org/service/local/staging/deploy/maven2/")
237 username = findProperty("ossrhUser") ?: "ossrh_user_unset!"
238 password = findProperty("ossrhPassword") ?: "ossrh_pass_unset!"
243 // IntelliJ adjustments
246 // Make testFixtures as part of tests so that in search and
247 // otherwise they appear as such
248 testSourceDirs += project.projectDir.toPath().resolve("src")
249 .resolve("testFixtures").resolve("java").toFile()
250 testResourceDirs += project.projectDir.toPath().resolve("src")
251 .resolve("testFixtures").resolve("resources").toFile()
256 // Signing publications
262 // Load key into memory and the password
263 def signingKeyId = findProperty("signingKeyId")
264 def signingPassword = findProperty("signingPassword")
266 def signingKeyBase64 = findProperty("signingKey")
267 def signingKey = (signingKeyBase64 == null ? null :
268 new String(Base64.getMimeDecoder()
269 .decode(signingKeyBase64.toString()), "utf-8"))
271 // Use in memory key signing
272 useInMemoryPgpKeys(/*signingKeyId,*/ signingKey, signingPassword)
274 // The default Maven release becomes signed
275 sign publishing.publications.maven
279 // Properties for every sub-project, except for cldc-compact as it is special
280 configure(subprojects
281 - project(":modules:cldc-compact")) {
282 apply plugin: "java-library"
284 // All projects use the base classpath
286 // Only use SquirrelJME's boot classes, not the system SDK
287 Project cldcCompactProject = project(":modules:cldc-compact")
288 compileJava.options.bootstrapClasspath = project.objects.
289 fileCollection().from(cldcCompactProject.buildDir.toPath().
290 resolve("classes").resolve("java").resolve("main")).getAsFileTree()
293 javadoc.options.bootClasspath = compileJava.options.bootstrapClasspath
298 // All projects depend on the Compact CLDC Library
299 api project(":modules:cldc-compact")