Drop parameter annotations since we do not need them.
[SquirrelJME.git] / modules / build.gradle
blobae737ec7a8da38faab1870f939b5b448d7cbffbe
1 import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
2 import org.gradle.util.VersionNumber
4 plugins {
5         id "de.set.ecj" version "1.4.1" apply false
6         id "idea"
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())
15         
16         // If this is an even version, then this is a release version
17         if ((inVersion.minor % 2) == 0)
18                 return inVersion
19         
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
25 subprojects {
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"
30         }
31         
32         apply plugin: "java-library"
33         apply plugin: "java-test-fixtures"
34         apply plugin: "cc.squirreljme.plugin"
35         apply plugin: "idea"
36         apply plugin: "maven-publish"
37         apply plugin: "signing"
38         
39         // The Java versions this works with
40         sourceCompatibility = 8
41         targetCompatibility = 8
42         
43         idea {
44                 module
45                 {
46                         // This is 1.8 because 1.7 is not really available
47                         jdkName = "1.8"
48                         
49                         // However, everything targets 1.7 otherwise
50                         languageLevel = new IdeaLanguageLevel("1.7")
51                         targetBytecodeVersion = JavaVersion.VERSION_1_7
52                 }
53         }
54         
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)
62                 }
63         }
64         
65         // Configure the compiler
66         java {
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
76                 
77                 // Maximize debugging
78                 compileJava.options.debug = true
79                 compileJava.options.debugOptions.setDebugLevel("source,lines,vars")
81                 // Copy to tests
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
90                 // Copy to JavaDoc
91                 javadoc.options.source = "1.7"
92                 javadoc.options.tags = [ "squirreljme.property",
93                         "squirreljme.env",
94                         "squirreljme.error",
95                         "squirreljme.syscallparam",
96                         "squirreljme.syscallreturn",
97                         "squirreljme.tsiparam",
98                         "squirreljme.configtype",
99                         "squirreljme.uiwidgetparam" ]
100                         
101                 // Build sources and JavaDoc as well
102                 withSourcesJar()
103                 withJavadocJar()
104         }
106         // Enable SquirrelJME Tests
107         apply from: project.rootProject.findProject(":emulators:emulator-base").
108                 projectDir.toPath().resolve("enable-testing.gradle").toFile()
109         
110         // Publishing
111         publishing {
112                 // What is being published?
113                 publications {
114                         maven(MavenPublication) {
115                                 // Adjustments to the Maven POM
116                                 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/"
121                                         
122                                         // SquirrelJME started to exist in 2016!
123                                         inceptionYear = "2016"
124                                         
125                                         licenses {
126                                                 license {
127                                                         name = "GNU General Public License v3"
128                                                         url = "https://squirreljme.cc/file?name=LICENSE&ci=trunk"
129                                                 }
130                                         }
131                                         
132                                         developers {
133                                                 developer {
134                                                         id = "stephanie.gawroriski"
135                                                         name = "Stephanie Gawroriski"
136                                                         email = "xerthesquirrel@gmail.com"
137                                                 }
138                                         }
139                                         
140                                         contributors {
141                                                 contributor {
142                                                         name = "Stephanie Gawroriski"
143                                                         email = "xerthesquirrel@gmail.com"
144                                                         roles = [ "Primary Developer" ]
145                                                         timezone = "America/New_York"
146                                                         url = "https://shadowtail.dev/"
147                                                 }
148                                         }
149                                                 
150                                         scm {
151                                                 url = "https://squirreljme.cc/"
152                                                 connection = "fossil:https://squirreljme.cc/"
153                                         }
154                                         
155                                         organization {
156                                                 name = "SquirrelJME"
157                                                 url = "https://squirreljme.cc/"
158                                         }
159                                         
160                                         issueManagement {
161                                                 system = "GitHub"
162                                                 url = "https://github.com/SquirrelJME/SquirrelJME/issues"
163                                         }
164                                         
165                                         ciManagement {
166                                                 system = "CircleCI"
167                                                 url = "https://app.circleci.com/pipelines/github/SquirrelJME"
168                                         }
169                                         
170                                         withXml {
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)
175                                                 
176                                                 def propMap = asNode().appendNode("properties")
177                                                 
178                                                 // Properties that are needed by Maven, although
179                                                 // not recommended to use Maven for building
180                                                 propMap.appendNode("maven.compiler.source",
181                                                         "1.7")
182                                                 propMap.appendNode("maven.compiler.target",
183                                                         "1.7")
184                                                 propMap.appendNode("project.build.sourceEncoding",
185                                                         "UTF-8")
186                                                 
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))
203                                         }
204                                 }
205                                 
206                                 // Normal information
207                                 groupId = "cc.squirreljme.modules"
208                                 artifactId = project.name
209                                 version = normalizeMavenVersion(rootProject.version)
210                                 
211                                 // What is being published?
212                                 from components.java
213                         }
214                 }
215                 
216                 // Where is this to be published?
217                 repositories {
218                         // Publishing to local Maven
219                         mavenLocal()
220                         
221                         // OSSRH Repository (https://oss.sonatype.org/)
222                         maven {
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/")
227                                 
228                                 credentials {
229                                         username = findProperty("ossrhUser") ?: "ossrh_user_unset!"
230                                         password = findProperty("ossrhPassword") ?: "ossrh_pass_unset!"
231                                 }
232                         }
233                 }
234                 
235                 // IntelliJ adjustments
236                 idea {
237                         module {
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()
244                         }
245                 }
246         }
247         
248         // Signing publications
249         signing {
250                 required {
251                         false
252                 }
253                 
254                 // Load key into memory and the password
255                 def signingKeyId = findProperty("signingKeyId")
256                 def signingPassword = findProperty("signingPassword")
257                 
258                 def signingKeyBase64 = findProperty("signingKey")
259                 def signingKey = (signingKeyBase64 == null ? null :
260                         new String(Base64.getMimeDecoder()
261                                 .decode(signingKeyBase64.toString()), "utf-8"))
262                 
263                 // Use in memory key signing
264                 useInMemoryPgpKeys(/*signingKeyId,*/ signingKey, signingPassword)
265                 
266                 // The default Maven release becomes signed
267                 sign publishing.publications.maven
268         }
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
277     java {
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()
284                 // Copy to JavaDoc
285                 javadoc.options.bootClasspath = compileJava.options.bootstrapClasspath
286                         .collect()
287     }
289         dependencies {
290                 // All projects depend on the Compact CLDC Library
291                 api project(":modules:cldc-compact")
292         }