User: rednesto Date: 13 Sep 24 10:05 Revision: e941c85dc32e4824f4420f58796d6d9a2c36bfa9 Summary: Fix #2360 Lazily create LibraryKinds The platform started complaining about initializing these during class init, even though we use holder classes specifically for them. Using a lazy delegate should no longer trigger this warning. TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9678&personal=false Index: src/main/kotlin/facet/MinecraftLibraryKinds.kt =================================================================== --- src/main/kotlin/facet/MinecraftLibraryKinds.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/facet/MinecraftLibraryKinds.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -35,19 +35,21 @@ import com.demonwav.mcdev.platform.sponge.framework.SPONGE_LIBRARY_KIND import com.demonwav.mcdev.platform.velocity.framework.VELOCITY_LIBRARY_KIND -val MINECRAFT_LIBRARY_KINDS = setOf( +val MINECRAFT_LIBRARY_KINDS by lazy { + setOf( - BUKKIT_LIBRARY_KIND, - SPIGOT_LIBRARY_KIND, - PAPER_LIBRARY_KIND, - SPONGE_LIBRARY_KIND, - FORGE_LIBRARY_KIND, - NEOFORGE_LIBRARY_KIND, - FABRIC_LIBRARY_KIND, - ARCHITECTURY_LIBRARY_KIND, - MCP_LIBRARY_KIND, - MIXIN_LIBRARY_KIND, - BUNGEECORD_LIBRARY_KIND, - WATERFALL_LIBRARY_KIND, - VELOCITY_LIBRARY_KIND, - ADVENTURE_LIBRARY_KIND, -) + BUKKIT_LIBRARY_KIND, + SPIGOT_LIBRARY_KIND, + PAPER_LIBRARY_KIND, + SPONGE_LIBRARY_KIND, + FORGE_LIBRARY_KIND, + NEOFORGE_LIBRARY_KIND, + FABRIC_LIBRARY_KIND, + ARCHITECTURY_LIBRARY_KIND, + MCP_LIBRARY_KIND, + MIXIN_LIBRARY_KIND, + BUNGEECORD_LIBRARY_KIND, + WATERFALL_LIBRARY_KIND, + VELOCITY_LIBRARY_KIND, + ADVENTURE_LIBRARY_KIND, + ) +} Index: src/main/kotlin/platform/adventure/framework/AdventureLibraryKind.kt =================================================================== --- src/main/kotlin/platform/adventure/framework/AdventureLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/adventure/framework/AdventureLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val ADVENTURE_LIBRARY_KIND: LibraryKind = libraryKind("adventure-api") +val ADVENTURE_LIBRARY_KIND: LibraryKind by libraryKind("adventure-api") Index: src/main/kotlin/platform/architectury/framework/ArchitecturyLibraryKind.kt =================================================================== --- src/main/kotlin/platform/architectury/framework/ArchitecturyLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/architectury/framework/ArchitecturyLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val ARCHITECTURY_LIBRARY_KIND: LibraryKind = libraryKind("architectury-api") +val ARCHITECTURY_LIBRARY_KIND: LibraryKind by libraryKind("architectury-api") Index: src/main/kotlin/platform/bukkit/framework/BukkitLibraryKind.kt =================================================================== --- src/main/kotlin/platform/bukkit/framework/BukkitLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/bukkit/framework/BukkitLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,6 +23,6 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val BUKKIT_LIBRARY_KIND: LibraryKind = libraryKind("bukkit-api") -val SPIGOT_LIBRARY_KIND: LibraryKind = libraryKind("spigot-api") -val PAPER_LIBRARY_KIND: LibraryKind = libraryKind("paper-api") +val BUKKIT_LIBRARY_KIND: LibraryKind by libraryKind("bukkit-api") +val SPIGOT_LIBRARY_KIND: LibraryKind by libraryKind("spigot-api") +val PAPER_LIBRARY_KIND: LibraryKind by libraryKind("paper-api") Index: src/main/kotlin/platform/bungeecord/framework/BungeeCordLibraryKind.kt =================================================================== --- src/main/kotlin/platform/bungeecord/framework/BungeeCordLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/bungeecord/framework/BungeeCordLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,5 +23,5 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val BUNGEECORD_LIBRARY_KIND: LibraryKind = libraryKind("bungeecord-api") -val WATERFALL_LIBRARY_KIND: LibraryKind = libraryKind("waterfall-api") +val BUNGEECORD_LIBRARY_KIND: LibraryKind by libraryKind("bungeecord-api") +val WATERFALL_LIBRARY_KIND: LibraryKind by libraryKind("waterfall-api") Index: src/main/kotlin/platform/fabric/framework/FabricLibraryKind.kt =================================================================== --- src/main/kotlin/platform/fabric/framework/FabricLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/fabric/framework/FabricLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val FABRIC_LIBRARY_KIND: LibraryKind = libraryKind("fabric-library") +val FABRIC_LIBRARY_KIND: LibraryKind by libraryKind("fabric-library") Index: src/main/kotlin/platform/forge/framework/ForgeLibraryKind.kt =================================================================== --- src/main/kotlin/platform/forge/framework/ForgeLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/forge/framework/ForgeLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val FORGE_LIBRARY_KIND: LibraryKind = libraryKind("forge-library") +val FORGE_LIBRARY_KIND: LibraryKind by libraryKind("forge-library") Index: src/main/kotlin/platform/mcp/framework/McpLibraryKind.kt =================================================================== --- src/main/kotlin/platform/mcp/framework/McpLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/mcp/framework/McpLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val MCP_LIBRARY_KIND: LibraryKind = libraryKind("mcp-library") +val MCP_LIBRARY_KIND: LibraryKind by libraryKind("mcp-library") Index: src/main/kotlin/platform/mixin/framework/MixinLibraryKind.kt =================================================================== --- src/main/kotlin/platform/mixin/framework/MixinLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/mixin/framework/MixinLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val MIXIN_LIBRARY_KIND: LibraryKind = libraryKind("mixin-library") +val MIXIN_LIBRARY_KIND: LibraryKind by libraryKind("mixin-library") Index: src/main/kotlin/platform/neoforge/framework/NeoForgeLibraryKind.kt =================================================================== --- src/main/kotlin/platform/neoforge/framework/NeoForgeLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/neoforge/framework/NeoForgeLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val NEOFORGE_LIBRARY_KIND: LibraryKind = libraryKind("neoforge-library") +val NEOFORGE_LIBRARY_KIND: LibraryKind by libraryKind("neoforge-library") Index: src/main/kotlin/platform/sponge/framework/SpongeLibraryKind.kt =================================================================== --- src/main/kotlin/platform/sponge/framework/SpongeLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/sponge/framework/SpongeLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val SPONGE_LIBRARY_KIND: LibraryKind = libraryKind("sponge-api") +val SPONGE_LIBRARY_KIND: LibraryKind by libraryKind("sponge-api") Index: src/main/kotlin/platform/velocity/framework/VelocityLibraryKind.kt =================================================================== --- src/main/kotlin/platform/velocity/framework/VelocityLibraryKind.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/platform/velocity/framework/VelocityLibraryKind.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -23,4 +23,4 @@ import com.demonwav.mcdev.util.libraryKind import com.intellij.openapi.roots.libraries.LibraryKind -val VELOCITY_LIBRARY_KIND: LibraryKind = libraryKind("velocity-api") +val VELOCITY_LIBRARY_KIND: LibraryKind by libraryKind("velocity-api") Index: src/main/kotlin/util/utils.kt =================================================================== --- src/main/kotlin/util/utils.kt (revision 0ba6095280e26cf70c6afdd1d318fc28d37924cd) +++ src/main/kotlin/util/utils.kt (revision e941c85dc32e4824f4420f58796d6d9a2c36bfa9) @@ -361,7 +361,8 @@ return this.firstOrNull { it is T } as? T } -fun libraryKind(id: String): LibraryKind = LibraryKindRegistry.getInstance().findKindById(id) ?: LibraryKind.create(id) +fun libraryKind(id: String): Lazy = + lazy { LibraryKindRegistry.getInstance().findKindById(id) ?: LibraryKind.create(id) } fun String.capitalize(): String = replaceFirstChar {