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")
24 // Every sub-project needs SquirrelJME specific pieces
26 // Apply ECJ for compilation? (Such as too new of Java)
27 if (project.hasProperty("squirreljmeEcjEnabled") &&
28 project.squirreljmeEcjEnabled) {
29 apply plugin: "de.set.ecj"
32 apply plugin: "java-library"
33 apply plugin: "java-test-fixtures"
34 apply plugin: "cc.squirreljme.plugin"
36 apply plugin: "maven-publish"
37 apply plugin: "signing"
39 // The Java versions this works with
40 sourceCompatibility = 8
41 targetCompatibility = 8
46 // This is 1.8 because 1.7 is not really available
49 // However, everything targets 1.7 otherwise
50 languageLevel = new IdeaLanguageLevel("1.7")
51 targetBytecodeVersion = JavaVersion.VERSION_1_7
55 // Disable native header generation when using ECJ as it does not have
56 // the -h option. See:
57 // https://github.com/gradle/gradle/issues/12904#issuecomment-619212927
58 if (project.hasProperty("squirreljmeEcjEnabled") &&
59 project.squirreljmeEcjEnabled) {
60 tasks.withType(JavaCompile) {
61 options.headerOutputDirectory.convention((Directory)null)
65 // Configure the compiler
67 // Java ME 8 is effectively Java 7, but use Java 8 here
68 compileJava.sourceCompatibility = JavaVersion.VERSION_1_7
69 compileJava.targetCompatibility = JavaVersion.VERSION_1_8
71 // All files are always in UTF-8 format
72 compileJava.options.encoding = "utf-8"
74 // Emit deprecation errors
75 compileJava.options.deprecation = true
78 compileJava.options.debug = true
79 compileJava.options.debugOptions.setDebugLevel("source,lines,vars")
82 compileTestJava.sourceCompatibility = compileJava.sourceCompatibility
83 compileTestJava.targetCompatibility = compileJava.targetCompatibility
84 compileTestJava.options.encoding = compileJava.options.encoding
85 compileTestJava.options.verbose = compileJava.options.verbose
86 compileTestJava.options.deprecation = compileJava.options.deprecation
87 compileTestJava.options.debug = compileJava.options.debug
88 compileTestJava.options.debugOptions = compileJava.options.debugOptions
91 javadoc.options.source = "1.7"
92 javadoc.options.tags = [ "squirreljme.property",
95 "squirreljme.syscallparam",
96 "squirreljme.syscallreturn",
97 "squirreljme.tsiparam",
98 "squirreljme.configtype",
99 "squirreljme.uiwidgetparam" ]
101 // Build sources and JavaDoc as well
106 // Enable SquirrelJME Tests
107 apply from: project.rootProject.findProject(":emulators:emulator-base").
108 projectDir.toPath().resolve("enable-testing.gradle").toFile()
112 // What is being published?
114 maven(MavenPublication) {
115 // Adjustments to the Maven POM
117 /*System.err.printf("Name/Desc: %s %s%n", project.squirreljme.swmName ?: project.name, project.description)
118 name = project.squirreljme.swmName ?: project.name
119 description = project.description*/
120 url = "https://squirreljme.cc/"
122 // SquirrelJME started to exist in 2016!
123 inceptionYear = "2016"
127 name = "GNU General Public License v3"
128 url = "https://squirreljme.cc/file?name=LICENSE&ci=trunk"
134 id = "stephanie.gawroriski"
135 name = "Stephanie Gawroriski"
136 email = "xerthesquirrel@gmail.com"
142 name = "Stephanie Gawroriski"
143 email = "xerthesquirrel@gmail.com"
144 roles = [ "Primary Developer" ]
145 timezone = "America/New_York"
146 url = "https://shadowtail.dev/"
151 url = "https://squirreljme.cc/"
152 connection = "fossil:https://squirreljme.cc/"
157 url = "https://squirreljme.cc/"
162 url = "https://github.com/SquirrelJME/SquirrelJME/issues"
167 url = "https://app.circleci.com/pipelines/github/SquirrelJME"
171 // Lazy evaluation of the project name and description so that it
172 // uses the proper name for Maven and otherwise
173 asNode().appendNode("name", project.squirreljme.swmName ?: project.name)
174 asNode().appendNode("description", project.description)
176 def propMap = asNode().appendNode("properties")
178 // Properties that are needed by Maven, although
179 // not recommended to use Maven for building
180 propMap.appendNode("maven.compiler.source",
182 propMap.appendNode("maven.compiler.target",
184 propMap.appendNode("project.build.sourceEncoding",
187 // SquirrelJME properties
188 if (project.squirreljme.swmType != null)
189 propMap.appendNode("squirreljme.type",
190 project.squirreljme.swmType)
191 propMap.appendNode("squirreljme.vendor",
192 project.squirreljme.swmVendor)
193 propMap.appendNode("squirreljme.errorCode",
194 project.squirreljme.javaDocErrorCode)
195 propMap.appendNode("squirreljme.configurations",
196 Objects.toString(project.squirreljme.definedConfigurations))
197 propMap.appendNode("squirreljme.profiles",
198 Objects.toString(project.squirreljme.definedProfiles))
199 propMap.appendNode("squirreljme.standards",
200 Objects.toString(project.squirreljme.definedStandards))
201 propMap.appendNode("squirreljme.midlets",
202 Objects.toString(project.squirreljme.midlets))
206 // Normal information
207 groupId = "cc.squirreljme.modules"
208 artifactId = project.name
209 version = normalizeMavenVersion(rootProject.version)
211 // What is being published?
216 // Where is this to be published?
218 // Publishing to local Maven
221 // OSSRH Repository (https://oss.sonatype.org/)
223 url = (normalizeMavenVersion(rootProject.version)
224 .toString().endsWith("-SNAPSHOT") ?
225 "https://oss.sonatype.org/content/repositories/snapshots/" :
226 "https://oss.sonatype.org/service/local/staging/deploy/maven2/")
229 username = findProperty("ossrhUser") ?: "ossrh_user_unset!"
230 password = findProperty("ossrhPassword") ?: "ossrh_pass_unset!"
235 // IntelliJ adjustments
238 // Make testFixtures as part of tests so that in search and
239 // otherwise they appear as such
240 testSourceDirs += project.projectDir.toPath().resolve("src")
241 .resolve("testFixtures").resolve("java").toFile()
242 testResourceDirs += project.projectDir.toPath().resolve("src")
243 .resolve("testFixtures").resolve("resources").toFile()
248 // Signing publications
254 // Load key into memory and the password
255 def signingKeyId = findProperty("signingKeyId")
256 def signingPassword = findProperty("signingPassword")
258 def signingKeyBase64 = findProperty("signingKey")
259 def signingKey = (signingKeyBase64 == null ? null :
260 new String(Base64.getMimeDecoder()
261 .decode(signingKeyBase64.toString()), "utf-8"))
263 // Use in memory key signing
264 useInMemoryPgpKeys(/*signingKeyId,*/ signingKey, signingPassword)
266 // The default Maven release becomes signed
267 sign publishing.publications.maven
271 // Properties for every sub-project, except for cldc-compact as it is special
272 configure(subprojects
273 - project(":modules:cldc-compact")) {
274 apply plugin: "java-library"
276 // All projects use the base classpath
278 // Only use SquirrelJME's boot classes, not the system SDK
279 Project cldcCompactProject = project(":modules:cldc-compact")
280 compileJava.options.bootstrapClasspath = project.objects.
281 fileCollection().from(cldcCompactProject.buildDir.toPath().
282 resolve("classes").resolve("java").resolve("main")).getAsFileTree()
285 javadoc.options.bootClasspath = compileJava.options.bootstrapClasspath
290 // All projects depend on the Compact CLDC Library
291 api project(":modules:cldc-compact")