Browse Source

IconSet: Annotate generated classes as @Generated

pull/270/head
weisj 3 years ago
parent
commit
2491bda23e
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 5
      buildSrc/src/main/kotlin/GenerateIconAccessor.kt
  2. 2
      gradle/libs.versions.toml
  3. 7
      iconset/build.gradle.kts
  4. 1
      iconset/src/main/module/module-info.java

5
buildSrc/src/main/kotlin/GenerateIconAccessor.kt

@ -2,7 +2,7 @@ import java.io.File
import java.io.FileInputStream
import java.util.*
fun createIconAccessor(propertyFile: File, className: String): String {
fun createIconAccessor(propertyFile: File, packageName : String, className: String): String {
class Property(val name: String?, val path: String)
class AccessorTreeNode(
val nodes: MutableMap<String, AccessorTreeNode>,
@ -51,6 +51,7 @@ fun createIconAccessor(propertyFile: File, className: String): String {
createAccessorClass(it.key, it.value)
}.replace("\n", "\n ")
return """
|@javax.annotation.Generated(value = {"GenerateIconAccessor"})
|public ${if (topLevel) "" else "static "}final class ${name.capitalize()} {
| $properties
| $subNodes
@ -59,7 +60,7 @@ fun createIconAccessor(propertyFile: File, className: String): String {
}
return """
|package com.github.weisj.darklaf.iconset;
|package $packageName;
|
|import javax.swing.Icon;
|

2
gradle/libs.versions.toml

@ -14,6 +14,7 @@ macOSFramework = "latest.release"
javaNativeFoundation = "1.1.1"
errorprone = "2.8.1"
guava = "1.0"
javaxAnnotations = "1.3.2"
[libraries]
jxlayer = { module = "org.swinglabs:jxlayer", version.ref = "jxlayer" }
@ -24,6 +25,7 @@ visualPaddings = { module = "com.github.weisj:swing-extensions-visual-padding",
autoservice-annotations = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoservice" }
autoservice-processor = { module = "com.google.auto.service:auto-service", version.ref = "autoservice" }
nullabilityAnnotations = { module = "org.jetbrains:annotations", version.ref = "nullabilityAnnotations" }
javaxAnnotations = { module = "javax.annotation:javax.annotation-api", version.ref = "javaxAnnotations"}
# MacOS frameworks
macosLegacy-javaVM-base = { module = "dev.nokee.framework:JavaVM", version.ref = "macOSFramework" }

7
iconset/build.gradle.kts

@ -9,6 +9,7 @@ plugins {
dependencies {
api(projects.darklafPropertyLoader)
compileOnly(libs.javaxAnnotations)
}
fun Jar.includeLicenses() {
@ -36,9 +37,11 @@ val generateIconAccessor by tasks.registering {
val propertyFile = project.file("iconAccessorSpec.properties")
val allIconsName = "AllIcons"
generatedDir.mkdirs()
generatedDir.resolve("$allIconsName.java").apply {
val packageName = "com.github.weisj.darklaf.iconset"
generatedDir.resolve("${packageName.replace('.', '/')}/$allIconsName.java").apply {
parentFile.mkdirs()
createNewFile()
writeText(createIconAccessor(propertyFile, allIconsName))
writeText(createIconAccessor(propertyFile, packageName, allIconsName))
}
}
}

1
iconset/src/main/module/module-info.java

@ -24,6 +24,7 @@
*/
open module darklaf.iconset {
requires darklaf.properties;
requires static java.annotation;
exports com.github.weisj.darklaf.iconset;
}

Loading…
Cancel
Save