From ebf5b8cf432903f85c37a561ef0fe168fd81b392 Mon Sep 17 00:00:00 2001 From: shartte Date: Wed, 1 Jan 2025 20:20:02 +0100 Subject: [PATCH] Align source formatting with the NeoForge project code style (#214) --- .../generated/MinecraftVersionList.java | 33 ++++--- .../moddevgradle/boot/TrampolinePlugin.java | 7 +- .../legacyforge/dsl/LegacyForgeExtension.java | 7 +- .../dsl/LegacyForgeModdingSettings.java | 7 +- .../legacyforge/dsl/MixinCompilerArgs.java | 11 +-- .../legacyforge/dsl/MixinExtension.java | 8 +- .../legacyforge/dsl/ObfuscationExtension.java | 27 +++-- .../LegacyForgeMetadataTransform.java | 5 +- .../internal/LegacyForgeModDevPlugin.java | 21 ++-- .../internal/LegacyMetadataTransform.java | 9 +- .../internal/McpMetadataTransform.java | 6 +- .../internal/MinecraftMappings.java | 3 +- .../internal/RemappingTransform.java | 11 +-- .../legacyforge/tasks/RemapJar.java | 9 +- .../legacyforge/tasks/RemapOperation.java | 22 ++--- .../DefaultValueDisambiguationRule.java | 3 +- .../MinecraftDependenciesPlugin.java | 10 +- .../moddevgradle/dsl/DataFileCollection.java | 5 +- .../moddevgradle/dsl/InternalModelHelper.java | 7 +- .../moddevgradle/dsl/ModDevExtension.java | 9 +- .../neoforged/moddevgradle/dsl/ModModel.java | 5 +- .../dsl/ModdingVersionSettings.java | 7 +- .../moddevgradle/dsl/NeoForgeExtension.java | 10 +- .../neoforged/moddevgradle/dsl/Parchment.java | 23 ++--- .../neoforged/moddevgradle/dsl/RunModel.java | 11 +-- .../neoforged/moddevgradle/dsl/UnitTest.java | 6 +- .../internal/CreateLaunchScriptTask.java | 47 ++++----- .../internal/DataFileCollections.java | 18 ++-- .../internal/EclipseIntegration.java | 41 ++++---- .../moddevgradle/internal/IdeIntegration.java | 25 ++--- .../internal/IntelliJIntegration.java | 54 +++++----- .../IntelliJOutputDirectoryValueSource.java | 22 ++--- .../internal/ModDevArtifactsWorkflow.java | 55 +++++------ .../moddevgradle/internal/ModDevPlugin.java | 13 +-- .../internal/ModDevRunWorkflow.java | 76 +++++++------- .../internal/ModdingDependencies.java | 21 ++-- .../moddevgradle/internal/NeoDevFacade.java | 62 +++++------- .../moddevgradle/internal/PrepareRun.java | 3 +- .../internal/PrepareRunOrTest.java | 48 ++++----- .../moddevgradle/internal/PrepareTest.java | 3 +- .../internal/RepositoriesPlugin.java | 9 +- .../moddevgradle/internal/RunGameTask.java | 13 +-- .../moddevgradle/internal/RunUtils.java | 60 +++++------ .../moddevgradle/internal/UserDevConfig.java | 2 - .../moddevgradle/internal/UserDevRunType.java | 3 +- .../internal/VsCodeIntegration.java | 17 ++-- .../internal/WorkflowArtifact.java | 1 + .../internal/WriteLegacyClasspath.java | 14 ++- .../internal/jarjar/JarJarArtifacts.java | 37 +++---- .../internal/jarjar/JarJarPlugin.java | 2 - .../jarjar/ResolvedJarJarArtifact.java | 13 +-- .../internal/utils/DependencyUtils.java | 3 +- .../internal/utils/ExtensionUtils.java | 3 +- .../internal/utils/FileUtils.java | 14 +-- .../internal/utils/IdeDetection.java | 4 +- .../utils/NetworkSettingPassthrough.java | 11 +-- .../internal/utils/PropertyUtils.java | 4 +- .../internal/utils/StringUtils.java | 6 +- .../utils/VersionCapabilitiesInternal.java | 12 +-- .../neoforged/moddevgradle/tasks/JarJar.java | 33 +++---- .../nfrtgradle/ArtifactManifestEntry.java | 13 ++- .../nfrtgradle/CreateMinecraftArtifacts.java | 11 +-- .../neoforged/nfrtgradle/DownloadAssets.java | 29 +++--- .../nfrtgradle/NeoFormRuntimeExtension.java | 3 +- .../nfrtgradle/NeoFormRuntimeTask.java | 23 ++--- .../AbstractProjectBuilderTest.java | 11 +-- .../moddevgradle/dsl/ParchmentTest.java | 8 +- .../functional/AbstractFunctionalTest.java | 10 +- .../DataFileCollectionFunctionalTest.java | 39 +++----- .../functional/GroovyScriptTest.java | 11 +-- .../functional/KotlinScriptTest.java | 9 +- .../functional/ValidationTests.java | 11 +-- .../AccessTransformerConventionTest.java | 11 +-- .../internal/ModDevPluginTest.java | 26 ++--- .../moddevgradle/internal/RunUtilsTest.java | 8 +- .../VersionCapabilitiesInternalTest.java | 6 +- .../legacyforge/LegacyModDevPluginTest.java | 21 ++-- .../legacyforge/dsl/MixinMappingTest.java | 4 +- .../moddevgradle/tasks/JarJarTest.java | 99 ++++++++----------- 79 files changed, 582 insertions(+), 802 deletions(-) diff --git a/src/generated/java/net/neoforged/moddevgradle/internal/generated/MinecraftVersionList.java b/src/generated/java/net/neoforged/moddevgradle/internal/generated/MinecraftVersionList.java index f3ab5e5f..6eef2c5d 100644 --- a/src/generated/java/net/neoforged/moddevgradle/internal/generated/MinecraftVersionList.java +++ b/src/generated/java/net/neoforged/moddevgradle/internal/generated/MinecraftVersionList.java @@ -4,28 +4,39 @@ import java.util.List; public final class MinecraftVersionList { - private MinecraftVersionList() { - } + private MinecraftVersionList() {} /** * Released Minecraft Versions as of 2024-12-06T12:54:48.337462300Z from latest to oldest. */ - public static final List VERSIONS = List.of("1.21.4", "1.21.4-rc3", "1.21.4-rc2", "1.21.4-rc1", "1.21.4-pre3", "1.21.4-pre2", "1.21.4-pre1", "24w46a", "24w45a", "24w44a", "1.21.3", "1.21.2", "1.21.2-rc2", "1.21.2-rc1", "1.21.2-pre5", "1.21.2-pre4", "1.21.2-pre3", "1.21.2-pre2", "1.21.2-pre1", "24w40a", "24w39a", "24w38a", "24w37a", "24w36a", "24w35a", "24w34a", "24w33a", "1.21.1", "1.21.1-rc1", "1.21", "1.21-rc1", "1.21-pre4", "1.21-pre3", "1.21-pre2", "1.21-pre1", "24w21b", "24w21a", "24w20a", "24w19b", "24w19a", "24w18a", "1.20.6", "1.20.6-rc1", "1.20.5", "1.20.5-rc3", "1.20.5-rc2", "1.20.5-rc1", "1.20.5-pre4", "1.20.5-pre3", "1.20.5-pre2", "1.20.5-pre1", "24w14a", "24w14potato", "24w13a", "24w12a", "24w11a", "24w10a", "24w09a", "24w07a", "24w06a", "24w05b", "24w05a", "24w04a", "24w03b", "24w03a", "23w51b", "23w51a", "1.20.4", "1.20.4-rc1", "1.20.3", "1.20.3-rc1", "1.20.3-pre4", "1.20.3-pre3", "1.20.3-pre2", "1.20.3-pre1", "23w46a", "23w45a", "23w44a", "23w43b", "23w43a", "23w42a", "23w41a", "23w40a", "1.20.2", "1.20.2-rc2", "1.20.2-rc1", "1.20.2-pre4", "1.20.2-pre3", "1.20.2-pre2", "1.20.2-pre1", "23w35a", "23w33a", "23w32a", "23w31a", "1.20.1", "1.20.1-rc1", "1.20", "1.20-rc1", "1.20-pre7", "1.20-pre6", "1.20-pre5", "1.20-pre4", "1.20-pre3", "1.20-pre2", "1.20-pre1", "23w18a", "23w17a", "23w16a", "23w14a", "23w13a_or_b", "23w13a", "23w12a", "1.19.4", "1.19.4-rc3", "1.19.4-rc2", "1.19.4-rc1", "1.19.4-pre4", "1.19.4-pre3", "1.19.4-pre2", "1.19.4-pre1", "23w07a", "23w06a", "23w05a", "23w04a", "23w03a", "1.19.3", "1.19.3-rc3", "1.19.3-rc2", "1.19.3-rc1", "1.19.3-pre3", "1.19.3-pre2", "1.19.3-pre1", "22w46a", "22w45a", "22w44a", "22w43a", "22w42a", "1.19.2", "1.19.2-rc2", "1.19.2-rc1", "1.19.1", "1.19.1-rc3", "1.19.1-rc2", "1.19.1-pre6", "1.19.1-pre5", "1.19.1-pre4", "1.19.1-pre3", "1.19.1-pre2", "1.19.1-rc1", "1.19.1-pre1", "22w24a", "1.19", "1.19-rc2", "1.19-rc1", "1.19-pre5", "1.19-pre4", "1.19-pre3", "1.19-pre2", "1.19-pre1", "22w19a", "22w18a", "22w17a", "22w16b", "22w16a", "22w15a", "22w14a", "22w13oneblockatatime", "22w13a", "22w12a", "22w11a", "1.18.2", "1.18.2-rc1", "1.18.2-pre3", "1.18.2-pre2", "1.18.2-pre1", "22w07a", "22w06a", "22w05a", "22w03a", "1.18.1", "1.18.1-rc3", "1.18.1-rc2", "1.18.1-rc1", "1.18.1-pre1", "1.18", "1.18-rc4", "1.18-rc3", "1.18-rc2", "1.18-rc1", "1.18-pre8", "1.18-pre7", "1.18-pre6", "1.18-pre5", "1.18-pre4", "1.18-pre3", "1.18-pre2", "1.18-pre1", "21w44a", "21w43a", "21w42a", "21w41a", "21w40a", "21w39a", "21w38a", "21w37a", "1.17.1", "1.17.1-rc2", "1.17.1-rc1", "1.17.1-pre3", "1.17.1-pre2", "1.17.1-pre1", "1.17", "1.17-rc2", "1.17-rc1", "1.17-pre5", "1.17-pre4", "1.17-pre3", "1.17-pre2", "1.17-pre1", "21w20a", "21w19a", "21w18a", "21w17a", "21w16a", "21w15a", "21w14a", "21w13a", "21w11a", "21w10a", "21w08b", "21w08a", "21w07a", "21w06a", "21w05b", "21w05a", "21w03a", "1.16.5", "1.16.5-rc1", "20w51a", "20w49a", "20w48a", "20w46a", "20w45a", "1.16.4", "1.16.4-rc1", "1.16.4-pre2", "1.16.4-pre1", "1.16.3", "1.16.3-rc1", "1.16.2", "1.16.2-rc2", "1.16.2-rc1", "1.16.2-pre3", "1.16.2-pre2", "1.16.2-pre1", "20w30a", "20w29a", "20w28a", "20w27a", "1.16.1", "1.16", "1.16-rc1", "1.16-pre8", "1.16-pre7", "1.16-pre6", "1.16-pre5", "1.16-pre4", "1.16-pre3", "1.16-pre2", "1.16-pre1", "20w22a", "20w21a", "20w20b", "20w20a", "20w19a", "20w18a", "20w17a", "20w16a", "20w15a", "20w14a", "20w14infinite", "20w13b", "20w13a", "20w12a", "20w11a", "20w10a", "20w09a", "20w08a", "20w07a", "20w06a", "1.15.2", "1.15.2-pre2", "1.15.2-pre1", "1.15.1", "1.15.1-pre1", "1.15", "1.15-pre7", "1.15-pre6", "1.15-pre5", "1.15-pre4", "1.15-pre3", "1.15-pre2", "1.15-pre1", "19w46b", "19w46a", "19w45b", "19w45a", "19w44a", "19w42a", "19w41a", "19w40a", "19w39a", "19w38b", "19w38a", "19w37a", "19w36a", "19w35a", "19w34a", "1.14.4", "1.14.4-pre7", "1.14.4-pre6", "1.14.4-pre5", "1.14.4-pre4", "1.14.4-pre3", "1.14.4-pre2", "1.14.4-pre1", "1.14.3", "1.14.3-pre4", "1.14.3-pre3", "1.14.3-pre2", "1.14.3-pre1", "1.14.2", "1.14.2 Pre-Release 4", "1.14.2 Pre-Release 3", "1.14.2 Pre-Release 2", "1.14.2 Pre-Release 1", "1.14.1", "1.14.1 Pre-Release 2", "1.14.1 Pre-Release 1", "1.14", "1.14 Pre-Release 5", "1.14 Pre-Release 4", "1.14 Pre-Release 3", "1.14 Pre-Release 2", "1.14 Pre-Release 1", "19w14b", "19w14a", "3D Shareware v1.34", "19w13b", "19w13a", "19w12b", "19w12a", "19w11b", "19w11a", "19w09a", "19w08b", "19w08a", "19w07a", "19w06a", "19w05a", "19w04b", "19w04a", "19w03c", "19w03b", "19w03a", "19w02a", "18w50a", "18w49a", "18w48b", "18w48a", "18w47b", "18w47a", "18w46a", "18w45a", "18w44a", "18w43c", "18w43b", "18w43a", "1.13.2", "1.13.2-pre2", "1.13.2-pre1", "1.13.1", "1.13.1-pre2", "1.13.1-pre1", "18w33a", "18w32a", "18w31a", "18w30b", "18w30a", "1.13", "1.13-pre10", "1.13-pre9", "1.13-pre8", "1.13-pre7", "1.13-pre6", "1.13-pre5", "1.13-pre4", "1.13-pre3", "1.13-pre2", "1.13-pre1", "18w22c", "18w22b", "18w22a", "18w21b", "18w21a", "18w20c", "18w20b", "18w20a", "18w19b", "18w19a", "18w16a", "18w15a", "18w14b", "18w14a", "18w11a", "18w10d", "18w10c", "18w10b", "18w10a", "18w09a", "18w08b", "18w08a", "18w07c", "18w07b", "18w07a", "18w06a", "18w05a", "18w03b", "18w03a", "18w02a", "18w01a", "17w50a", "17w49b", "17w49a", "17w48a", "17w47b", "17w47a", "17w46a", "17w45b", "17w45a", "17w43b", "17w43a", "1.12.2", "1.12.2-pre2", "1.12.2-pre1", "1.12.1", "1.12.1-pre1", "17w31a", "1.12", "1.12-pre7", "1.12-pre6", "1.12-pre5", "1.12-pre4", "1.12-pre3", "1.12-pre2", "1.12-pre1", "17w18b", "17w18a", "17w17b", "17w17a", "17w16b", "17w16a", "17w15a", "17w14a", "17w13b", "17w13a", "17w06a", "1.11.2", "1.11.1", "16w50a", "1.11", "1.11-pre1", "16w44a", "16w43a", "16w42a", "16w41a", "16w40a", "16w39c", "16w39b", "16w39a", "16w38a", "16w36a", "16w35a", "16w33a", "16w32b", "16w32a", "1.10.2", "1.10.1", "1.10", "1.10-pre2", "1.10-pre1", "16w21b", "16w21a", "16w20a", "1.9.4", "1.9.3", "1.9.3-pre3", "1.9.3-pre2", "1.9.3-pre1", "16w15b", "16w15a", "16w14a", "1.RV-Pre1", "1.9.2", "1.9.1", "1.9.1-pre3", "1.9.1-pre2", "1.9.1-pre1", "1.9", "1.9-pre4", "1.9-pre3", "1.9-pre2", "1.9-pre1", "16w07b", "16w07a", "16w06a", "16w05b", "16w05a", "16w04a", "16w03a", "16w02a", "15w51b", "15w51a", "15w50a", "15w49b", "1.8.9", "15w49a", "15w47c", "15w47b", "15w47a", "15w46a", "15w45a", "15w44b", "15w44a", "15w43c", "15w43b", "15w43a", "15w42a", "15w41b", "15w41a", "15w40b", "15w40a", "15w39c", "15w39b", "15w39a", "15w38b", "15w38a", "15w37a", "15w36d", "15w36c", "15w36b", "15w36a", "15w35e", "15w35d", "15w35c", "15w35b", "15w35a", "15w34d", "15w34c", "15w34b", "15w34a", "15w33c", "15w33b", "15w33a", "15w32c", "15w32b", "15w32a", "15w31c", "15w31b", "15w31a", "1.8.8", "1.8.7", "1.8.6", "1.8.5", "1.8.4", "15w14a", "1.8.3", "1.8.2", "1.8.2-pre7", "1.8.2-pre6", "1.8.2-pre5", "1.8.2-pre4", "1.8.2-pre3", "1.8.2-pre2", "1.8.2-pre1", "1.8.1", "1.8.1-pre5", "1.8.1-pre4", "1.8.1-pre3", "1.8.1-pre2", "1.8.1-pre1", "1.8", "1.8-pre3", "1.8-pre2", "1.8-pre1", "14w34d", "14w34c", "14w34b", "14w34a", "14w33c", "14w33b", "14w33a", "14w32d", "14w32c", "14w32b", "14w32a", "14w31a", "14w30c", "14w30b", "14w30a", "14w29b", "14w29a", "14w28b", "14w28a", "14w27b", "14w27a", "14w26c", "14w26b", "14w26a", "14w25b", "14w25a", "14w21b", "14w21a", "14w20b", "14w20a", "1.7.10", "1.7.10-pre4", "1.7.10-pre3", "1.7.10-pre2", "1.7.10-pre1", "14w19a", "14w18b", "14w18a", "14w17a", "14w11b", "1.7.9", "1.7.8", "1.7.7", "1.7.6", "14w11a", "1.7.6-pre2", "1.7.6-pre1", "14w10c", "14w10b", "14w10a", "14w08a", "1.7.5", "14w07a", "14w06b", "14w06a", "14w05b", "14w05a", "14w04b", "14w04a", "14w03b", "14w03a", "14w02c", "14w02b", "14w02a", "1.7.4", "1.7.3", "13w49a", "13w48b", "13w48a", "13w47e", "13w47d", "13w47c", "13w47b", "13w47a", "1.7.2", "1.7.1", "1.7", "13w43a", "13w42b", "13w42a", "13w41b", "13w41a", "13w39b", "13w39a", "13w38c", "13w38b", "13w38a", "1.6.4", "13w37b", "1.6.3", "13w37a", "13w36b", "13w36a", "1.6.2", "1.6.1", "1.6", "13w26a", "13w25c", "13w25b", "13w25a", "13w24b", "13w24a", "13w23b", "13w23a", "13w22a", "13w21b", "13w21a", "13w19a", "13w18c", "13w18b", "13w18a", "13w17a", "1.5.2", "13w16b", "13w16a", "1.5.1", "1.5", "1.4.7", "1.4.5", "1.4.6", "1.4.4", "1.4.3", "1.4.2", "1.4.1", "1.4", "1.3.2", "1.3.1", "1.3", "1.2.5", "1.2.4", "1.2.3", "1.2.2", "1.2.1", "1.1", "1.0", "b1.8.1", "b1.8", "b1.7.3", "b1.7.2", "b1.7", "b1.6.6", "b1.6.5", "b1.6.4", "b1.6.3", "b1.6.2", "b1.6.1", "b1.6", "b1.5_01", "b1.5", "b1.4_01", "b1.4", "b1.3_01", "b1.3b", "b1.2_02", "b1.2_01", "b1.2", "b1.1_02", "b1.1_01", "b1.0.2", "b1.0_01", "b1.0", "a1.2.6", "a1.2.5", "a1.2.4_01", "a1.2.3_04", "a1.2.3_02", "a1.2.3_01", "a1.2.3", "a1.2.2b", "a1.2.2a", "a1.2.1_01", "a1.2.1", "a1.2.0_02", "a1.2.0_01", "a1.2.0", "a1.1.2_01", "a1.1.2", "a1.1.0", "a1.0.17_04", "a1.0.17_02", "a1.0.16", "a1.0.15", "a1.0.14", "a1.0.11", "a1.0.5_01", "a1.0.4", "inf-20100618", "c0.30_01c", "c0.0.13a", "c0.0.13a_03", "c0.0.11a", "rd-161348", "rd-160052", "rd-20090515", "rd-132328", "rd-132211"); + public static final List VERSIONS = List.of("1.21.4", "1.21.4-rc3", "1.21.4-rc2", "1.21.4-rc1", "1.21.4-pre3", "1.21.4-pre2", "1.21.4-pre1", "24w46a", "24w45a", "24w44a", "1.21.3", "1.21.2", "1.21.2-rc2", "1.21.2-rc1", "1.21.2-pre5", "1.21.2-pre4", "1.21.2-pre3", "1.21.2-pre2", "1.21.2-pre1", "24w40a", "24w39a", "24w38a", "24w37a", "24w36a", "24w35a", "24w34a", "24w33a", "1.21.1", "1.21.1-rc1", "1.21", "1.21-rc1", "1.21-pre4", "1.21-pre3", "1.21-pre2", "1.21-pre1", "24w21b", "24w21a", "24w20a", "24w19b", "24w19a", "24w18a", "1.20.6", "1.20.6-rc1", "1.20.5", "1.20.5-rc3", "1.20.5-rc2", "1.20.5-rc1", "1.20.5-pre4", "1.20.5-pre3", "1.20.5-pre2", "1.20.5-pre1", "24w14a", "24w14potato", "24w13a", "24w12a", "24w11a", "24w10a", "24w09a", "24w07a", "24w06a", "24w05b", "24w05a", "24w04a", "24w03b", "24w03a", "23w51b", "23w51a", "1.20.4", "1.20.4-rc1", "1.20.3", "1.20.3-rc1", "1.20.3-pre4", "1.20.3-pre3", "1.20.3-pre2", "1.20.3-pre1", "23w46a", "23w45a", "23w44a", "23w43b", "23w43a", + "23w42a", "23w41a", "23w40a", "1.20.2", "1.20.2-rc2", "1.20.2-rc1", "1.20.2-pre4", "1.20.2-pre3", "1.20.2-pre2", "1.20.2-pre1", "23w35a", "23w33a", "23w32a", "23w31a", "1.20.1", "1.20.1-rc1", "1.20", "1.20-rc1", "1.20-pre7", "1.20-pre6", "1.20-pre5", "1.20-pre4", "1.20-pre3", "1.20-pre2", "1.20-pre1", "23w18a", "23w17a", "23w16a", "23w14a", "23w13a_or_b", "23w13a", "23w12a", "1.19.4", "1.19.4-rc3", "1.19.4-rc2", "1.19.4-rc1", "1.19.4-pre4", "1.19.4-pre3", "1.19.4-pre2", "1.19.4-pre1", "23w07a", "23w06a", "23w05a", "23w04a", "23w03a", "1.19.3", "1.19.3-rc3", "1.19.3-rc2", "1.19.3-rc1", "1.19.3-pre3", "1.19.3-pre2", "1.19.3-pre1", "22w46a", "22w45a", "22w44a", "22w43a", "22w42a", "1.19.2", "1.19.2-rc2", "1.19.2-rc1", "1.19.1", "1.19.1-rc3", "1.19.1-rc2", "1.19.1-pre6", "1.19.1-pre5", "1.19.1-pre4", "1.19.1-pre3", "1.19.1-pre2", "1.19.1-rc1", "1.19.1-pre1", "22w24a", "1.19", "1.19-rc2", "1.19-rc1", "1.19-pre5", "1.19-pre4", "1.19-pre3", "1.19-pre2", "1.19-pre1", "22w19a", + "22w18a", "22w17a", "22w16b", "22w16a", "22w15a", "22w14a", "22w13oneblockatatime", "22w13a", "22w12a", "22w11a", "1.18.2", "1.18.2-rc1", "1.18.2-pre3", "1.18.2-pre2", "1.18.2-pre1", "22w07a", "22w06a", "22w05a", "22w03a", "1.18.1", "1.18.1-rc3", "1.18.1-rc2", "1.18.1-rc1", "1.18.1-pre1", "1.18", "1.18-rc4", "1.18-rc3", "1.18-rc2", "1.18-rc1", "1.18-pre8", "1.18-pre7", "1.18-pre6", "1.18-pre5", "1.18-pre4", "1.18-pre3", "1.18-pre2", "1.18-pre1", "21w44a", "21w43a", "21w42a", "21w41a", "21w40a", "21w39a", "21w38a", "21w37a", "1.17.1", "1.17.1-rc2", "1.17.1-rc1", "1.17.1-pre3", "1.17.1-pre2", "1.17.1-pre1", "1.17", "1.17-rc2", "1.17-rc1", "1.17-pre5", "1.17-pre4", "1.17-pre3", "1.17-pre2", "1.17-pre1", "21w20a", "21w19a", "21w18a", "21w17a", "21w16a", "21w15a", "21w14a", "21w13a", "21w11a", "21w10a", "21w08b", "21w08a", "21w07a", "21w06a", "21w05b", "21w05a", "21w03a", "1.16.5", "1.16.5-rc1", "20w51a", "20w49a", "20w48a", "20w46a", "20w45a", "1.16.4", "1.16.4-rc1", + "1.16.4-pre2", "1.16.4-pre1", "1.16.3", "1.16.3-rc1", "1.16.2", "1.16.2-rc2", "1.16.2-rc1", "1.16.2-pre3", "1.16.2-pre2", "1.16.2-pre1", "20w30a", "20w29a", "20w28a", "20w27a", "1.16.1", "1.16", "1.16-rc1", "1.16-pre8", "1.16-pre7", "1.16-pre6", "1.16-pre5", "1.16-pre4", "1.16-pre3", "1.16-pre2", "1.16-pre1", "20w22a", "20w21a", "20w20b", "20w20a", "20w19a", "20w18a", "20w17a", "20w16a", "20w15a", "20w14a", "20w14infinite", "20w13b", "20w13a", "20w12a", "20w11a", "20w10a", "20w09a", "20w08a", "20w07a", "20w06a", "1.15.2", "1.15.2-pre2", "1.15.2-pre1", "1.15.1", "1.15.1-pre1", "1.15", "1.15-pre7", "1.15-pre6", "1.15-pre5", "1.15-pre4", "1.15-pre3", "1.15-pre2", "1.15-pre1", "19w46b", "19w46a", "19w45b", "19w45a", "19w44a", "19w42a", "19w41a", "19w40a", "19w39a", "19w38b", "19w38a", "19w37a", "19w36a", "19w35a", "19w34a", "1.14.4", "1.14.4-pre7", "1.14.4-pre6", "1.14.4-pre5", "1.14.4-pre4", "1.14.4-pre3", "1.14.4-pre2", "1.14.4-pre1", "1.14.3", "1.14.3-pre4", "1.14.3-pre3", + "1.14.3-pre2", "1.14.3-pre1", "1.14.2", "1.14.2 Pre-Release 4", "1.14.2 Pre-Release 3", "1.14.2 Pre-Release 2", "1.14.2 Pre-Release 1", "1.14.1", "1.14.1 Pre-Release 2", "1.14.1 Pre-Release 1", "1.14", "1.14 Pre-Release 5", "1.14 Pre-Release 4", "1.14 Pre-Release 3", "1.14 Pre-Release 2", "1.14 Pre-Release 1", "19w14b", "19w14a", "3D Shareware v1.34", "19w13b", "19w13a", "19w12b", "19w12a", "19w11b", "19w11a", "19w09a", "19w08b", "19w08a", "19w07a", "19w06a", "19w05a", "19w04b", "19w04a", "19w03c", "19w03b", "19w03a", "19w02a", "18w50a", "18w49a", "18w48b", "18w48a", "18w47b", "18w47a", "18w46a", "18w45a", "18w44a", "18w43c", "18w43b", "18w43a", "1.13.2", "1.13.2-pre2", "1.13.2-pre1", "1.13.1", "1.13.1-pre2", "1.13.1-pre1", "18w33a", "18w32a", "18w31a", "18w30b", "18w30a", "1.13", "1.13-pre10", "1.13-pre9", "1.13-pre8", "1.13-pre7", "1.13-pre6", "1.13-pre5", "1.13-pre4", "1.13-pre3", "1.13-pre2", "1.13-pre1", "18w22c", "18w22b", "18w22a", "18w21b", "18w21a", "18w20c", + "18w20b", "18w20a", "18w19b", "18w19a", "18w16a", "18w15a", "18w14b", "18w14a", "18w11a", "18w10d", "18w10c", "18w10b", "18w10a", "18w09a", "18w08b", "18w08a", "18w07c", "18w07b", "18w07a", "18w06a", "18w05a", "18w03b", "18w03a", "18w02a", "18w01a", "17w50a", "17w49b", "17w49a", "17w48a", "17w47b", "17w47a", "17w46a", "17w45b", "17w45a", "17w43b", "17w43a", "1.12.2", "1.12.2-pre2", "1.12.2-pre1", "1.12.1", "1.12.1-pre1", "17w31a", "1.12", "1.12-pre7", "1.12-pre6", "1.12-pre5", "1.12-pre4", "1.12-pre3", "1.12-pre2", "1.12-pre1", "17w18b", "17w18a", "17w17b", "17w17a", "17w16b", "17w16a", "17w15a", "17w14a", "17w13b", "17w13a", "17w06a", "1.11.2", "1.11.1", "16w50a", "1.11", "1.11-pre1", "16w44a", "16w43a", "16w42a", "16w41a", "16w40a", "16w39c", "16w39b", "16w39a", "16w38a", "16w36a", "16w35a", "16w33a", "16w32b", "16w32a", "1.10.2", "1.10.1", "1.10", "1.10-pre2", "1.10-pre1", "16w21b", "16w21a", "16w20a", "1.9.4", "1.9.3", "1.9.3-pre3", "1.9.3-pre2", "1.9.3-pre1", "16w15b", + "16w15a", "16w14a", "1.RV-Pre1", "1.9.2", "1.9.1", "1.9.1-pre3", "1.9.1-pre2", "1.9.1-pre1", "1.9", "1.9-pre4", "1.9-pre3", "1.9-pre2", "1.9-pre1", "16w07b", "16w07a", "16w06a", "16w05b", "16w05a", "16w04a", "16w03a", "16w02a", "15w51b", "15w51a", "15w50a", "15w49b", "1.8.9", "15w49a", "15w47c", "15w47b", "15w47a", "15w46a", "15w45a", "15w44b", "15w44a", "15w43c", "15w43b", "15w43a", "15w42a", "15w41b", "15w41a", "15w40b", "15w40a", "15w39c", "15w39b", "15w39a", "15w38b", "15w38a", "15w37a", "15w36d", "15w36c", "15w36b", "15w36a", "15w35e", "15w35d", "15w35c", "15w35b", "15w35a", "15w34d", "15w34c", "15w34b", "15w34a", "15w33c", "15w33b", "15w33a", "15w32c", "15w32b", "15w32a", "15w31c", "15w31b", "15w31a", "1.8.8", "1.8.7", "1.8.6", "1.8.5", "1.8.4", "15w14a", "1.8.3", "1.8.2", "1.8.2-pre7", "1.8.2-pre6", "1.8.2-pre5", "1.8.2-pre4", "1.8.2-pre3", "1.8.2-pre2", "1.8.2-pre1", "1.8.1", "1.8.1-pre5", "1.8.1-pre4", "1.8.1-pre3", "1.8.1-pre2", "1.8.1-pre1", "1.8", "1.8-pre3", + "1.8-pre2", "1.8-pre1", "14w34d", "14w34c", "14w34b", "14w34a", "14w33c", "14w33b", "14w33a", "14w32d", "14w32c", "14w32b", "14w32a", "14w31a", "14w30c", "14w30b", "14w30a", "14w29b", "14w29a", "14w28b", "14w28a", "14w27b", "14w27a", "14w26c", "14w26b", "14w26a", "14w25b", "14w25a", "14w21b", "14w21a", "14w20b", "14w20a", "1.7.10", "1.7.10-pre4", "1.7.10-pre3", "1.7.10-pre2", "1.7.10-pre1", "14w19a", "14w18b", "14w18a", "14w17a", "14w11b", "1.7.9", "1.7.8", "1.7.7", "1.7.6", "14w11a", "1.7.6-pre2", "1.7.6-pre1", "14w10c", "14w10b", "14w10a", "14w08a", "1.7.5", "14w07a", "14w06b", "14w06a", "14w05b", "14w05a", "14w04b", "14w04a", "14w03b", "14w03a", "14w02c", "14w02b", "14w02a", "1.7.4", "1.7.3", "13w49a", "13w48b", "13w48a", "13w47e", "13w47d", "13w47c", "13w47b", "13w47a", "1.7.2", "1.7.1", "1.7", "13w43a", "13w42b", "13w42a", "13w41b", "13w41a", "13w39b", "13w39a", "13w38c", "13w38b", "13w38a", "1.6.4", "13w37b", "1.6.3", "13w37a", "13w36b", "13w36a", "1.6.2", "1.6.1", + "1.6", "13w26a", "13w25c", "13w25b", "13w25a", "13w24b", "13w24a", "13w23b", "13w23a", "13w22a", "13w21b", "13w21a", "13w19a", "13w18c", "13w18b", "13w18a", "13w17a", "1.5.2", "13w16b", "13w16a", "1.5.1", "1.5", "1.4.7", "1.4.5", "1.4.6", "1.4.4", "1.4.3", "1.4.2", "1.4.1", "1.4", "1.3.2", "1.3.1", "1.3", "1.2.5", "1.2.4", "1.2.3", "1.2.2", "1.2.1", "1.1", "1.0", "b1.8.1", "b1.8", "b1.7.3", "b1.7.2", "b1.7", "b1.6.6", "b1.6.5", "b1.6.4", "b1.6.3", "b1.6.2", "b1.6.1", "b1.6", "b1.5_01", "b1.5", "b1.4_01", "b1.4", "b1.3_01", "b1.3b", "b1.2_02", "b1.2_01", "b1.2", "b1.1_02", "b1.1_01", "b1.0.2", "b1.0_01", "b1.0", "a1.2.6", "a1.2.5", "a1.2.4_01", "a1.2.3_04", "a1.2.3_02", "a1.2.3_01", "a1.2.3", "a1.2.2b", "a1.2.2a", "a1.2.1_01", "a1.2.1", "a1.2.0_02", "a1.2.0_01", "a1.2.0", "a1.1.2_01", "a1.1.2", "a1.1.0", "a1.0.17_04", "a1.0.17_02", "a1.0.16", "a1.0.15", "a1.0.14", "a1.0.11", "a1.0.5_01", "a1.0.4", "inf-20100618", "c0.30_01c", "c0.0.13a", "c0.0.13a_03", "c0.0.11a", + "rd-161348", "rd-160052", "rd-20090515", "rd-132328", "rd-132211"); // Indices into VERSIONS sorted by descending length of the version id - private static final int[] BY_LENGTH = {166, 332, 333, 334, 335, 337, 338, 340, 341, 342, 343, 344, 347, 280, 781, 4, 5, 6, 14, 15, 16, 17, 18, 47, 48, 49, 50, 52, 71, 72, 73, 74, 86, 87, 88, 89, 109, 116, 117, 118, 119, 129, 130, 131, 143, 144, 145, 146, 147, 149, 172, 173, 174, 183, 208, 209, 210, 245, 246, 252, 253, 254, 291, 292, 294, 319, 320, 321, 322, 323, 324, 325, 327, 328, 329, 330, 379, 380, 382, 383, 443, 444, 446, 626, 627, 628, 629, 784, 788, 1, 2, 3, 12, 13, 28, 42, 44, 45, 46, 68, 70, 84, 85, 95, 113, 114, 115, 126, 127, 128, 138, 139, 141, 142, 148, 171, 180, 181, 182, 206, 207, 237, 244, 248, 250, 251, 390, 496, 497, 498, 505, 506, 507, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 640, 641, 773, 774, 31, 32, 33, 34, 98, 99, 100, 101, 102, 103, 104, 154, 155, 156, 157, 158, 189, 190, 191, 192, 193, 194, 195, 196, 214, 215, 216, 217, 218, 262, 263, 264, 265, 266, 267, 268, 269, 296, 297, 298, 299, 300, 301, 302, 391, 392, 393, 394, 395, 396, 397, 398, 399, 449, 450, 451, 452, 453, 454, 455, 471, 489, 490, 502, 758, 759, 760, 761, 765, 767, 768, 770, 779, 782, 786, 787, 789, 790, 30, 97, 152, 153, 185, 186, 187, 188, 212, 213, 261, 509, 510, 511, 512, 592, 593, 594, 783, 785, 742, 744, 746, 748, 749, 751, 752, 754, 763, 764, 775, 776, 777, 778, 0, 7, 8, 9, 10, 11, 19, 20, 21, 22, 23, 24, 25, 26, 27, 35, 36, 37, 38, 39, 40, 41, 43, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 75, 76, 77, 78, 79, 80, 81, 82, 83, 90, 91, 92, 93, 94, 105, 106, 107, 108, 110, 111, 112, 120, 121, 122, 123, 124, 125, 132, 133, 134, 135, 136, 137, 140, 150, 159, 160, 161, 162, 163, 164, 165, 167, 168, 169, 170, 175, 176, 177, 178, 179, 197, 198, 199, 200, 201, 202, 203, 204, 205, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 238, 239, 240, 241, 242, 243, 247, 249, 255, 256, 257, 258, 259, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 293, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 326, 331, 336, 345, 346, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 381, 384, 385, 386, 387, 388, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 445, 447, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 491, 492, 493, 499, 500, 501, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 575, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 630, 631, 632, 633, 634, 639, 642, 643, 644, 645, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 661, 662, 663, 664, 665, 666, 667, 668, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 683, 685, 686, 687, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 709, 730, 732, 733, 735, 736, 737, 738, 739, 740, 753, 756, 757, 762, 766, 769, 771, 772, 780, 494, 495, 503, 504, 525, 570, 571, 572, 573, 574, 576, 577, 585, 635, 636, 637, 638, 646, 659, 660, 669, 670, 682, 684, 688, 689, 707, 710, 712, 713, 714, 715, 716, 717, 718, 720, 721, 723, 724, 725, 726, 727, 747, 29, 96, 151, 184, 211, 260, 295, 339, 389, 448, 470, 488, 731, 734, 741, 743, 745, 750, 755, 508, 591, 671, 690, 711, 719, 722, 728, 729}; + private static final int[] BY_LENGTH = { 166, 332, 333, 334, 335, 337, 338, 340, 341, 342, 343, 344, 347, 280, 781, 4, 5, 6, 14, 15, 16, 17, 18, 47, 48, 49, 50, 52, 71, 72, 73, 74, 86, 87, 88, 89, 109, 116, 117, 118, 119, 129, 130, 131, 143, 144, 145, 146, 147, 149, 172, 173, 174, 183, 208, 209, 210, 245, 246, 252, 253, 254, 291, 292, 294, 319, 320, 321, 322, 323, 324, 325, 327, 328, 329, 330, 379, 380, 382, 383, 443, 444, 446, 626, 627, 628, 629, 784, 788, 1, 2, 3, 12, 13, 28, 42, 44, 45, 46, 68, 70, 84, 85, 95, 113, 114, 115, 126, 127, 128, 138, 139, 141, 142, 148, 171, 180, 181, 182, 206, 207, 237, 244, 248, 250, 251, 390, 496, 497, 498, 505, 506, 507, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 640, 641, 773, 774, 31, 32, 33, 34, 98, 99, 100, 101, 102, 103, 104, 154, 155, 156, 157, 158, 189, 190, 191, 192, 193, 194, 195, 196, 214, 215, 216, 217, 218, 262, 263, 264, 265, 266, 267, 268, 269, 296, 297, 298, 299, 300, 301, 302, 391, 392, 393, 394, 395, 396, 397, + 398, 399, 449, 450, 451, 452, 453, 454, 455, 471, 489, 490, 502, 758, 759, 760, 761, 765, 767, 768, 770, 779, 782, 786, 787, 789, 790, 30, 97, 152, 153, 185, 186, 187, 188, 212, 213, 261, 509, 510, 511, 512, 592, 593, 594, 783, 785, 742, 744, 746, 748, 749, 751, 752, 754, 763, 764, 775, 776, 777, 778, 0, 7, 8, 9, 10, 11, 19, 20, 21, 22, 23, 24, 25, 26, 27, 35, 36, 37, 38, 39, 40, 41, 43, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 75, 76, 77, 78, 79, 80, 81, 82, 83, 90, 91, 92, 93, 94, 105, 106, 107, 108, 110, 111, 112, 120, 121, 122, 123, 124, 125, 132, 133, 134, 135, 136, 137, 140, 150, 159, 160, 161, 162, 163, 164, 165, 167, 168, 169, 170, 175, 176, 177, 178, 179, 197, 198, 199, 200, 201, 202, 203, 204, 205, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 238, 239, 240, 241, 242, 243, 247, 249, 255, 256, 257, 258, 259, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 281, 282, 283, 284, 285, 286, 287, + 288, 289, 290, 293, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 326, 331, 336, 345, 346, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 381, 384, 385, 386, 387, 388, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 445, 447, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 491, 492, 493, 499, 500, 501, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, + 568, 569, 575, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 630, 631, 632, 633, 634, 639, 642, 643, 644, 645, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 661, 662, 663, 664, 665, 666, 667, 668, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 683, 685, 686, 687, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 709, 730, 732, 733, 735, 736, 737, 738, 739, 740, 753, 756, 757, 762, 766, 769, 771, 772, 780, 494, 495, 503, 504, 525, 570, 571, 572, 573, 574, 576, 577, 585, 635, 636, 637, 638, 646, 659, 660, 669, 670, 682, 684, 688, 689, 707, 710, 712, 713, 714, 715, 716, 717, 718, 720, 721, 723, 724, 725, 726, 727, 747, 29, 96, 151, 184, 211, 260, 295, 339, 389, 448, 470, 488, 731, 734, 741, 743, 745, 750, 755, 508, 591, 671, 690, 711, 719, 722, 728, 729 }; /** * Finds the index of the longest matching prefix or -1 if none match. - * Prefix matches must terminate with one of the given separator characters to be found valid. + * Prefix matches must terminate with one of the given separator characters to be found valid. */ public static int indexOfByPrefix(String version, String separators) { - for (var versionIdx : BY_LENGTH) { - var versionText = VERSIONS.get(versionIdx); - if (version.startsWith(versionText) && (versionText.length() == version.length() || separators.indexOf(version.charAt(versionText.length())) != -1)) { - return versionIdx; + for (var versionIdx : BY_LENGTH) { + var versionText = VERSIONS.get(versionIdx); + if (version.startsWith(versionText) && (versionText.length() == version.length() || separators.indexOf(version.charAt(versionText.length())) != -1)) { + return versionIdx; + } } - } - return -1; + return -1; } } diff --git a/src/java8/java/net/neoforged/moddevgradle/boot/TrampolinePlugin.java b/src/java8/java/net/neoforged/moddevgradle/boot/TrampolinePlugin.java index 067628d9..822134fe 100644 --- a/src/java8/java/net/neoforged/moddevgradle/boot/TrampolinePlugin.java +++ b/src/java8/java/net/neoforged/moddevgradle/boot/TrampolinePlugin.java @@ -1,13 +1,12 @@ package net.neoforged.moddevgradle.boot; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.gradle.api.GradleException; import org.gradle.api.Plugin; import org.gradle.api.plugins.PluginAware; import org.gradle.util.GradleVersion; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * This is just a trampoline to perform the Java and Gradle version check, and is compiled for Java 8 in the real Jar. */ @@ -32,7 +31,7 @@ public final void apply(T target) { if (GradleVersion.current().compareTo(MIN_GRADLE_VERSION) < 0) { throw new GradleException("To use the NeoForge plugin, please use at least " + MIN_GRADLE_VERSION - + ". You are currently using " + GradleVersion.current() + "."); + + ". You are currently using " + GradleVersion.current() + "."); } try { diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeExtension.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeExtension.java index aa0d0140..07ba6032 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeExtension.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeExtension.java @@ -1,13 +1,12 @@ package net.neoforged.moddevgradle.legacyforge.dsl; +import javax.inject.Inject; import net.neoforged.moddevgradle.dsl.DataFileCollection; import net.neoforged.moddevgradle.dsl.ModDevExtension; import net.neoforged.moddevgradle.legacyforge.internal.LegacyForgeModDevPlugin; import org.gradle.api.Action; import org.gradle.api.Project; -import javax.inject.Inject; - /** * This is the top-level {@code legacyForge} extension, used to configure the moddev plugin. */ @@ -16,8 +15,8 @@ public abstract class LegacyForgeExtension extends ModDevExtension { @Inject public LegacyForgeExtension(Project project, - DataFileCollection accessTransformers, - DataFileCollection interfaceInjectionData) { + DataFileCollection accessTransformers, + DataFileCollection interfaceInjectionData) { super(project, accessTransformers, interfaceInjectionData); this.project = project; } diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeModdingSettings.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeModdingSettings.java index a004c936..1e082ee0 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeModdingSettings.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeModdingSettings.java @@ -1,14 +1,13 @@ package net.neoforged.moddevgradle.legacyforge.dsl; +import java.util.HashSet; +import java.util.Set; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import org.gradle.api.Project; import org.gradle.api.tasks.SourceSet; import org.jetbrains.annotations.Nullable; -import javax.inject.Inject; -import java.util.HashSet; -import java.util.Set; - public abstract class LegacyForgeModdingSettings { @Nullable private String neoForgeVersion; diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinCompilerArgs.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinCompilerArgs.java index 451dcc2d..c552b1ab 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinCompilerArgs.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinCompilerArgs.java @@ -1,5 +1,7 @@ package net.neoforged.moddevgradle.legacyforge.dsl; +import java.util.List; +import javax.inject.Inject; import org.gradle.api.file.RegularFileProperty; import org.gradle.api.tasks.InputFile; import org.gradle.api.tasks.OutputFile; @@ -7,13 +9,9 @@ import org.gradle.api.tasks.PathSensitivity; import org.gradle.process.CommandLineArgumentProvider; -import javax.inject.Inject; -import java.util.List; - abstract class MixinCompilerArgs implements CommandLineArgumentProvider { @Inject - public MixinCompilerArgs() { - } + public MixinCompilerArgs() {} @OutputFile protected abstract RegularFileProperty getOutMappings(); @@ -36,7 +34,6 @@ public Iterable asArguments() { "-AoutRefMapFile=" + getRefmap().get().getAsFile().getAbsolutePath(), "-AmappingTypes=tsrg", "-ApluginVersion=0.7", // Not sure what this is used for, but MixinGradle gives it to the AP. Latest as of time of writing - "-AdefaultObfuscationEnv=searge" - ); + "-AdefaultObfuscationEnv=searge"); } } diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinExtension.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinExtension.java index cf703f02..45dbc62f 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinExtension.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinExtension.java @@ -1,5 +1,6 @@ package net.neoforged.moddevgradle.legacyforge.dsl; +import javax.inject.Inject; import org.gradle.api.Project; import org.gradle.api.file.ConfigurableFileCollection; import org.gradle.api.file.RegularFile; @@ -9,8 +10,6 @@ import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.jvm.tasks.Jar; -import javax.inject.Inject; - public abstract class MixinExtension { private final Project project; private final Provider officialToSrg; @@ -18,8 +17,8 @@ public abstract class MixinExtension { @Inject public MixinExtension(Project project, - Provider officialToSrg, - ConfigurableFileCollection extraMappingFiles) { + Provider officialToSrg, + ConfigurableFileCollection extraMappingFiles) { this.project = project; this.officialToSrg = officialToSrg; this.extraMappingFiles = extraMappingFiles; @@ -54,4 +53,3 @@ public Provider add(SourceSet sourceSet, String refmap) { return refMapFile; } } - diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/ObfuscationExtension.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/ObfuscationExtension.java index 628024b3..59f86310 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/ObfuscationExtension.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/ObfuscationExtension.java @@ -1,5 +1,8 @@ package net.neoforged.moddevgradle.legacyforge.dsl; +import java.util.List; +import java.util.Objects; +import javax.inject.Inject; import net.neoforged.moddevgradle.legacyforge.internal.MinecraftMappings; import net.neoforged.moddevgradle.legacyforge.tasks.RemapJar; import net.neoforged.moddevgradle.legacyforge.tasks.RemapOperation; @@ -23,10 +26,6 @@ import org.gradle.api.tasks.bundling.AbstractArchiveTask; import org.jetbrains.annotations.ApiStatus; -import javax.inject.Inject; -import java.util.List; -import java.util.Objects; - public abstract class ObfuscationExtension { private final Project project; private final Configuration autoRenamingToolRuntime; @@ -35,9 +34,9 @@ public abstract class ObfuscationExtension { @Inject public ObfuscationExtension(Project project, - Configuration autoRenamingToolRuntime, - Configuration installerToolsRuntime, - FileCollection extraMixinMappings) { + Configuration autoRenamingToolRuntime, + Configuration installerToolsRuntime, + FileCollection extraMixinMappings) { this.project = project; this.autoRenamingToolRuntime = autoRenamingToolRuntime; this.installerToolsRuntime = installerToolsRuntime; @@ -79,13 +78,12 @@ public void configureSrgToNamedOperation(RemapOperation operation) { /** * Create a reobfuscation task. * - * @param jar the jar task to reobfuscate - * @param sourceSet the source set whose classpath to use when remapping inherited methods + * @param jar the jar task to reobfuscate + * @param sourceSet the source set whose classpath to use when remapping inherited methods * @return a provider of the created task */ public TaskProvider reobfuscate(TaskProvider jar, SourceSet sourceSet) { - return reobfuscate(jar, sourceSet, ignored -> { - }); + return reobfuscate(jar, sourceSet, ignored -> {}); } /** @@ -97,8 +95,8 @@ public TaskProvider reobfuscate(TaskProvider reobfuscate(TaskProvider jar, - SourceSet sourceSet, - Action configureTask) { + SourceSet sourceSet, + Action configureTask) { var reobf = project.getTasks().register("reobf" + StringUtils.capitalize(jar.getName()), RemapJar.class, task -> { task.getInput().set(jar.flatMap(AbstractArchiveTask::getArchiveFile)); task.getDestinationDirectory().convention(task.getProject().getLayout().getBuildDirectory().dir("libs")); @@ -139,8 +137,7 @@ public TaskProvider reobfuscate(TaskProvider { - }); + java.addVariantsFromConfiguration(reobfConfig, spec -> {}); } return reobf; diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeMetadataTransform.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeMetadataTransform.java index f7213ffd..45eabd84 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeMetadataTransform.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeMetadataTransform.java @@ -2,6 +2,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import java.util.List; +import javax.inject.Inject; import org.gradle.api.Action; import org.gradle.api.artifacts.CacheableRule; import org.gradle.api.artifacts.ComponentMetadataContext; @@ -14,9 +16,6 @@ import org.gradle.api.attributes.Usage; import org.gradle.api.model.ObjectFactory; -import javax.inject.Inject; -import java.util.List; - @CacheableRule class LegacyForgeMetadataTransform extends LegacyMetadataTransform { @Inject diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java index ceb73bce..9b519dc7 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java @@ -1,14 +1,16 @@ package net.neoforged.moddevgradle.legacyforge.internal; +import java.net.URI; +import java.util.stream.Stream; import net.neoforged.minecraftdependencies.MinecraftDependenciesPlugin; import net.neoforged.moddevgradle.internal.ArtifactNamingStrategy; import net.neoforged.moddevgradle.internal.Branding; import net.neoforged.moddevgradle.internal.DataFileCollections; -import net.neoforged.moddevgradle.internal.ModdingDependencies; -import net.neoforged.moddevgradle.internal.jarjar.JarJarPlugin; import net.neoforged.moddevgradle.internal.ModDevArtifactsWorkflow; import net.neoforged.moddevgradle.internal.ModDevRunWorkflow; +import net.neoforged.moddevgradle.internal.ModdingDependencies; import net.neoforged.moddevgradle.internal.RepositoriesPlugin; +import net.neoforged.moddevgradle.internal.jarjar.JarJarPlugin; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import net.neoforged.moddevgradle.internal.utils.VersionCapabilitiesInternal; import net.neoforged.moddevgradle.legacyforge.dsl.LegacyForgeExtension; @@ -30,9 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.URI; -import java.util.stream.Stream; - @ApiStatus.Internal public class LegacyForgeModDevPlugin implements Plugin { private static final Logger LOG = LoggerFactory.getLogger(LegacyForgeModDevPlugin.class); @@ -102,8 +101,7 @@ public void apply(Project project) { LegacyForgeExtension.class, project, dataFileCollections.accessTransformers().extension(), - dataFileCollections.interfaceInjectionData().extension() - ); + dataFileCollections.interfaceInjectionData().extension()); } public void enable(Project project, LegacyForgeModdingSettings settings, LegacyForgeExtension extension) { @@ -151,15 +149,13 @@ public void enable(Project project, LegacyForgeModdingSettings settings, LegacyF artifactNamingStrategy, configurations.getByName(DataFileCollections.CONFIGURATION_ACCESS_TRANSFORMERS), configurations.getByName(DataFileCollections.CONFIGURATION_INTERFACE_INJECTION_DATA), - versionCapabilities - ); + versionCapabilities); var runs = ModDevRunWorkflow.create( project, Branding.MDG, artifacts, - extension.getRuns() - ); + extension.getRuns()); // Configure the mixin and obfuscation extensions var mixin = ExtensionUtils.getExtension(project, MIXIN_EXTENSION, MixinExtension.class); @@ -185,8 +181,7 @@ public void enable(Project project, LegacyForgeModdingSettings settings, LegacyF var reobfJar = obf.reobfuscate( project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class), - project.getExtensions().getByType(SourceSetContainer.class).getByName(SourceSet.MAIN_SOURCE_SET_NAME) - ); + project.getExtensions().getByType(SourceSetContainer.class).getByName(SourceSet.MAIN_SOURCE_SET_NAME)); project.getTasks().named("assemble", assemble -> assemble.dependsOn(reobfJar)); diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyMetadataTransform.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyMetadataTransform.java index cef027e7..a4bf8819 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyMetadataTransform.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyMetadataTransform.java @@ -2,17 +2,16 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.jar.JarInputStream; import org.gradle.api.GradleException; import org.gradle.api.artifacts.ComponentMetadataContext; import org.gradle.api.artifacts.ComponentMetadataRule; import org.gradle.api.artifacts.repositories.RepositoryResourceAccessor; import org.gradle.api.model.ObjectFactory; -import java.io.BufferedInputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.jar.JarInputStream; - abstract class LegacyMetadataTransform implements ComponentMetadataRule { protected final ObjectFactory objects; private final RepositoryResourceAccessor repositoryResourceAccessor; diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/McpMetadataTransform.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/McpMetadataTransform.java index b7e314f7..fdfbc183 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/McpMetadataTransform.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/McpMetadataTransform.java @@ -2,6 +2,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import javax.inject.Inject; import org.gradle.api.Action; import org.gradle.api.artifacts.CacheableRule; import org.gradle.api.artifacts.ComponentMetadataContext; @@ -11,8 +12,6 @@ import org.gradle.api.attributes.java.TargetJvmVersion; import org.gradle.api.model.ObjectFactory; -import javax.inject.Inject; - /** * Given an implicit Metadata object by Gradle (which results from reading in a pom.xml from Maven for MCP data, * which is basically empty), we build metadata that is equivalent to NeoForms Gradle module metadata. @@ -64,8 +63,7 @@ protected void adaptWithConfig(ComponentMetadataContext context, JsonObject conf }); }); - dependencies(context, "mcpRuntimeElements", javaTarget, Usage.JAVA_RUNTIME, deps -> { - }); + dependencies(context, "mcpRuntimeElements", javaTarget, Usage.JAVA_RUNTIME, deps -> {}); dependencies(context, "mcpApiElements", javaTarget, Usage.JAVA_API, dependencies -> { var libraries = config.getAsJsonObject("libraries").getAsJsonArray("joined"); diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/MinecraftMappings.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/MinecraftMappings.java index e427d52d..68a019b3 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/MinecraftMappings.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/MinecraftMappings.java @@ -1,11 +1,10 @@ package net.neoforged.moddevgradle.legacyforge.internal; +import java.util.Locale; import org.gradle.api.Named; import org.gradle.api.attributes.Attribute; import org.jetbrains.annotations.ApiStatus; -import java.util.Locale; - @ApiStatus.Internal public enum MinecraftMappings implements Named { NAMED, diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/RemappingTransform.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/RemappingTransform.java index 114b7134..508821b6 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/RemappingTransform.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/RemappingTransform.java @@ -1,5 +1,7 @@ package net.neoforged.moddevgradle.legacyforge.internal; +import java.io.IOException; +import javax.inject.Inject; import net.neoforged.moddevgradle.legacyforge.tasks.RemapOperation; import org.gradle.api.artifacts.transform.CacheableTransform; import org.gradle.api.artifacts.transform.InputArtifact; @@ -18,9 +20,6 @@ import org.gradle.api.tasks.PathSensitivity; import org.gradle.process.ExecOperations; -import javax.inject.Inject; -import java.io.IOException; - @CacheableTransform abstract class RemappingTransform implements TransformAction { @InputArtifact @@ -35,8 +34,7 @@ abstract class RemappingTransform implements TransformAction { // Pass through network properties diff --git a/src/main/java/net/neoforged/minecraftdependencies/DefaultValueDisambiguationRule.java b/src/main/java/net/neoforged/minecraftdependencies/DefaultValueDisambiguationRule.java index a82992a5..4cfd1da7 100644 --- a/src/main/java/net/neoforged/minecraftdependencies/DefaultValueDisambiguationRule.java +++ b/src/main/java/net/neoforged/minecraftdependencies/DefaultValueDisambiguationRule.java @@ -1,10 +1,9 @@ package net.neoforged.minecraftdependencies; +import javax.inject.Inject; import org.gradle.api.attributes.AttributeDisambiguationRule; import org.gradle.api.attributes.MultipleCandidatesDetails; -import javax.inject.Inject; - /** * Sets a default value for an attribute if no value is requested. */ diff --git a/src/main/java/net/neoforged/minecraftdependencies/MinecraftDependenciesPlugin.java b/src/main/java/net/neoforged/minecraftdependencies/MinecraftDependenciesPlugin.java index 20ba9a51..cbcec399 100644 --- a/src/main/java/net/neoforged/minecraftdependencies/MinecraftDependenciesPlugin.java +++ b/src/main/java/net/neoforged/minecraftdependencies/MinecraftDependenciesPlugin.java @@ -8,8 +8,8 @@ *

* The defaults are: *

    - *
  • {@code net.neoforged.distribution} defaults to {@code client}
  • - *
  • {@code net.neoforged.operatingsystem} defaults to the current operating system
  • + *
  • {@code net.neoforged.distribution} defaults to {@code client}
  • + *
  • {@code net.neoforged.operatingsystem} defaults to the current operating system
  • *
*/ public class MinecraftDependenciesPlugin implements Plugin { @@ -20,13 +20,11 @@ public void apply(Project project) { // This happens under the assumption that client is usually a superset of server. var defaultDistribution = project.getObjects().named(MinecraftDistribution.class, MinecraftDistribution.CLIENT); attributesSchema.attribute(MinecraftDistribution.ATTRIBUTE).getDisambiguationRules().add(DistributionDisambiguationRule.class, spec -> spec.params( - defaultDistribution - )); + defaultDistribution)); var defaultOperatingSystem = project.getObjects().named(OperatingSystem.class, getDefaultOperatingSystem()); attributesSchema.attribute(OperatingSystem.ATTRIBUTE).getDisambiguationRules().add(OperatingSystemDisambiguationRule.class, spec -> spec.params( - defaultOperatingSystem - )); + defaultOperatingSystem)); }); } diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/DataFileCollection.java b/src/main/java/net/neoforged/moddevgradle/dsl/DataFileCollection.java index 1a81adea..bc5831f2 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/DataFileCollection.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/DataFileCollection.java @@ -1,9 +1,8 @@ package net.neoforged.moddevgradle.dsl; -import org.gradle.api.file.ConfigurableFileCollection; - -import javax.inject.Inject; import java.util.function.Consumer; +import javax.inject.Inject; +import org.gradle.api.file.ConfigurableFileCollection; /** * Holds data files (such as ATs) to be used or exposed. diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/InternalModelHelper.java b/src/main/java/net/neoforged/moddevgradle/dsl/InternalModelHelper.java index aaa18a70..e5c1c6ec 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/InternalModelHelper.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/InternalModelHelper.java @@ -9,12 +9,11 @@ */ @ApiStatus.Internal public class InternalModelHelper { - public InternalModelHelper() { - } + public InternalModelHelper() {} public static String nameOfRun(RunModel run, @Nullable String prefix, @Nullable String suffix) { return StringUtils.uncapitalize((prefix == null ? "" : prefix) - + StringUtils.capitalize(run.getName()) - + (suffix == null ? "" : StringUtils.capitalize(suffix))); + + StringUtils.capitalize(run.getName()) + + (suffix == null ? "" : StringUtils.capitalize(suffix))); } } diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/ModDevExtension.java b/src/main/java/net/neoforged/moddevgradle/dsl/ModDevExtension.java index 4a1614cf..d6fa353a 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/ModDevExtension.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/ModDevExtension.java @@ -1,5 +1,7 @@ package net.neoforged.moddevgradle.dsl; +import java.io.File; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.Branding; import net.neoforged.moddevgradle.internal.IdeIntegration; import net.neoforged.moddevgradle.internal.ModDevArtifactsWorkflow; @@ -14,9 +16,6 @@ import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.TaskProvider; -import javax.inject.Inject; -import java.io.File; - public abstract class ModDevExtension { private final NamedDomainObjectContainer mods; private final NamedDomainObjectContainer runs; @@ -28,8 +27,8 @@ public abstract class ModDevExtension { @Inject public ModDevExtension(Project project, - DataFileCollection accessTransformers, - DataFileCollection interfaceInjectionData) { + DataFileCollection accessTransformers, + DataFileCollection interfaceInjectionData) { mods = project.container(ModModel.class); runs = project.container(RunModel.class, name -> project.getObjects().newInstance(RunModel.class, name, project, mods)); parchment = project.getObjects().newInstance(Parchment.class); diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/ModModel.java b/src/main/java/net/neoforged/moddevgradle/dsl/ModModel.java index 02368b4d..bc259127 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/ModModel.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/ModModel.java @@ -1,12 +1,11 @@ package net.neoforged.moddevgradle.dsl; +import java.util.List; +import javax.inject.Inject; import org.gradle.api.Named; import org.gradle.api.provider.ListProperty; import org.gradle.api.tasks.SourceSet; -import javax.inject.Inject; -import java.util.List; - /** * Model of a mod. This tells the moddev plugin which classes and resources need to be combined to produce a valid mod. */ diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/ModdingVersionSettings.java b/src/main/java/net/neoforged/moddevgradle/dsl/ModdingVersionSettings.java index 08c61f3c..bc36311b 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/ModdingVersionSettings.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/ModdingVersionSettings.java @@ -1,14 +1,13 @@ package net.neoforged.moddevgradle.dsl; +import java.util.HashSet; +import java.util.Set; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import org.gradle.api.Project; import org.gradle.api.tasks.SourceSet; import org.jetbrains.annotations.Nullable; -import javax.inject.Inject; -import java.util.HashSet; -import java.util.Set; - public abstract class ModdingVersionSettings { @Nullable private String version; diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/NeoForgeExtension.java b/src/main/java/net/neoforged/moddevgradle/dsl/NeoForgeExtension.java index 04984dfc..5684ad12 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/NeoForgeExtension.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/NeoForgeExtension.java @@ -1,13 +1,9 @@ package net.neoforged.moddevgradle.dsl; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.ModDevPlugin; -import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import org.gradle.api.Action; import org.gradle.api.Project; -import org.gradle.api.tasks.SourceSet; - -import javax.inject.Inject; -import java.util.List; /** * This is the top-level {@code neoForge} extension, used to configure the moddev plugin. @@ -31,7 +27,7 @@ public NeoForgeExtension(Project project, DataFileCollection accessTransformers, * * Shorthand for: * - * enable { version = '...' } + * enable { version = '...' } * */ public void setVersion(String version) { @@ -45,7 +41,7 @@ public void setVersion(String version) { * * Shorthand for: * - * enable { neoFormVersion = '...' } + * enable { neoFormVersion = '...' } * */ public void setNeoFormVersion(String version) { diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/Parchment.java b/src/main/java/net/neoforged/moddevgradle/dsl/Parchment.java index c7cc72a0..28fe23a8 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/Parchment.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/Parchment.java @@ -1,5 +1,6 @@ package net.neoforged.moddevgradle.dsl; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.utils.PropertyUtils; import org.gradle.api.InvalidUserDataException; import org.gradle.api.Project; @@ -8,8 +9,6 @@ import org.gradle.api.tasks.Optional; import org.jetbrains.annotations.ApiStatus; -import javax.inject.Inject; - /** * Allows configuration of Parchment mappings for userdev. */ @@ -29,21 +28,16 @@ public Parchment(Project project) { return null; } return "org.parchmentmc.data" - + ":" + "parchment-" + minecraftVersion - + ":" + mappingVersion - + "@zip"; - }) - ) - ); + + ":" + "parchment-" + minecraftVersion + + ":" + mappingVersion + + "@zip"; + }))); getMinecraftVersion().convention( - project.getProviders().gradleProperty("neoForge.parchment.minecraftVersion") - ); + project.getProviders().gradleProperty("neoForge.parchment.minecraftVersion")); getMappingsVersion().convention( - project.getProviders().gradleProperty("neoForge.parchment.mappingsVersion") - ); + project.getProviders().gradleProperty("neoForge.parchment.mappingsVersion")); getConflictResolutionPrefix().convention( - project.getProviders().gradleProperty("neoForge.parchment.conflictResolutionPrefix").orElse("p_") - ); + project.getProviders().gradleProperty("neoForge.parchment.conflictResolutionPrefix").orElse("p_")); getEnabled().convention(getParchmentArtifact() .map(s -> !s.isEmpty()).orElse(PropertyUtils.getBooleanProperty(project, "neoForge.parchment.enabled").orElse(false))); } @@ -85,5 +79,4 @@ public Parchment(Project project) { */ @Input public abstract Property getEnabled(); - } diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/RunModel.java b/src/main/java/net/neoforged/moddevgradle/dsl/RunModel.java index d51b3dbe..eb2d9f89 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/RunModel.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/RunModel.java @@ -1,5 +1,10 @@ package net.neoforged.moddevgradle.dsl; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.regex.Pattern; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import net.neoforged.moddevgradle.internal.utils.StringUtils; import org.gradle.api.GradleException; @@ -17,12 +22,6 @@ import org.gradle.api.tasks.TaskProvider; import org.slf4j.event.Level; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.regex.Pattern; - /** * Model of a run. Each run will generate a {@code runXxx} gradle task and optionally * (enabled by default) a corresponding IDE run. diff --git a/src/main/java/net/neoforged/moddevgradle/dsl/UnitTest.java b/src/main/java/net/neoforged/moddevgradle/dsl/UnitTest.java index 5e9442c1..51d62343 100644 --- a/src/main/java/net/neoforged/moddevgradle/dsl/UnitTest.java +++ b/src/main/java/net/neoforged/moddevgradle/dsl/UnitTest.java @@ -1,12 +1,11 @@ package net.neoforged.moddevgradle.dsl; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.ModDevRunWorkflow; import org.gradle.api.Project; import org.gradle.api.provider.Property; import org.gradle.api.provider.SetProperty; -import javax.inject.Inject; - /** * Used to enable and configure the JUnit integration. */ @@ -24,8 +23,7 @@ public UnitTest(Project project) { public void enable() { ModDevRunWorkflow.get(project).configureTesting( getTestedMod(), - getLoadedMods() - ); + getLoadedMods()); } /** diff --git a/src/main/java/net/neoforged/moddevgradle/internal/CreateLaunchScriptTask.java b/src/main/java/net/neoforged/moddevgradle/internal/CreateLaunchScriptTask.java index cf0ef447..110999f4 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/CreateLaunchScriptTask.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/CreateLaunchScriptTask.java @@ -1,5 +1,13 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import javax.inject.Inject; import net.neoforged.moddevgradle.dsl.RunModel; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import net.neoforged.moddevgradle.internal.utils.FileUtils; @@ -19,15 +27,6 @@ import org.gradle.api.tasks.TaskAction; import org.gradle.jvm.toolchain.JavaToolchainService; -import javax.inject.Inject; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - /** * Writes standalone start scripts to launch the game. * These scripts are useful for launching the game outside Gradle or the IDE, for example, from tools @@ -89,8 +88,7 @@ public CreateLaunchScriptTask() { var java = ExtensionUtils.getExtension(getProject(), "java", JavaPluginExtension.class); getJavaExecutable().convention(getJavaToolchainService() .launcherFor(java.getToolchain()) - .map(javaLauncher -> javaLauncher.getExecutablePath().getAsFile().getAbsolutePath()) - ); + .map(javaLauncher -> javaLauncher.getExecutablePath().getAsFile().getAbsolutePath())); } @TaskAction @@ -131,15 +129,13 @@ private void writeClasspathArguments() throws IOException { var lines = List.of( "-classpath", - RunUtils.escapeJvmArg(classpathFileList) - ); + RunUtils.escapeJvmArg(classpathFileList)); FileUtils.writeLinesSafe( getClasspathArgsFile().get().getAsFile().toPath(), lines, // JVM expects default character set - StringUtils.getNativeCharset() - ); + StringUtils.getNativeCharset()); } private void writeLaunchScriptForWindows(List javaCommand) throws IOException { @@ -151,8 +147,7 @@ private void writeLaunchScriptForWindows(List javaCommand) throws IOExce // https://stackoverflow.com/a/1427817 "for /f \"tokens=2 delims=:.\" %%x in ('chcp') do set _codepage=%%x", // Switch encoding to Unicode, otherwise the next "cd" might not work with special chars - "chcp 65001>nul" - ); + "chcp 65001>nul"); for (var entry : getEnvironment().get().entrySet()) { lines.add("set " + escapeBatchScriptArg(entry.getKey()) + "=" + escapeBatchScriptArg(entry.getValue())); @@ -163,19 +158,17 @@ private void writeLaunchScriptForWindows(List javaCommand) throws IOExce javaCommand.stream().map(this::escapeBatchScriptArg).collect(Collectors.joining(" ")), // When Minecraft crashed, pause to prevent the console from closing, making it harder to read the error "if not ERRORLEVEL 0 (" + - " echo Minecraft failed with exit code %ERRORLEVEL%" + - " pause" + - ")", + " echo Minecraft failed with exit code %ERRORLEVEL%" + + " pause" + + ")", // Restore original codepage "chcp %_codepage%>nul", - "endlocal" - ); + "endlocal"); FileUtils.writeStringSafe( getLaunchScript().get().getAsFile().toPath(), String.join("\r\n", lines), - StandardCharsets.UTF_8 - ); + StandardCharsets.UTF_8); } private String escapeBatchScriptArg(String text) { @@ -195,14 +188,12 @@ private void writeLaunchScriptForUnix(List javaCommand) throws IOExcepti Collections.addAll(lines, "(cd " + escapeShellArg(getWorkingDirectory().get()) + "; exec " - + javaCommand.stream().map(this::escapeShellArg).collect(Collectors.joining(" ")) + ")" - ); + + javaCommand.stream().map(this::escapeShellArg).collect(Collectors.joining(" ")) + ")"); FileUtils.writeStringSafe( getLaunchScript().get().getAsFile().toPath(), String.join("\n", lines), - StandardCharsets.UTF_8 - ); + StandardCharsets.UTF_8); } private String escapeShellArg(String text) { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/DataFileCollections.java b/src/main/java/net/neoforged/moddevgradle/internal/DataFileCollections.java index 896ec937..b935b2fd 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/DataFileCollections.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/DataFileCollections.java @@ -1,5 +1,7 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.util.function.Consumer; import net.neoforged.moddevgradle.dsl.DataFileCollection; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import org.gradle.api.Project; @@ -10,9 +12,6 @@ import org.gradle.api.tasks.SourceSet; import org.jetbrains.annotations.ApiStatus; -import java.io.File; -import java.util.function.Consumer; - /** * Access Transformers and Interface Injection Data are treated in a common way as "collections of data files", * which can be declared via a {@link DataFileCollection DSL}, and have an associated configuration for internal @@ -22,7 +21,8 @@ */ @ApiStatus.Internal public record DataFileCollections(CollectionWrapper accessTransformers, - CollectionWrapper interfaceInjectionData) { + CollectionWrapper interfaceInjectionData) { + public static final String CONFIGURATION_ACCESS_TRANSFORMERS = "accessTransformers"; public static final String CONFIGURATION_INTERFACE_INJECTION_DATA = "interfaceInjectionData"; @@ -37,8 +37,7 @@ public static DataFileCollections create(Project project) { project, CONFIGURATION_ACCESS_TRANSFORMERS, "AccessTransformers to widen visibility of Minecraft classes/fields/methods", - "accesstransformer" - ); + "accesstransformer"); accessTransformers.extension().getFiles().convention(project.provider(() -> { var collection = project.getObjects().fileCollection(); @@ -59,14 +58,11 @@ public static DataFileCollections create(Project project) { project, CONFIGURATION_INTERFACE_INJECTION_DATA, "Interface injection data adds extend/implements clauses for interfaces to Minecraft code at development time", - "interfaceinjection" - ); + "interfaceinjection"); return new DataFileCollections(accessTransformers, interfaceInjectionData); } - - public record CollectionWrapper(DataFileCollection extension, Configuration configuration) { - } + public record CollectionWrapper(DataFileCollection extension, Configuration configuration) {} private static CollectionWrapper createCollection(Project project, String name, String description, String category) { var configuration = project.getConfigurations().create(name, spec -> { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/EclipseIntegration.java b/src/main/java/net/neoforged/moddevgradle/internal/EclipseIntegration.java index ba9b6410..40e97557 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/EclipseIntegration.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/EclipseIntegration.java @@ -1,5 +1,13 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import javax.xml.stream.XMLStreamException; import net.neoforged.elc.configs.GradleLaunchConfig; import net.neoforged.elc.configs.JavaApplicationLaunchConfig; import net.neoforged.elc.configs.LaunchConfig; @@ -21,15 +29,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.xml.stream.XMLStreamException; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - /** * Provides integration with Eclipse Buildship and VSCode extensions based on it. */ @@ -55,7 +54,6 @@ protected EclipseIntegration(Project project, Branding branding) { */ @Override public void attachSources(Map, Provider> jarToSourceJarMapping) { - var fileClasspath = eclipseModel.getClasspath().getFile(); fileClasspath.whenMerged((Classpath classpath) -> { for (var mapping : jarToSourceJarMapping.entrySet()) { @@ -73,7 +71,7 @@ public void attachSources(Map, Provider> jarT @Override public void configureRuns(Map> prepareRunTasks, - Iterable runs) { + Iterable runs) { // Set up runs if running under buildship and in VS Code project.afterEvaluate(ignored -> { for (var run : runs) { @@ -85,11 +83,11 @@ public void configureRuns(Map> prepareRunTask @Override public void configureTesting(Provider> loadedMods, - Provider testedMod, - Provider runArgsDir, - File gameDirectory, - Provider programArgsFile, - Provider vmArgsFile) { + Provider testedMod, + Provider runArgsDir, + File gameDirectory, + Provider programArgsFile, + Provider vmArgsFile) { // Eclipse has no concept of JUnit run templates. We cannot configure VM args or similar for all JUnit runs. } @@ -107,8 +105,8 @@ private static EclipseModel getOrCreateEclipseModel(Project project) { } private void addEclipseLaunchConfiguration(Project project, - RunModel run, - PrepareRun prepareTask) { + RunModel run, + PrepareRun prepareTask) { if (!prepareTask.getEnabled()) { LOG.info("Not creating Eclipse run {} since its prepare task {} is disabled", run, prepareTask); return; @@ -160,8 +158,7 @@ private void addEclipseLaunchConfiguration(Project project, var config = JavaApplicationLaunchConfig.builder(eclipseProjectName) .vmArgs( RunUtils.escapeJvmArg(RunUtils.getArgFileParameter(prepareTask.getVmArgsFile().get())), - RunUtils.escapeJvmArg(modFoldersProvider.getArgument()) - ) + RunUtils.escapeJvmArg(modFoldersProvider.getArgument())) .args(RunUtils.escapeJvmArg(RunUtils.getArgFileParameter(prepareTask.getProgramArgsFile().get()))) .envVar(RunUtils.replaceModClassesEnv(run, modFoldersProvider)) .workingDirectory(run.getGameDirectory().get().getAsFile().getAbsolutePath()) @@ -170,8 +167,8 @@ private void addEclipseLaunchConfiguration(Project project, } protected static ModFoldersProvider getModFoldersProvider(Project project, - Provider> modsProvider, - @Nullable Provider testedMod) { + Provider> modsProvider, + @Nullable Provider testedMod) { var folders = RunUtils.buildModFolders(project, modsProvider, testedMod, (sourceSet, output) -> { output.from(RunUtils.findSourceSetProject(project, sourceSet).getProjectDir().toPath() .resolve("bin") diff --git a/src/main/java/net/neoforged/moddevgradle/internal/IdeIntegration.java b/src/main/java/net/neoforged/moddevgradle/internal/IdeIntegration.java index 7ae3ebf1..8e38adea 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/IdeIntegration.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/IdeIntegration.java @@ -1,5 +1,8 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.util.Map; +import java.util.Set; import net.neoforged.moddevgradle.dsl.ModModel; import net.neoforged.moddevgradle.dsl.RunModel; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; @@ -13,10 +16,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.util.Map; -import java.util.Set; - /** * Implementing classes are responsible for registering {@code ideSyncTask} with their IDE. */ @@ -70,8 +69,7 @@ private static IdeIntegration createForProject(Project project, Branding brandin * Locations are usually JAR files but may be folders. * @see #shouldUseCombinedSourcesAndClassesArtifact() This method will not work if the IDE doesn't support attaching sources. */ - void attachSources(Map, Provider> jarToSourceJarMapping) { - } + void attachSources(Map, Provider> jarToSourceJarMapping) {} /** * Only IntelliJ needs the combined artifact. @@ -91,20 +89,17 @@ public final void runTaskOnProjectSync(Object task) { ideSyncTask.configure(ideSyncTask -> ideSyncTask.dependsOn(task)); } - void configureRuns(Map> prepareRunTasks, Iterable runs) { - } + void configureRuns(Map> prepareRunTasks, Iterable runs) {} void configureTesting(Provider> loadedMods, - Provider testedMod, - Provider runArgsDir, - File gameDirectory, - Provider programArgsFile, - Provider vmArgsFile) { - } + Provider testedMod, + Provider runArgsDir, + File gameDirectory, + Provider programArgsFile, + Provider vmArgsFile) {} protected boolean shouldGenerateConfigFor(RunModel run) { var ideName = run.getIdeName().get(); return !ideName.isBlank(); } - } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/IntelliJIntegration.java b/src/main/java/net/neoforged/moddevgradle/internal/IntelliJIntegration.java index 35bf723e..2c23eb6d 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/IntelliJIntegration.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/IntelliJIntegration.java @@ -1,5 +1,15 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; +import javax.inject.Inject; import net.neoforged.moddevgradle.dsl.ModModel; import net.neoforged.moddevgradle.dsl.RunModel; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; @@ -28,17 +38,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; - final class IntelliJIntegration extends IdeIntegration { private static final Logger LOG = LoggerFactory.getLogger(IntelliJIntegration.class); @@ -82,7 +81,6 @@ public void attachSources(Map, Provider> jarT @Override public void configureRuns(Map> prepareRunTasks, Iterable runs) { - // IDEA Sync has no real notion of tasks or providers or similar project.afterEvaluate(ignored -> { @@ -111,11 +109,11 @@ public void configureRuns(Map> prepareRunTask @Override public void configureTesting(Provider> loadedMods, - Provider testedMod, - Provider runArgsDir, - File gameDirectory, - Provider programArgsFile, - Provider vmArgsFile) { + Provider testedMod, + Provider runArgsDir, + File gameDirectory, + Provider programArgsFile, + Provider vmArgsFile) { // IDEA Sync has no real notion of tasks or providers or similar project.afterEvaluate(ignored -> { // Write out a separate file that has IDE specific VM args, which include the definition of the output directories. @@ -149,8 +147,7 @@ public void configureTesting(Provider> loadedMods, + " " + RunUtils.escapeJvmArg("@" + buildRelativePath(vmArgsFile, gameDirectory)) + " " - + RunUtils.escapeJvmArg("@" + buildRelativePath(intellijVmArgsFile, gameDirectory)) - ); + + RunUtils.escapeJvmArg("@" + buildRelativePath(intellijVmArgsFile, gameDirectory))); }); } }); @@ -174,10 +171,10 @@ private RunConfigurationContainer getIntelliJRunConfigurations() { } private static void addIntelliJRunConfiguration(Project project, - RunConfigurationContainer runConfigurations, - @Nullable Function outputDirectory, - RunModel run, - PrepareRun prepareTask) { + RunConfigurationContainer runConfigurations, + @Nullable Function outputDirectory, + RunModel run, + PrepareRun prepareTask) { var appRun = new Application(run.getIdeName().get(), project); var sourceSets = ExtensionUtils.getSourceSets(project); var sourceSet = run.getSourceSet().get(); @@ -191,9 +188,8 @@ private static void addIntelliJRunConfiguration(Project project, appRun.setEnvs(RunUtils.replaceModClassesEnv(run, modFoldersProvider)); appRun.setJvmArgs( RunUtils.escapeJvmArg(RunUtils.getArgFileParameter(prepareTask.getVmArgsFile().get())) - + " " - + RunUtils.escapeJvmArg(modFoldersProvider.getArgument()) - ); + + " " + + RunUtils.escapeJvmArg(modFoldersProvider.getArgument())); appRun.setMainClass(RunUtils.DEV_LAUNCH_MAIN_CLASS); appRun.setProgramParameters(RunUtils.escapeJvmArg(RunUtils.getArgFileParameter(prepareTask.getProgramArgsFile().get()))); @@ -233,9 +229,9 @@ public boolean shouldUseCombinedSourcesAndClassesArtifact() { } private static ModFoldersProvider getModFoldersProvider(Project project, - @Nullable Function outputDirectory, - Provider> modsProvider, - @Nullable Provider testedMod) { + @Nullable Function outputDirectory, + Provider> modsProvider, + @Nullable Provider testedMod) { Provider> folders; if (outputDirectory != null) { folders = RunUtils.buildModFolders(project, modsProvider, testedMod, (sourceSet, output) -> { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/IntelliJOutputDirectoryValueSource.java b/src/main/java/net/neoforged/moddevgradle/internal/IntelliJOutputDirectoryValueSource.java index efd3995e..a5fe7943 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/IntelliJOutputDirectoryValueSource.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/IntelliJOutputDirectoryValueSource.java @@ -1,5 +1,14 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.function.Function; +import javax.inject.Inject; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; import org.gradle.api.Project; import org.gradle.api.provider.Property; import org.gradle.api.provider.ValueSource; @@ -8,16 +17,6 @@ import org.jetbrains.annotations.Nullable; import org.xml.sax.InputSource; -import javax.inject.Inject; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.function.Function; - /** * Checks the IntelliJ project files for the setting that determines whether 1) the build is delegated * and 2) the configured output directory. @@ -37,8 +36,7 @@ interface Params extends ValueSourceParameters { } @Inject - public IntelliJOutputDirectoryValueSource() { - } + public IntelliJOutputDirectoryValueSource() {} /** * Returns a function that maps a project to the configured output directory, diff --git a/src/main/java/net/neoforged/moddevgradle/internal/ModDevArtifactsWorkflow.java b/src/main/java/net/neoforged/moddevgradle/internal/ModDevArtifactsWorkflow.java index c206cb8c..4dbf034e 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/ModDevArtifactsWorkflow.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/ModDevArtifactsWorkflow.java @@ -1,5 +1,10 @@ package net.neoforged.moddevgradle.internal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Function; import net.neoforged.minecraftdependencies.MinecraftDistribution; import net.neoforged.moddevgradle.dsl.ModDevExtension; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; @@ -29,12 +34,6 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - /** * The workflow needed to produce artifacts and assets for compiling and running a mod. */ @@ -49,10 +48,9 @@ public record ModDevArtifactsWorkflow( Configuration runtimeDependencies, Configuration compileDependencies, Provider modDevBuildDir, - Provider artifactsBuildDir -) { - private static final String EXTENSION_NAME = "__internal_modDevArtifactsWorkflow"; + Provider artifactsBuildDir) { + private static final String EXTENSION_NAME = "__internal_modDevArtifactsWorkflow"; public static ModDevArtifactsWorkflow get(Project project) { var result = ExtensionUtils.findExtension(project, EXTENSION_NAME, ModDevArtifactsWorkflow.class); if (result == null) { @@ -62,15 +60,14 @@ public static ModDevArtifactsWorkflow get(Project project) { } public static ModDevArtifactsWorkflow create(Project project, - Collection enabledSourceSets, - Branding branding, - ModDevExtension extension, - ModdingDependencies moddingDependencies, - ArtifactNamingStrategy artifactNamingStrategy, - Configuration accessTransformers, - Configuration interfaceInjectionData, - VersionCapabilitiesInternal versionCapabilities - ) { + Collection enabledSourceSets, + Branding branding, + ModDevExtension extension, + ModdingDependencies moddingDependencies, + ArtifactNamingStrategy artifactNamingStrategy, + Configuration accessTransformers, + Configuration interfaceInjectionData, + VersionCapabilitiesInternal versionCapabilities) { if (project.getExtensions().findByName(EXTENSION_NAME) != null) { throw new InvalidUserCodeException("You cannot enable modding in the same project twice."); } @@ -84,8 +81,7 @@ public static ModDevArtifactsWorkflow create(Project project, var createManifestConfigurations = configureArtifactManifestConfigurations( project, moddingDependencies.neoForgeDependency(), - moddingDependencies.neoFormDependency() - ); + moddingDependencies.neoFormDependency()); var dependencyFactory = project.getDependencyFactory(); var configurations = project.getConfigurations(); @@ -125,8 +121,7 @@ public static ModDevArtifactsWorkflow create(Project project, // NFRT needs access to a JDK of the right version to be able to correctly decompile and recompile the code task.getToolsJavaExecutable().set(javaToolchainService .launcherFor(spec -> spec.getLanguageVersion().set(JavaLanguageVersion.of(versionCapabilities.javaVersion()))) - .map(javaLauncher -> javaLauncher.getExecutablePath().getAsFile().getAbsolutePath()) - ); + .map(javaLauncher -> javaLauncher.getExecutablePath().getAsFile().getAbsolutePath())); task.getAccessTransformers().from(accessTransformers); task.getInterfaceInjectionData().from(interfaceInjectionData); @@ -135,8 +130,7 @@ public static ModDevArtifactsWorkflow create(Project project, task.getParchmentEnabled().set(parchment.getEnabled()); task.getParchmentConflictResolutionPrefix().set(parchment.getConflictResolutionPrefix()); - Function> artifactPathStrategy = artifact -> - artifactsBuildDir.map(dir -> dir.file(artifactNamingStrategy.getFilename(artifact))); + Function> artifactPathStrategy = artifact -> artifactsBuildDir.map(dir -> dir.file(artifactNamingStrategy.getFilename(artifact))); task.getCompiledArtifact().set(artifactPathStrategy.apply(WorkflowArtifact.COMPILED)); task.getCompiledWithSourcesArtifact().set(artifactPathStrategy.apply(WorkflowArtifact.COMPILED_WITH_SOURCES)); @@ -201,9 +195,7 @@ public static ModDevArtifactsWorkflow create(Project project, ideIntegration.attachSources( Map.of( createArtifacts.get().getCompiledArtifact(), - createArtifacts.get().getSourcesArtifact() - ) - ); + createArtifacts.get().getSourcesArtifact())); } var result = new ModDevArtifactsWorkflow( @@ -216,8 +208,7 @@ public static ModDevArtifactsWorkflow create(Project project, runtimeDependencies, compileDependencies, modDevBuildDir, - artifactsBuildDir - ); + artifactsBuildDir); project.getExtensions().add(ModDevArtifactsWorkflow.class, EXTENSION_NAME, result); @@ -234,8 +225,7 @@ public static ModDevArtifactsWorkflow create(Project project, private static List configureArtifactManifestConfigurations( Project project, @Nullable ModuleDependency moddingPlatformDependency, - @Nullable ModuleDependency recompilableMinecraftWorkflowDependency - ) { + @Nullable ModuleDependency recompilableMinecraftWorkflowDependency) { var configurations = project.getConfigurations(); var configurationPrefix = "neoFormRuntimeDependencies"; @@ -343,8 +333,7 @@ public Provider requestAdditionalMinecraftArtifact(String id, Strin public Provider requestAdditionalMinecraftArtifact(String id, Provider path) { createArtifacts.configure(task -> task.getAdditionalResults().put(id, path.map(RegularFile::getAsFile))); return project.getLayout().file( - createArtifacts.flatMap(task -> task.getAdditionalResults().getting(id)) - ); + createArtifacts.flatMap(task -> task.getAdditionalResults().getting(id))); } private static void setNamedAttribute(Project project, AttributeContainer attributes, Attribute attribute, String value) { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/ModDevPlugin.java b/src/main/java/net/neoforged/moddevgradle/internal/ModDevPlugin.java index eeb3c5a7..26a7e3dd 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/ModDevPlugin.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/ModDevPlugin.java @@ -41,15 +41,13 @@ public void apply(Project project) { NeoForgeExtension.NAME, NeoForgeExtension.class, dataFileCollections.accessTransformers().extension(), - dataFileCollections.interfaceInjectionData().extension() - ); + dataFileCollections.interfaceInjectionData().extension()); } public void enable( Project project, ModdingVersionSettings settings, - ModDevExtension extension - ) { + ModDevExtension extension) { var neoForgeVersion = settings.getVersion(); var neoFormVersion = settings.getNeoFormVersion(); if (neoForgeVersion == null && neoFormVersion == null) { @@ -85,7 +83,6 @@ public void enable( var configurations = project.getConfigurations(); - var dependencies = neoForge != null ? ModdingDependencies.create(neoForge, neoForgeNotation, neoForm, neoFormNotation, versionCapabilities) : ModdingDependencies.createVanillaOnly(neoForm, neoFormNotation); @@ -98,14 +95,12 @@ public void enable( artifactNamingStrategy, configurations.getByName(DataFileCollections.CONFIGURATION_ACCESS_TRANSFORMERS), configurations.getByName(DataFileCollections.CONFIGURATION_INTERFACE_INJECTION_DATA), - versionCapabilities - ); + versionCapabilities); ModDevRunWorkflow.create( project, Branding.MDG, artifacts, - extension.getRuns() - ); + extension.getRuns()); } } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/ModDevRunWorkflow.java b/src/main/java/net/neoforged/moddevgradle/internal/ModDevRunWorkflow.java index 1c343c74..246f6212 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/ModDevRunWorkflow.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/ModDevRunWorkflow.java @@ -1,5 +1,12 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.util.HashMap; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; import net.neoforged.minecraftdependencies.MinecraftDistribution; import net.neoforged.moddevgradle.dsl.InternalModelHelper; import net.neoforged.moddevgradle.dsl.ModModel; @@ -33,14 +40,6 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.event.Level; -import java.io.File; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - /** * After modding has been enabled, this will be attached as an extension to the project. */ @@ -70,14 +69,14 @@ public class ModDevRunWorkflow { * (apiElements vs. runtimeElements). */ private ModDevRunWorkflow(Project project, - Branding branding, - ModDevArtifactsWorkflow artifactsWorkflow, - @Nullable ModuleDependency modulePathDependency, - @Nullable ModuleDependency runTypesConfigDependency, - @Nullable ModuleDependency testFixturesDependency, - ModuleDependency gameLibrariesDependency, - DomainObjectCollection runs, - VersionCapabilitiesInternal versionCapabilities) { + Branding branding, + ModDevArtifactsWorkflow artifactsWorkflow, + @Nullable ModuleDependency modulePathDependency, + @Nullable ModuleDependency runTypesConfigDependency, + @Nullable ModuleDependency testFixturesDependency, + ModuleDependency gameLibrariesDependency, + DomainObjectCollection runs, + VersionCapabilitiesInternal versionCapabilities) { this.project = project; this.branding = branding; this.modulePathDependency = modulePathDependency; @@ -125,8 +124,7 @@ private ModDevRunWorkflow(Project project, }, legacyClassPath -> legacyClassPath.extendsFrom(additionalClasspath), artifactsWorkflow.downloadAssets().flatMap(DownloadAssets::getAssetPropertiesFile), - versionCapabilities - ); + versionCapabilities); } public static ModDevRunWorkflow get(Project project) { @@ -138,10 +136,9 @@ public static ModDevRunWorkflow get(Project project) { } public static ModDevRunWorkflow create(Project project, - Branding branding, - ModDevArtifactsWorkflow artifactsWorkflow, - DomainObjectCollection runs) { - + Branding branding, + ModDevArtifactsWorkflow artifactsWorkflow, + DomainObjectCollection runs) { var dependencies = artifactsWorkflow.dependencies(); var versionCapabilites = artifactsWorkflow.versionCapabilities(); @@ -154,8 +151,7 @@ public static ModDevRunWorkflow create(Project project, dependencies.testFixturesDependency(), dependencies.gameLibrariesDependency(), runs, - versionCapabilites - ); + versionCapabilites); project.getExtensions().add(EXTENSION_NAME, workflow); @@ -202,8 +198,7 @@ public void configureTesting(Provider testedMod, Provider testedMod, Provider createArtifacts) { spec.getDependencies().add( project.getDependencyFactory().create( - project.files(createArtifacts.flatMap(CreateMinecraftArtifacts::getResourcesArtifact)) - ) - ); + project.files(createArtifacts.flatMap(CreateMinecraftArtifacts::getResourcesArtifact)))); } public static void setupRuns( @@ -225,8 +218,7 @@ public static void setupRuns( Consumer configureModulePath, Consumer configureLegacyClasspath, Provider assetPropertiesFile, - VersionCapabilitiesInternal versionCapabilities - ) { + VersionCapabilitiesInternal versionCapabilities) { var dependencyFactory = project.getDependencyFactory(); var ideIntegration = IdeIntegration.of(project, branding); @@ -263,8 +255,7 @@ public static void setupRuns( assetPropertiesFile, devLaunchConfig, versionCapabilities, - createLaunchScriptsTask - ); + createLaunchScriptsTask); prepareRunTasks.put(run, prepareRunTask); }); ideIntegration.configureRuns(prepareRunTasks, runs); @@ -405,16 +396,15 @@ private static TaskProvider setupRunInGradle( * @see #setupRunInGradle for a description of the parameters */ static void setupTestTask(Project project, - Branding branding, - Object runTemplatesSourceFile, - TaskProvider testTask, - Provider> loadedMods, - Provider testedMod, - Provider argFileDir, - Consumer configureModulePath, - Consumer configureLegacyClasspath, - Provider assetPropertiesFile - ) { + Branding branding, + Object runTemplatesSourceFile, + TaskProvider testTask, + Provider> loadedMods, + Provider testedMod, + Provider argFileDir, + Consumer configureModulePath, + Consumer configureLegacyClasspath, + Provider assetPropertiesFile) { var gameDirectory = new File(project.getProjectDir(), JUNIT_GAME_DIR); var ideIntegration = IdeIntegration.of(project, branding); diff --git a/src/main/java/net/neoforged/moddevgradle/internal/ModdingDependencies.java b/src/main/java/net/neoforged/moddevgradle/internal/ModdingDependencies.java index 50665fc9..2a26d6be 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/ModdingDependencies.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/ModdingDependencies.java @@ -1,11 +1,10 @@ package net.neoforged.moddevgradle.internal; +import java.util.Map; import net.neoforged.moddevgradle.internal.utils.VersionCapabilitiesInternal; import org.gradle.api.artifacts.ModuleDependency; import org.jetbrains.annotations.Nullable; -import java.util.Map; - public record ModdingDependencies( @Nullable ModuleDependency neoForgeDependency, @Nullable String neoForgeDependencyNotation, @@ -14,14 +13,12 @@ public record ModdingDependencies( ModuleDependency gameLibrariesDependency, @Nullable ModuleDependency modulePathDependency, @Nullable ModuleDependency runTypesConfigDependency, - @Nullable ModuleDependency testFixturesDependency -) { - + @Nullable ModuleDependency testFixturesDependency) { public static ModdingDependencies create(ModuleDependency neoForge, - String neoForgeNotation, - @Nullable ModuleDependency neoForm, - @Nullable String neoFormNotation, - VersionCapabilitiesInternal versionCapabilities) { + String neoForgeNotation, + @Nullable ModuleDependency neoForm, + @Nullable String neoFormNotation, + VersionCapabilitiesInternal versionCapabilities) { var runTypesDataDependency = neoForge.copy() .capabilities(caps -> caps.requireCapability("net.neoforged:neoforge-moddev-config")); var modulePathDependency = neoForge.copy() @@ -45,8 +42,7 @@ public static ModdingDependencies create(ModuleDependency neoForge, librariesDependency, modulePathDependency, runTypesDataDependency, - testFixturesDependency - ); + testFixturesDependency); } public static ModdingDependencies createVanillaOnly(ModuleDependency neoForm, String neoFormNotation) { @@ -61,7 +57,6 @@ public static ModdingDependencies createVanillaOnly(ModuleDependency neoForm, St librariesDependency, null, null, - null - ); + null); } } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/NeoDevFacade.java b/src/main/java/net/neoforged/moddevgradle/internal/NeoDevFacade.java index 59bb88c3..272dfe3f 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/NeoDevFacade.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/NeoDevFacade.java @@ -1,5 +1,7 @@ package net.neoforged.moddevgradle.internal; +import java.util.Set; +import java.util.function.Consumer; import net.neoforged.moddevgradle.dsl.ModModel; import net.neoforged.moddevgradle.dsl.RunModel; import net.neoforged.moddevgradle.internal.utils.VersionCapabilitiesInternal; @@ -12,9 +14,6 @@ import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.testing.Test; -import java.util.Set; -import java.util.function.Consumer; - /** * Internal API provided to the NeoForge development build scripts. * This is NOT API for normal mod development projects! @@ -23,17 +22,15 @@ * b) evolve the internal API while not having to modify NeoDev. */ public final class NeoDevFacade { - private NeoDevFacade() { - } + private NeoDevFacade() {} public static void setupRuns(Project project, - Provider argFileDir, - DomainObjectCollection runs, - Object runTemplatesSourceFile, - Consumer configureModulePath, - Consumer configureAdditionalClasspath, - Provider assetPropertiesFile - ) { + Provider argFileDir, + DomainObjectCollection runs, + Object runTemplatesSourceFile, + Consumer configureModulePath, + Consumer configureAdditionalClasspath, + Provider assetPropertiesFile) { ModDevRunWorkflow.setupRuns( project, Branding.NEODEV, @@ -44,19 +41,17 @@ public static void setupRuns(Project project, configureAdditionalClasspath, assetPropertiesFile, // This overload of the method was only used by NeoForge 1.21.3 - VersionCapabilitiesInternal.ofMinecraftVersion("1.21.3") - ); + VersionCapabilitiesInternal.ofMinecraftVersion("1.21.3")); } public static void setupRuns(Project project, - Provider argFileDir, - DomainObjectCollection runs, - Object runTemplatesSourceFile, - Consumer configureModulePath, - Consumer configureAdditionalClasspath, - Provider assetPropertiesFile, - Provider neoFormVersion - ) { + Provider argFileDir, + DomainObjectCollection runs, + Object runTemplatesSourceFile, + Consumer configureModulePath, + Consumer configureAdditionalClasspath, + Provider assetPropertiesFile, + Provider neoFormVersion) { ModDevRunWorkflow.setupRuns( project, Branding.NEODEV, @@ -66,20 +61,18 @@ public static void setupRuns(Project project, configureModulePath, configureAdditionalClasspath, assetPropertiesFile, - neoFormVersion.map(VersionCapabilitiesInternal::ofNeoFormVersion).getOrElse(VersionCapabilitiesInternal.latest()) - ); + neoFormVersion.map(VersionCapabilitiesInternal::ofNeoFormVersion).getOrElse(VersionCapabilitiesInternal.latest())); } public static void setupTestTask(Project project, - Provider argFileDir, - TaskProvider testTask, - Object runTemplatesSourceFile, - Provider> loadedMods, - Provider testedMod, - Consumer configureModulePath, - Consumer configureAdditionalClasspath, - Provider assetPropertiesFile - ) { + Provider argFileDir, + TaskProvider testTask, + Object runTemplatesSourceFile, + Provider> loadedMods, + Provider testedMod, + Consumer configureModulePath, + Consumer configureAdditionalClasspath, + Provider assetPropertiesFile) { ModDevRunWorkflow.setupTestTask( project, Branding.NEODEV, @@ -90,8 +83,7 @@ public static void setupTestTask(Project project, argFileDir, configureModulePath, configureAdditionalClasspath, - assetPropertiesFile - ); + assetPropertiesFile); } public static void runTaskOnProjectSync(Project project, Object task) { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/PrepareRun.java b/src/main/java/net/neoforged/moddevgradle/internal/PrepareRun.java index bc21de28..55aa0ecb 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/PrepareRun.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/PrepareRun.java @@ -1,13 +1,12 @@ package net.neoforged.moddevgradle.internal; +import javax.inject.Inject; import org.gradle.api.GradleException; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Optional; import org.jetbrains.annotations.Nullable; -import javax.inject.Inject; - /** * Prepare all files needed to run a particular flavor of the game. */ diff --git a/src/main/java/net/neoforged/moddevgradle/internal/PrepareRunOrTest.java b/src/main/java/net/neoforged/moddevgradle/internal/PrepareRunOrTest.java index bab0aec8..4270cb73 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/PrepareRunOrTest.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/PrepareRunOrTest.java @@ -1,5 +1,16 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.zip.ZipFile; import net.neoforged.moddevgradle.internal.utils.FileUtils; import net.neoforged.moddevgradle.internal.utils.OperatingSystem; import net.neoforged.moddevgradle.internal.utils.StringUtils; @@ -25,18 +36,6 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.event.Level; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.zip.ZipFile; - /** * Performs preparation for running the game or running a test. * @@ -63,8 +62,8 @@ abstract class PrepareRunOrTest extends DefaultTask { * The source of the underlying run type templates. This must contain a single file, which has one of the * following supported formats: *
    - *
  • NeoForge Userdev config.json file
  • - *
  • NeoForge Userdev jar file, containing a Userdev config.json file
  • + *
  • NeoForge Userdev config.json file
  • + *
  • NeoForge Userdev jar file, containing a Userdev config.json file
  • *
* Subclasses implementing {@link #resolveRunType} can then access this information to get the run type template. */ @@ -205,23 +204,18 @@ private UserDevConfig getSimulatedUserDevConfigForVanilla() { var runTypes = new LinkedHashMap(); runTypes.put("client", new UserDevRunType( - true, "net.minecraft.client.main.Main", clientArgs, List.of(), Map.of(), Map.of() - )); + true, "net.minecraft.client.main.Main", clientArgs, List.of(), Map.of(), Map.of())); runTypes.put("server", new UserDevRunType( - true, "net.minecraft.server.Main", commonArgs, List.of(), Map.of(), Map.of() - )); + true, "net.minecraft.server.Main", commonArgs, List.of(), Map.of(), Map.of())); if (getVersionCapabilities().getOrElse(VersionCapabilitiesInternal.latest()).splitDataRuns()) { runTypes.put("clientData", new UserDevRunType( - true, "net.minecraft.client.data.Main", commonArgs, List.of(), Map.of(), Map.of() - )); + true, "net.minecraft.client.data.Main", commonArgs, List.of(), Map.of(), Map.of())); runTypes.put("serverData", new UserDevRunType( - true, "net.minecraft.data.Main", commonArgs, List.of(), Map.of(), Map.of() - )); + true, "net.minecraft.data.Main", commonArgs, List.of(), Map.of(), Map.of())); } else { runTypes.put("data", new UserDevRunType( - true, "net.minecraft.data.Main", commonArgs, List.of(), Map.of(), Map.of() - )); + true, "net.minecraft.data.Main", commonArgs, List.of(), Map.of(), Map.of())); } return new UserDevConfig(runTypes); @@ -267,8 +261,7 @@ private void writeJvmArguments(UserDevRunType runConfig, Map add getVmArgsFile().get().getAsFile().toPath(), lines, // JVM expects default character set - StringUtils.getNativeCharset() - ); + StringUtils.getNativeCharset()); } private void writeProgramArguments(UserDevRunType runConfig, @Nullable String mainClass) throws IOException { @@ -320,8 +313,7 @@ private void writeProgramArguments(UserDevRunType runConfig, @Nullable String ma getProgramArgsFile().get().getAsFile().toPath(), lines, // FML Junit and DevLaunch (starting in 1.0.1) read this file using UTF-8 - StandardCharsets.UTF_8 - ); + StandardCharsets.UTF_8); } private static void addSystemProp(String name, String value, List lines) { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/PrepareTest.java b/src/main/java/net/neoforged/moddevgradle/internal/PrepareTest.java index e49f5dd7..7cd15845 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/PrepareTest.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/PrepareTest.java @@ -1,10 +1,9 @@ package net.neoforged.moddevgradle.internal; +import javax.inject.Inject; import org.gradle.api.GradleException; import org.jetbrains.annotations.Nullable; -import javax.inject.Inject; - abstract class PrepareTest extends PrepareRunOrTest { @Inject public PrepareTest() { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/RepositoriesPlugin.java b/src/main/java/net/neoforged/moddevgradle/internal/RepositoriesPlugin.java index 848aacd3..ec296a1a 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/RepositoriesPlugin.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/RepositoriesPlugin.java @@ -1,5 +1,6 @@ package net.neoforged.moddevgradle.internal; +import java.net.URI; import net.neoforged.moddevgradle.internal.generated.MojangRepositoryFilter; import org.gradle.api.GradleException; import org.gradle.api.Plugin; @@ -10,14 +11,12 @@ import org.gradle.api.invocation.Gradle; import org.gradle.api.plugins.PluginAware; -import java.net.URI; - /** * This plugin acts in different roles depending on where it is applied: *
    - *
  • At the project-level, it will add the required repositories for moddev.
  • - *
  • At the settings-level, it will add the required repositories to the dependency management block, and add a marker plugin to the Gradle instance to prevent the - * repositories from being added again at the project-level.
  • + *
  • At the project-level, it will add the required repositories for moddev.
  • + *
  • At the settings-level, it will add the required repositories to the dependency management block, and add a marker plugin to the Gradle instance to prevent the + * repositories from being added again at the project-level.
  • *
*/ public class RepositoriesPlugin implements Plugin { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/RunGameTask.java b/src/main/java/net/neoforged/moddevgradle/internal/RunGameTask.java index 518f2a28..79928fb9 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/RunGameTask.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/RunGameTask.java @@ -1,5 +1,9 @@ package net.neoforged.moddevgradle.internal; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import javax.inject.Inject; import org.gradle.api.file.ConfigurableFileCollection; import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.MapProperty; @@ -11,11 +15,6 @@ import org.gradle.api.tasks.TaskAction; import org.gradle.work.DisableCachingByDefault; -import javax.inject.Inject; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.file.Files; - /** * By extending JavaExec, we allow IntelliJ to automatically attach a debugger to the forked JVM, making * these runs easy and nice to work with. @@ -33,8 +32,7 @@ public abstract class RunGameTask extends JavaExec { public abstract DirectoryProperty getGameDirectory(); @Inject - public RunGameTask() { - } + public RunGameTask() {} @TaskAction public void exec() { @@ -52,5 +50,4 @@ public void exec() { setWorkingDir(runDir); super.exec(); } - } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/RunUtils.java b/src/main/java/net/neoforged/moddevgradle/internal/RunUtils.java index eb8fbce5..a7e46922 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/RunUtils.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/RunUtils.java @@ -1,5 +1,21 @@ package net.neoforged.moddevgradle.internal; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; +import javax.inject.Inject; import net.neoforged.moddevgradle.dsl.InternalModelHelper; import net.neoforged.moddevgradle.dsl.ModModel; import net.neoforged.moddevgradle.dsl.RunModel; @@ -23,26 +39,8 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.event.Level; -import javax.inject.Inject; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Properties; -import java.util.Set; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; - final class RunUtils { - private RunUtils() { - } + private RunUtils() {} public static final String DEV_LAUNCH_GAV = "net.neoforged:DevLaunch:1.0.1"; // renovate public static final String DEV_LAUNCH_MAIN_CLASS = "net.neoforged.devlaunch.Main"; @@ -80,8 +78,7 @@ public static AssetProperties loadAssetProperties(File file) { return new AssetProperties( assetProperties.getProperty("asset_index"), - assetProperties.getProperty("assets_root") - ); + assetProperties.getProperty("assets_root")); } public static void writeLog4j2Configuration(Level rootLevel, Path destination) throws IOException { @@ -147,7 +144,7 @@ public static void writeLog4j2Configuration(Level rootLevel, Path destination) t - + @@ -155,7 +152,7 @@ public static void writeLog4j2Configuration(Level rootLevel, Path destination) t - + @@ -240,17 +237,17 @@ public static Map replaceModClassesEnv(RunModel model, ModFolder } public static Provider> getModFoldersForGradle(Project project, - Provider> modsProvider, - @Nullable Provider testedMod) { + Provider> modsProvider, + @Nullable Provider testedMod) { return buildModFolders(project, modsProvider, testedMod, (sourceSet, output) -> { output.from(sourceSet.getOutput()); }); } public static Provider> buildModFolders(Project project, - Provider> modsProvider, - @Nullable Provider testedModProvider, - BiConsumer outputFolderResolver) { + Provider> modsProvider, + @Nullable Provider testedModProvider, + BiConsumer outputFolderResolver) { // Convert it to optional to ensure zip will be called even if no mod under test is present. if (testedModProvider == null) { testedModProvider = project.provider(() -> null); @@ -291,11 +288,9 @@ public static Provider> buildModFolders(Project project, })); })); } - } -record AssetProperties(String assetIndex, String assetsRoot) { -} +record AssetProperties(String assetIndex, String assetsRoot) {} abstract class ModFoldersProvider implements CommandLineArgumentProvider { @Inject @@ -330,8 +325,7 @@ public Iterable asArguments() { abstract class ModFolder { @Inject - public ModFolder() { - } + public ModFolder() {} @InputFiles @Classpath diff --git a/src/main/java/net/neoforged/moddevgradle/internal/UserDevConfig.java b/src/main/java/net/neoforged/moddevgradle/internal/UserDevConfig.java index 29745a68..d62e210a 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/UserDevConfig.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/UserDevConfig.java @@ -1,7 +1,6 @@ package net.neoforged.moddevgradle.internal; import com.google.gson.Gson; - import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; @@ -17,4 +16,3 @@ public static UserDevConfig from(InputStream in) { return new Gson().fromJson(new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)), UserDevConfig.class); } } - diff --git a/src/main/java/net/neoforged/moddevgradle/internal/UserDevRunType.java b/src/main/java/net/neoforged/moddevgradle/internal/UserDevRunType.java index ff8a3c9f..bb6e54de 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/UserDevRunType.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/UserDevRunType.java @@ -4,5 +4,4 @@ import java.util.Map; public record UserDevRunType(boolean singleInstance, String main, List args, List jvmArgs, - Map env, Map props) { -} + Map env, Map props) {} diff --git a/src/main/java/net/neoforged/moddevgradle/internal/VsCodeIntegration.java b/src/main/java/net/neoforged/moddevgradle/internal/VsCodeIntegration.java index e3e35cf5..342f042b 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/VsCodeIntegration.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/VsCodeIntegration.java @@ -1,5 +1,9 @@ package net.neoforged.moddevgradle.internal; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Objects; import net.neoforged.moddevgradle.dsl.RunModel; import net.neoforged.vsclc.BatchedLaunchWriter; import net.neoforged.vsclc.attribute.ConsoleType; @@ -11,11 +15,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Objects; - /** * Provides integration with Eclipse Buildship and VSCode extensions based on it. */ @@ -28,7 +27,7 @@ final class VsCodeIntegration extends EclipseIntegration { @Override public void configureRuns(Map> prepareRunTasks, - Iterable runs) { + Iterable runs) { // Set up runs if running under buildship and in VS Code project.afterEvaluate(ignored -> { var launchWriter = new BatchedLaunchWriter(WritingMode.MODIFY_CURRENT); @@ -47,9 +46,9 @@ public void configureRuns(Map> prepareRunTask } private void addVscodeLaunchConfiguration(Project project, - RunModel run, - PrepareRun prepareTask, - BatchedLaunchWriter launchWriter) { + RunModel run, + PrepareRun prepareTask, + BatchedLaunchWriter launchWriter) { if (!prepareTask.getEnabled()) { LOG.info("Not creating VSCode run {} since its prepare task {} is disabled", run, prepareTask); return; diff --git a/src/main/java/net/neoforged/moddevgradle/internal/WorkflowArtifact.java b/src/main/java/net/neoforged/moddevgradle/internal/WorkflowArtifact.java index c1a7f795..2d16251d 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/WorkflowArtifact.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/WorkflowArtifact.java @@ -8,6 +8,7 @@ public enum WorkflowArtifact { COMPILED_WITH_SOURCES("-merged"), SOURCES("-sources"), CLIENT_RESOURCES("-client-extra-aka-minecraft-resources"); + public final String defaultSuffix; WorkflowArtifact(String defaultSuffix) { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/WriteLegacyClasspath.java b/src/main/java/net/neoforged/moddevgradle/internal/WriteLegacyClasspath.java index 3f6ad03e..f33421fd 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/WriteLegacyClasspath.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/WriteLegacyClasspath.java @@ -1,5 +1,10 @@ package net.neoforged.moddevgradle.internal; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.TreeSet; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.utils.FileUtils; import org.gradle.api.DefaultTask; import org.gradle.api.file.RegularFileProperty; @@ -8,16 +13,9 @@ import org.gradle.api.tasks.OutputFile; import org.gradle.api.tasks.TaskAction; -import javax.inject.Inject; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.TreeSet; - abstract class WriteLegacyClasspath extends DefaultTask { @Inject - public WriteLegacyClasspath() { - } + public WriteLegacyClasspath() {} @Input abstract ListProperty getEntries(); diff --git a/src/main/java/net/neoforged/moddevgradle/internal/jarjar/JarJarArtifacts.java b/src/main/java/net/neoforged/moddevgradle/internal/jarjar/JarJarArtifacts.java index c9a67c9b..9b6c0744 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/jarjar/JarJarArtifacts.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/jarjar/JarJarArtifacts.java @@ -1,5 +1,15 @@ package net.neoforged.moddevgradle.internal.jarjar; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import javax.inject.Inject; import net.neoforged.jarjar.metadata.ContainedJarIdentifier; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -25,23 +35,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - public abstract class JarJarArtifacts { private static final Logger LOG = LoggerFactory.getLogger(JarJarArtifacts.class); private transient final SetProperty includedRootComponents; private transient final SetProperty includedArtifacts; - @Internal protected SetProperty getIncludedRootComponents() { return includedRootComponents; @@ -71,8 +69,7 @@ public JarJarArtifacts() { public void configuration(Configuration jarJarConfiguration) { getIncludedArtifacts().addAll(jarJarConfiguration.getIncoming().artifactView(config -> { config.attributes( - attr -> attr.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.JAR_TYPE) - ); + attr -> attr.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.JAR_TYPE)); }).getArtifacts().getResolvedArtifacts()); getIncludedRootComponents().add(jarJarConfiguration.getIncoming().getResolutionResult().getRootComponent()); } @@ -213,16 +210,14 @@ private static String getModuleVersionRange(ModuleComponentSelector requestedMod moduleIdentifier = new ArtifactIdentifier( moduleComponentIdentifier.getGroup(), moduleComponentIdentifier.getModule(), - moduleComponentIdentifier.getVersion() - ); + moduleComponentIdentifier.getVersion()); } List capabilityIdentifiers = variant.getCapabilities().stream() .map(capability -> new ArtifactIdentifier( capability.getGroup(), capability.getName(), - capability.getVersion() - )) + capability.getVersion())) .toList(); if (moduleIdentifier != null && capabilityIdentifiers.contains(moduleIdentifier)) { @@ -234,7 +229,8 @@ private static String getModuleVersionRange(ModuleComponentSelector requestedMod } private static @Nullable String moduleOrCapabilityVersion(final ResolvedVariantResult variant) { - @Nullable ArtifactIdentifier identifier = capabilityOrModule(variant); + @Nullable + ArtifactIdentifier identifier = capabilityOrModule(variant); if (identifier != null) { return identifier.version(); } @@ -274,6 +270,5 @@ private static boolean isDynamicVersion(@Nullable ArtifactVersion version) { /** * Simple artifact identifier class which only references group, name and version. */ - private record ArtifactIdentifier(String group, String name, String version) { - } + private record ArtifactIdentifier(String group, String name, String version) {} } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/jarjar/JarJarPlugin.java b/src/main/java/net/neoforged/moddevgradle/internal/jarjar/JarJarPlugin.java index 4f02081f..d2a105dd 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/jarjar/JarJarPlugin.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/jarjar/JarJarPlugin.java @@ -5,9 +5,7 @@ import net.neoforged.moddevgradle.tasks.JarJar; import org.gradle.api.Plugin; import org.gradle.api.Project; -import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.bundling.AbstractArchiveTask; -import org.gradle.api.tasks.compile.JavaCompile; import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal diff --git a/src/main/java/net/neoforged/moddevgradle/internal/jarjar/ResolvedJarJarArtifact.java b/src/main/java/net/neoforged/moddevgradle/internal/jarjar/ResolvedJarJarArtifact.java index 3539a4ea..b7b7af3c 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/jarjar/ResolvedJarJarArtifact.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/jarjar/ResolvedJarJarArtifact.java @@ -1,5 +1,9 @@ package net.neoforged.moddevgradle.internal.jarjar; +import java.io.File; +import java.io.IOException; +import java.util.jar.JarFile; +import java.util.jar.Manifest; import net.neoforged.jarjar.metadata.ContainedJarIdentifier; import net.neoforged.jarjar.metadata.ContainedJarMetadata; import net.neoforged.jarjar.metadata.ContainedVersion; @@ -11,13 +15,7 @@ import org.gradle.api.tasks.PathSensitive; import org.gradle.api.tasks.PathSensitivity; -import java.io.File; -import java.io.IOException; -import java.util.jar.JarFile; -import java.util.jar.Manifest; - public class ResolvedJarJarArtifact { - private final File file; private final String embeddedFilename; private final String version; @@ -42,8 +40,7 @@ public ContainedVersion createContainedVersion() { try { return new ContainedVersion( VersionRange.createFromVersionSpec(versionRange), - new DefaultArtifactVersion(version) - ); + new DefaultArtifactVersion(version)); } catch (InvalidVersionSpecificationException e) { throw new RuntimeException(e); } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/DependencyUtils.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/DependencyUtils.java index 2fb284de..44231e95 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/utils/DependencyUtils.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/DependencyUtils.java @@ -6,8 +6,7 @@ @ApiStatus.Internal public final class DependencyUtils { - private DependencyUtils() { - } + private DependencyUtils() {} /** * Given a resolved artifact, try to guess which Maven GAV it was resolved from. diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/ExtensionUtils.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/ExtensionUtils.java index 679c5a2d..b1c4751c 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/utils/ExtensionUtils.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/ExtensionUtils.java @@ -9,8 +9,7 @@ @ApiStatus.Internal public final class ExtensionUtils { - private ExtensionUtils() { - } + private ExtensionUtils() {} public static T getExtension(ExtensionAware holder, String name, Class expectedType) { var extension = findExtension(holder.getExtensions(), name, expectedType); diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/FileUtils.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/FileUtils.java index 5340c967..9f32a71c 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/utils/FileUtils.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/FileUtils.java @@ -1,8 +1,5 @@ package net.neoforged.moddevgradle.internal.utils; -import org.gradle.api.GradleException; -import org.jetbrains.annotations.ApiStatus; - import java.io.File; import java.io.FileInputStream; import java.io.FilterOutputStream; @@ -22,6 +19,8 @@ import java.util.Optional; import java.util.jar.JarFile; import java.util.zip.ZipFile; +import org.gradle.api.GradleException; +import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal public final class FileUtils { @@ -30,8 +29,7 @@ public final class FileUtils { */ private static final int MAX_TRIES = 2; - private FileUtils() { - } + private FileUtils() {} /** * Finds an explicitly defined Java module name in the given Jar file. @@ -59,7 +57,6 @@ public static Optional getExplicitJavaModuleName(File file) throws IOExc } catch (Exception e) { throw new IOException("Failed to determine the Java module name of " + file + ": " + e, e); } - } public static String hashFile(File file, String algorithm) { @@ -77,7 +74,7 @@ public static String hashFile(File file, String algorithm) { public static void writeStringSafe(Path destination, String content, Charset charset) throws IOException { if (!charset.newEncoder().canEncode(content)) { throw new IllegalArgumentException("The given character set " + charset - + " cannot represent this string: " + content); + + " cannot represent this string: " + content); } try (var out = newSafeFileOutputStream(destination)) { @@ -106,8 +103,7 @@ public void close() throws IOException { } finally { try { Files.deleteIfExists(tempFile); - } catch (IOException ignored) { - } + } catch (IOException ignored) {} closed[0] = true; } } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/IdeDetection.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/IdeDetection.java index afe93244..2ef381d9 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/utils/IdeDetection.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/IdeDetection.java @@ -9,8 +9,7 @@ public final class IdeDetection { private static final Logger LOG = LoggerFactory.getLogger(IdeDetection.class); - private IdeDetection() { - } + private IdeDetection() {} /** * @return true if IntelliJ is running Gradle. This is true both during sync and execution of other Gradle tasks. @@ -84,5 +83,4 @@ public static boolean isVsCode() { vsCodePid, ourProcess.pid()); return false; } - } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/NetworkSettingPassthrough.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/NetworkSettingPassthrough.java index 6cc2e93b..4a394806 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/utils/NetworkSettingPassthrough.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/NetworkSettingPassthrough.java @@ -11,7 +11,6 @@ * change network settings, such as proxies and TLS trust settings. */ public class NetworkSettingPassthrough { - /** * The list of system properties to pass through to NFRT if set. * Refer to JRE Networking Properties. @@ -19,8 +18,7 @@ public class NetworkSettingPassthrough { private static final Set PROPERTIES = Set.of( "socksProxyHost", "socksProxyPort", - "socksProxyVersion" - ); + "socksProxyVersion"); private static final List PREFIXES = List.of( // HTTPS and HTTP proxy settings @@ -31,11 +29,9 @@ public class NetworkSettingPassthrough { // All TLS related properties, like telling it to use Windows trust store // See https://docs.oracle.com/en/java/javase/17/security/java-secure-socket-extension-jsse-reference-guide.html#GUID-A41282C3-19A3-400A-A40F-86F4DA22ABA9__SYSTEMPROPERTIESANDCUSTOMIZEITEMSIN-DCEEB591 "javax.net.ssl.", - "jdk.tls." - ); + "jdk.tls."); - private NetworkSettingPassthrough() { - } + private NetworkSettingPassthrough() {} public static Map getNetworkSystemProperties() { var properties = System.getProperties(); @@ -52,6 +48,5 @@ public static Map getNetworkSystemProperties() { return false; }) .collect(Collectors.toMap(Function.identity(), properties::getProperty)); - } } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/PropertyUtils.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/PropertyUtils.java index eb0e4145..0b72076e 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/utils/PropertyUtils.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/PropertyUtils.java @@ -5,8 +5,7 @@ import org.gradle.api.provider.Provider; public final class PropertyUtils { - private PropertyUtils() { - } + private PropertyUtils() {} public static Provider getStringProperty(Project project, String propertyName) { return project.getProviders().gradleProperty(propertyName); @@ -22,5 +21,4 @@ public static Provider getBooleanProperty(Project project, String prope } }); } - } diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/StringUtils.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/StringUtils.java index 0d5e2f1b..a8669173 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/utils/StringUtils.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/StringUtils.java @@ -1,14 +1,12 @@ package net.neoforged.moddevgradle.internal.utils; -import org.jetbrains.annotations.ApiStatus; - import java.nio.charset.Charset; import java.util.Locale; +import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal public final class StringUtils { - private StringUtils() { - } + private StringUtils() {} /** * Get the platform native charset. To see how this differs from the default charset, diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/VersionCapabilitiesInternal.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/VersionCapabilitiesInternal.java index 0bbf4bd5..c90d506a 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/utils/VersionCapabilitiesInternal.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/VersionCapabilitiesInternal.java @@ -1,13 +1,12 @@ package net.neoforged.moddevgradle.internal.utils; +import java.io.Serializable; +import java.util.regex.Pattern; import net.neoforged.moddevgradle.dsl.VersionCapabilities; import net.neoforged.moddevgradle.internal.generated.MinecraftVersionList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.Serializable; -import java.util.regex.Pattern; - /** * Models the changing capabilities of the modding platform and Vanilla, which we tie to the Minecraft version. * @@ -17,7 +16,8 @@ * @param testFixtures If the NeoForge version for this Minecraft version supports test fixtures. */ public record VersionCapabilitiesInternal(String minecraftVersion, int javaVersion, boolean splitDataRuns, - boolean testFixtures, boolean modLocatorRework) implements VersionCapabilities, Serializable { + boolean testFixtures, boolean modLocatorRework) implements VersionCapabilities, Serializable { + private static final Logger LOG = LoggerFactory.getLogger(VersionCapabilitiesInternal.class); private static final VersionCapabilitiesInternal LATEST = ofVersionIndex(0); @@ -32,7 +32,6 @@ public record VersionCapabilitiesInternal(String minecraftVersion, int javaVersi private static final int MC_1_20_4_INDEX = getReferenceVersionIndex("1.20.4"); private static final int MC_1_18_PRE2_INDEX = getReferenceVersionIndex("1.18-pre2"); private static final int MC_21W19A_INDEX = getReferenceVersionIndex("21w19a"); - public static VersionCapabilitiesInternal latest() { return LATEST; } @@ -169,7 +168,6 @@ public VersionCapabilitiesInternal withMinecraftVersion(String minecraftVersion) javaVersion, splitDataRuns, testFixtures, - modLocatorRework - ); + modLocatorRework); } } diff --git a/src/main/java/net/neoforged/moddevgradle/tasks/JarJar.java b/src/main/java/net/neoforged/moddevgradle/tasks/JarJar.java index f7a855ae..50e9cc01 100644 --- a/src/main/java/net/neoforged/moddevgradle/tasks/JarJar.java +++ b/src/main/java/net/neoforged/moddevgradle/tasks/JarJar.java @@ -1,5 +1,16 @@ package net.neoforged.moddevgradle.tasks; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import javax.inject.Inject; import net.neoforged.jarjar.metadata.Metadata; import net.neoforged.jarjar.metadata.MetadataIOHandler; import net.neoforged.moddevgradle.internal.jarjar.JarJarArtifacts; @@ -29,18 +40,6 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion; import org.jetbrains.annotations.ApiStatus; -import javax.inject.Inject; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - public abstract class JarJar extends DefaultTask { private static final String DEFAULT_GROUP = "jarjar"; @@ -122,8 +121,8 @@ protected void run() throws IOException { var moduleName = FileUtils.getExplicitJavaModuleName(file); if (moduleName.isEmpty()) { throw new GradleException("Cannot embed local file dependency " + file + " because it has no explicit Java module name.\n" + - "Please set either 'Automatic-Module-Name' in the Jar manifest, or make it an explicit Java module.\n" + - "This ensures that your file does not conflict with another mods library that has the same or a similar filename."); + "Please set either 'Automatic-Module-Name' in the Jar manifest, or make it an explicit Java module.\n" + + "This ensures that your file does not conflict with another mods library that has the same or a similar filename."); } // Create a hashcode to use as a version @@ -134,8 +133,7 @@ protected void run() throws IOException { hashCode, "[" + hashCode + "]", "", - moduleName.get() - )); + moduleName.get())); artifactFiles.add(file); } } @@ -210,7 +208,6 @@ private Metadata createMetadata(List jars) { return new Metadata( jars.stream() .map(ResolvedJarJarArtifact::createContainerMetadata) - .collect(Collectors.toList()) - ); + .collect(Collectors.toList())); } } diff --git a/src/main/java/net/neoforged/nfrtgradle/ArtifactManifestEntry.java b/src/main/java/net/neoforged/nfrtgradle/ArtifactManifestEntry.java index d3c4e538..cf3f635e 100644 --- a/src/main/java/net/neoforged/nfrtgradle/ArtifactManifestEntry.java +++ b/src/main/java/net/neoforged/nfrtgradle/ArtifactManifestEntry.java @@ -1,14 +1,13 @@ package net.neoforged.nfrtgradle; +import java.io.File; +import java.io.Serializable; +import java.util.Objects; import net.neoforged.moddevgradle.internal.utils.DependencyUtils; import org.gradle.api.artifacts.result.ResolvedArtifactResult; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.InputFile; -import java.io.File; -import java.io.Serializable; -import java.util.Objects; - /** * Represents an entry in the Artifact manifest given to NFRT to prevent re-downloading of * dependencies that Gradle has already downloaded to its cache. @@ -41,7 +40,7 @@ public boolean equals(Object obj) { if (obj == null || obj.getClass() != this.getClass()) return false; var that = (ArtifactManifestEntry) obj; return Objects.equals(this.artifactId, that.artifactId) && - Objects.equals(this.file, that.file); + Objects.equals(this.file, that.file); } @Override @@ -52,7 +51,7 @@ public int hashCode() { @Override public String toString() { return "ArtifactManifestEntry[" + - "artifactId=" + artifactId + ", " + - "file=" + file + ']'; + "artifactId=" + artifactId + ", " + + "file=" + file + ']'; } } diff --git a/src/main/java/net/neoforged/nfrtgradle/CreateMinecraftArtifacts.java b/src/main/java/net/neoforged/nfrtgradle/CreateMinecraftArtifacts.java index ed465533..7bb9a2ec 100644 --- a/src/main/java/net/neoforged/nfrtgradle/CreateMinecraftArtifacts.java +++ b/src/main/java/net/neoforged/nfrtgradle/CreateMinecraftArtifacts.java @@ -1,5 +1,10 @@ package net.neoforged.nfrtgradle; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.inject.Inject; import org.gradle.api.GradleException; import org.gradle.api.file.ConfigurableFileCollection; import org.gradle.api.file.RegularFileProperty; @@ -15,12 +20,6 @@ import org.gradle.work.DisableCachingByDefault; import org.jetbrains.annotations.ApiStatus; -import javax.inject.Inject; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - /** * The primary task for creating the Minecraft artifacts that mods will be compiled against, * using the NFRT CLI. diff --git a/src/main/java/net/neoforged/nfrtgradle/DownloadAssets.java b/src/main/java/net/neoforged/nfrtgradle/DownloadAssets.java index 3242768a..49cbf3a3 100644 --- a/src/main/java/net/neoforged/nfrtgradle/DownloadAssets.java +++ b/src/main/java/net/neoforged/nfrtgradle/DownloadAssets.java @@ -1,5 +1,8 @@ package net.neoforged.nfrtgradle; +import java.util.ArrayList; +import java.util.Collections; +import javax.inject.Inject; import org.gradle.api.GradleException; import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Property; @@ -10,10 +13,6 @@ import org.gradle.work.DisableCachingByDefault; import org.jetbrains.annotations.ApiStatus; -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Collections; - /** * Use the NFRT CLI to download the asset index and assets for the Minecraft version used by the * underlying NeoForge/NeoForm configuration. @@ -22,17 +21,16 @@ @ApiStatus.NonExtendable public abstract class DownloadAssets extends NeoFormRuntimeTask { @Inject - public DownloadAssets() { - } + public DownloadAssets() {} /** * Gradle dependency notation for the NeoForm data artifact, from which a Minecraft version will be derived. *

* To determine the Minecraft version, the following properties will be checked in-order and the first one will be used: *

    - *
  1. {@link #getMinecraftVersion()}
  2. - *
  3. {@link #getNeoFormArtifact()}
  4. - *
  5. this property
  6. + *
  7. {@link #getMinecraftVersion()}
  8. + *
  9. {@link #getNeoFormArtifact()}
  10. + *
  11. this property
  12. *
*/ @Input @@ -44,9 +42,9 @@ public DownloadAssets() { *

* To determine the Minecraft version, the following properties will be checked in-order and the first one will be used: *

    - *
  1. {@link #getMinecraftVersion()}
  2. - *
  3. this property
  4. - *
  5. {@link #getNeoForgeArtifact()}
  6. + *
  7. {@link #getMinecraftVersion()}
  8. + *
  9. this property
  10. + *
  11. {@link #getNeoForgeArtifact()}
  12. *
*/ @Input @@ -58,9 +56,9 @@ public DownloadAssets() { *

* To determine the Minecraft version, the following properties will be checked in-order and the first one will be used: *

    - *
  1. this property
  2. - *
  3. {@link #getNeoFormArtifact()}
  4. - *
  5. {@link #getNeoForgeArtifact()}
  6. + *
  7. this property
  8. + *
  9. {@link #getNeoFormArtifact()}
  10. + *
  11. {@link #getNeoForgeArtifact()}
  12. *
*/ @Input @@ -89,7 +87,6 @@ public DownloadAssets() { @TaskAction public void downloadAssets() { - var args = new ArrayList(); Collections.addAll(args, "download-assets"); if (getAssetPropertiesFile().isPresent()) { diff --git a/src/main/java/net/neoforged/nfrtgradle/NeoFormRuntimeExtension.java b/src/main/java/net/neoforged/nfrtgradle/NeoFormRuntimeExtension.java index 17f58246..3b277fb9 100644 --- a/src/main/java/net/neoforged/nfrtgradle/NeoFormRuntimeExtension.java +++ b/src/main/java/net/neoforged/nfrtgradle/NeoFormRuntimeExtension.java @@ -1,11 +1,10 @@ package net.neoforged.nfrtgradle; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.utils.PropertyUtils; import org.gradle.api.Project; import org.gradle.api.provider.Property; -import javax.inject.Inject; - /** * Configures aspects of the NeoForm Runtime (NFRT), which is used by this plugin to produce * the Minecraft artifacts for compiling and mods. diff --git a/src/main/java/net/neoforged/nfrtgradle/NeoFormRuntimeTask.java b/src/main/java/net/neoforged/nfrtgradle/NeoFormRuntimeTask.java index 6dbff66b..15c83004 100644 --- a/src/main/java/net/neoforged/nfrtgradle/NeoFormRuntimeTask.java +++ b/src/main/java/net/neoforged/nfrtgradle/NeoFormRuntimeTask.java @@ -1,5 +1,14 @@ package net.neoforged.nfrtgradle; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.stream.Collectors; +import javax.inject.Inject; import net.neoforged.moddevgradle.internal.utils.IdeDetection; import net.neoforged.moddevgradle.internal.utils.NetworkSettingPassthrough; import org.gradle.api.DefaultTask; @@ -18,16 +27,6 @@ import org.gradle.process.ExecOperations; import org.jetbrains.annotations.ApiStatus; -import javax.inject.Inject; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.stream.Collectors; - /** * Base task implementation for running the NFRT CLI, regardless of which sub-command is used. */ @@ -106,8 +105,7 @@ public NeoFormRuntimeTask() { // Run NFRT itself with Java 21 getJavaExecutable().convention(getJavaToolchainService() .launcherFor(spec -> spec.getLanguageVersion().set(JavaLanguageVersion.of(21))) - .map(javaLauncher -> javaLauncher.getExecutablePath().getAsFile().getAbsolutePath()) - ); + .map(javaLauncher -> javaLauncher.getExecutablePath().getAsFile().getAbsolutePath())); // We construct this here to keep them private from subclasses artifactManifestEntries = project.getObjects().setProperty(ArtifactManifestEntry.class); @@ -185,5 +183,4 @@ private File writeArtifactManifest() { } return artifactManifest; } - } diff --git a/src/test/java/net/neoforged/moddevgradle/AbstractProjectBuilderTest.java b/src/test/java/net/neoforged/moddevgradle/AbstractProjectBuilderTest.java index 327585f7..c9271f5a 100644 --- a/src/test/java/net/neoforged/moddevgradle/AbstractProjectBuilderTest.java +++ b/src/test/java/net/neoforged/moddevgradle/AbstractProjectBuilderTest.java @@ -1,5 +1,10 @@ package net.neoforged.moddevgradle; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; import org.assertj.core.api.AbstractListAssert; import org.assertj.core.api.ObjectAssert; import org.gradle.api.Project; @@ -7,12 +12,6 @@ import org.gradle.api.artifacts.ExternalModuleDependency; import org.gradle.api.artifacts.FileCollectionDependency; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import static org.assertj.core.api.Assertions.assertThat; - public abstract class AbstractProjectBuilderTest { protected Project project; diff --git a/src/test/java/net/neoforged/moddevgradle/dsl/ParchmentTest.java b/src/test/java/net/neoforged/moddevgradle/dsl/ParchmentTest.java index 67dec777..0ca0994f 100644 --- a/src/test/java/net/neoforged/moddevgradle/dsl/ParchmentTest.java +++ b/src/test/java/net/neoforged/moddevgradle/dsl/ParchmentTest.java @@ -1,14 +1,14 @@ package net.neoforged.moddevgradle.dsl; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + import org.gradle.api.Project; import org.gradle.testfixtures.ProjectBuilder; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - class ParchmentTest { Project project; Parchment parchment; diff --git a/src/test/java/net/neoforged/moddevgradle/functional/AbstractFunctionalTest.java b/src/test/java/net/neoforged/moddevgradle/functional/AbstractFunctionalTest.java index 792459d8..c1a4c86e 100644 --- a/src/test/java/net/neoforged/moddevgradle/functional/AbstractFunctionalTest.java +++ b/src/test/java/net/neoforged/moddevgradle/functional/AbstractFunctionalTest.java @@ -1,9 +1,5 @@ package net.neoforged.moddevgradle.functional; -import org.intellij.lang.annotations.Language; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.io.TempDir; - import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -11,13 +7,15 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.intellij.lang.annotations.Language; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; public abstract class AbstractFunctionalTest { static final String DEFAULT_NEOFORGE_VERSION = "21.0.133-beta"; static final Map DEFAULT_PLACEHOLDERS = Map.of( - "DEFAULT_NEOFORGE_VERSION", DEFAULT_NEOFORGE_VERSION - ); + "DEFAULT_NEOFORGE_VERSION", DEFAULT_NEOFORGE_VERSION); @TempDir protected File testProjectDir; diff --git a/src/test/java/net/neoforged/moddevgradle/functional/DataFileCollectionFunctionalTest.java b/src/test/java/net/neoforged/moddevgradle/functional/DataFileCollectionFunctionalTest.java index 95e6bf72..7d69cebd 100644 --- a/src/test/java/net/neoforged/moddevgradle/functional/DataFileCollectionFunctionalTest.java +++ b/src/test/java/net/neoforged/moddevgradle/functional/DataFileCollectionFunctionalTest.java @@ -1,25 +1,23 @@ package net.neoforged.moddevgradle.functional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.entry; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.google.gson.Gson; import com.google.gson.JsonObject; -import org.gradle.testkit.runner.GradleRunner; -import org.gradle.testkit.runner.TaskOutcome; -import org.intellij.lang.annotations.Language; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.util.HashMap; import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.gradle.testkit.runner.GradleRunner; +import org.gradle.testkit.runner.TaskOutcome; +import org.intellij.lang.annotations.Language; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class DataFileCollectionFunctionalTest extends AbstractFunctionalTest { - @TempDir File publicationTarget; @@ -33,12 +31,10 @@ public void testPublishAccessTransformerFile() throws IOException { publish(project.file("accesstransformer.cfg")) } } - """ - ); + """); assertThat(consumeDataFilePublication("accessTransformers", "test:publish-at:1.0")).containsOnly( - entry("publish-at-1.0-accesstransformer.cfg", "# hello world") - ); + entry("publish-at-1.0-accesstransformer.cfg", "# hello world")); } @Test @@ -61,14 +57,12 @@ public void testPublishInterfaceInjectionFile() throws IOException { publish(generatedDataFile) } } - """ - ); + """); assertThat(consumeDataFilePublication("interfaceInjectionData", "test:publish-if:1.0")).containsOnly( entry("publish-if-1.0-interfaceinjection1.json", "[]"), entry("publish-if-1.0-interfaceinjection2.json", "[]"), - entry("publish-if-1.0-interfaceinjection3.json", "{}") - ); + entry("publish-if-1.0-interfaceinjection3.json", "{}")); } @Test @@ -130,9 +124,9 @@ private Map consumeDataFilePublication(String configurationName, } private void publishDataFiles(String groupId, - String artifactId, - String version, - @Language("groovy") String buildScriptBody) throws IOException { + String artifactId, + String version, + @Language("groovy") String buildScriptBody) throws IOException { writeGroovySettingsScript(""" plugins { id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' @@ -173,5 +167,4 @@ url file("{3}") assertEquals(TaskOutcome.SUCCESS, result.task(":publish").getOutcome()); } - } diff --git a/src/test/java/net/neoforged/moddevgradle/functional/GroovyScriptTest.java b/src/test/java/net/neoforged/moddevgradle/functional/GroovyScriptTest.java index 150d803d..7ab4201f 100644 --- a/src/test/java/net/neoforged/moddevgradle/functional/GroovyScriptTest.java +++ b/src/test/java/net/neoforged/moddevgradle/functional/GroovyScriptTest.java @@ -1,17 +1,15 @@ package net.neoforged.moddevgradle.functional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.GradleRunner; import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.Test; -import java.io.IOException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class GroovyScriptTest extends AbstractFunctionalTest { - @Test public void testApplyInEmptyProject() throws IOException { writeFile(settingsFile, "rootProject.name = 'hello-world'"); @@ -53,5 +51,4 @@ public void testApplyInEmptyProjectAndEnable() throws IOException { assertThat(result.getOutput()).contains("createMinecraftArtifacts"); assertEquals(TaskOutcome.SUCCESS, result.task(":tasks").getOutcome()); } - } diff --git a/src/test/java/net/neoforged/moddevgradle/functional/KotlinScriptTest.java b/src/test/java/net/neoforged/moddevgradle/functional/KotlinScriptTest.java index 0e311686..018e632b 100644 --- a/src/test/java/net/neoforged/moddevgradle/functional/KotlinScriptTest.java +++ b/src/test/java/net/neoforged/moddevgradle/functional/KotlinScriptTest.java @@ -1,15 +1,14 @@ package net.neoforged.moddevgradle.functional; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.GradleRunner; import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.Test; -import java.io.IOException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class KotlinScriptTest extends AbstractFunctionalTest { @Test public void testApplyInEmptyProject() throws IOException { diff --git a/src/test/java/net/neoforged/moddevgradle/functional/ValidationTests.java b/src/test/java/net/neoforged/moddevgradle/functional/ValidationTests.java index ac493d71..5a113168 100644 --- a/src/test/java/net/neoforged/moddevgradle/functional/ValidationTests.java +++ b/src/test/java/net/neoforged/moddevgradle/functional/ValidationTests.java @@ -1,15 +1,14 @@ package net.neoforged.moddevgradle.functional; +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.nio.file.Files; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.GradleRunner; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.io.IOException; -import java.nio.file.Files; - -import static org.assertj.core.api.Assertions.assertThat; - public class ValidationTests extends AbstractFunctionalTest { @BeforeEach public void setup() throws IOException { @@ -22,7 +21,7 @@ void testRunNameValidation() throws IOException { plugins { id "net.neoforged.moddev" } - + neoForge { runs { validName1 {} diff --git a/src/test/java/net/neoforged/moddevgradle/internal/AccessTransformerConventionTest.java b/src/test/java/net/neoforged/moddevgradle/internal/AccessTransformerConventionTest.java index 41117846..6b1625f0 100644 --- a/src/test/java/net/neoforged/moddevgradle/internal/AccessTransformerConventionTest.java +++ b/src/test/java/net/neoforged/moddevgradle/internal/AccessTransformerConventionTest.java @@ -1,5 +1,10 @@ package net.neoforged.moddevgradle.internal; +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import net.neoforged.moddevgradle.dsl.NeoForgeExtension; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import net.neoforged.nfrtgradle.CreateMinecraftArtifacts; @@ -8,12 +13,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -import static org.assertj.core.api.Assertions.assertThat; - public class AccessTransformerConventionTest { Project project; NeoForgeExtension extension; diff --git a/src/test/java/net/neoforged/moddevgradle/internal/ModDevPluginTest.java b/src/test/java/net/neoforged/moddevgradle/internal/ModDevPluginTest.java index 623ce23d..b42067b1 100644 --- a/src/test/java/net/neoforged/moddevgradle/internal/ModDevPluginTest.java +++ b/src/test/java/net/neoforged/moddevgradle/internal/ModDevPluginTest.java @@ -1,5 +1,10 @@ package net.neoforged.moddevgradle.internal; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.Set; import net.neoforged.moddevgradle.AbstractProjectBuilderTest; import net.neoforged.moddevgradle.dsl.NeoForgeExtension; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; @@ -13,12 +18,6 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - public class ModDevPluginTest extends AbstractProjectBuilderTest { private final NeoForgeExtension extension; private final SourceSet mainSourceSet; @@ -109,14 +108,12 @@ void testEnable() { assertThatDependencies(mainSourceSet.getCompileClasspathConfigurationName()) .containsOnly( "build/moddev/artifacts/vanilla-" + VERSION + ".jar", - "net.neoforged:neoform:" + VERSION + "[net.neoforged:neoform-dependencies]" - ); + "net.neoforged:neoform:" + VERSION + "[net.neoforged:neoform-dependencies]"); assertThatDependencies(mainSourceSet.getRuntimeClasspathConfigurationName()) .containsOnly( "build/moddev/artifacts/vanilla-" + VERSION + ".jar", "build/moddev/artifacts/vanilla-" + VERSION + "-client-extra-aka-minecraft-resources.jar", - "net.neoforged:neoform:" + VERSION + "[net.neoforged:neoform-dependencies]" - ); + "net.neoforged:neoform:" + VERSION + "[net.neoforged:neoform-dependencies]"); } @Test @@ -143,8 +140,7 @@ void testGetVersionCapabilitiesForUnknownVersion() { // Should use latest features, but with the specified Minecraft version assertEquals( VersionCapabilitiesInternal.latest().withMinecraftVersion("1.99.1"), - extension.getVersionCapabilities() - ); + extension.getVersionCapabilities()); } } @@ -175,8 +171,7 @@ private void assertContainsModdingCompileDependencies(String version, String con assertThatDependencies(configurationName) .containsOnly( "build/moddev/artifacts/neoforge-" + version + ".jar", - "net.neoforged:neoforge:" + version + "[net.neoforged:neoforge-dependencies]" - ); + "net.neoforged:neoforge:" + version + "[net.neoforged:neoforge-dependencies]"); } private void assertContainsModdingRuntimeDependencies(String version, String configurationName) { @@ -191,7 +186,6 @@ private void assertContainsModdingRuntimeDependencies(String version, String con .containsOnly( "build/moddev/artifacts/neoforge-" + version + ".jar", "build/moddev/artifacts/neoforge-" + version + "-client-extra-aka-minecraft-resources.jar", - "net.neoforged:neoforge:" + version + "[net.neoforged:neoforge-dependencies]" - ); + "net.neoforged:neoforge:" + version + "[net.neoforged:neoforge-dependencies]"); } } diff --git a/src/test/java/net/neoforged/moddevgradle/internal/RunUtilsTest.java b/src/test/java/net/neoforged/moddevgradle/internal/RunUtilsTest.java index eccb2673..f71a5608 100644 --- a/src/test/java/net/neoforged/moddevgradle/internal/RunUtilsTest.java +++ b/src/test/java/net/neoforged/moddevgradle/internal/RunUtilsTest.java @@ -1,12 +1,11 @@ package net.neoforged.moddevgradle.internal; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import static org.junit.jupiter.api.Assertions.assertEquals; - class RunUtilsTest { - @ParameterizedTest @CsvSource(textBlock = """ ""|\\"\\" @@ -21,5 +20,4 @@ public void testEscape(String unescaped, String escaped) { assertEquals(escaped, RunUtils.escapeJvmArg(unescaped)); } - -} \ No newline at end of file +} diff --git a/src/test/java/net/neoforged/moddevgradle/internal/utils/VersionCapabilitiesInternalTest.java b/src/test/java/net/neoforged/moddevgradle/internal/utils/VersionCapabilitiesInternalTest.java index 27f694b4..1a397c33 100644 --- a/src/test/java/net/neoforged/moddevgradle/internal/utils/VersionCapabilitiesInternalTest.java +++ b/src/test/java/net/neoforged/moddevgradle/internal/utils/VersionCapabilitiesInternalTest.java @@ -1,12 +1,12 @@ package net.neoforged.moddevgradle.internal.utils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + import net.neoforged.moddevgradle.internal.generated.MinecraftVersionList; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class VersionCapabilitiesInternalTest { @ParameterizedTest() @CsvSource({ diff --git a/src/test/java/net/neoforged/moddevgradle/legacyforge/LegacyModDevPluginTest.java b/src/test/java/net/neoforged/moddevgradle/legacyforge/LegacyModDevPluginTest.java index 17e13eb8..fb439ed0 100644 --- a/src/test/java/net/neoforged/moddevgradle/legacyforge/LegacyModDevPluginTest.java +++ b/src/test/java/net/neoforged/moddevgradle/legacyforge/LegacyModDevPluginTest.java @@ -1,5 +1,9 @@ package net.neoforged.moddevgradle.legacyforge; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.Set; import net.neoforged.moddevgradle.AbstractProjectBuilderTest; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import net.neoforged.moddevgradle.legacyforge.dsl.LegacyForgeExtension; @@ -12,11 +16,6 @@ import org.gradle.testfixtures.ProjectBuilder; import org.junit.jupiter.api.Test; -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; - public class LegacyModDevPluginTest extends AbstractProjectBuilderTest { private final LegacyForgeExtension extension; private final SourceSet mainSourceSet; @@ -51,15 +50,13 @@ void testEnableVanillaOnlyMode() { assertThatDependencies(mainSourceSet.getCompileClasspathConfigurationName()) .containsOnly( "build/moddev/artifacts/vanilla-1.17.1.jar", - "de.oceanlabs.mcp:mcp_config:1.17.1[net.neoforged:neoform-dependencies]" - ); + "de.oceanlabs.mcp:mcp_config:1.17.1[net.neoforged:neoform-dependencies]"); assertThatDependencies(mainSourceSet.getRuntimeClasspathConfigurationName()) .containsOnly( "build/moddev/artifacts/vanilla-1.17.1.jar", "build/moddev/artifacts/vanilla-1.17.1-client-extra-aka-minecraft-resources.jar", "de.oceanlabs.mcp:mcp_config:1.17.1[net.neoforged:neoform-dependencies]", - "build/moddev/artifacts/intermediateToNamed.zip" - ); + "build/moddev/artifacts/intermediateToNamed.zip"); } @Test @@ -99,8 +96,7 @@ private void assertContainsModdingCompileDependencies(String version, String con assertThatDependencies(configurationName) .containsOnly( "build/moddev/artifacts/forge-" + version + ".jar", - "net.minecraftforge:forge:" + version + "[net.neoforged:neoforge-dependencies]" - ); + "net.minecraftforge:forge:" + version + "[net.neoforged:neoforge-dependencies]"); } private void assertContainsModdingRuntimeDependencies(String version, String configurationName) { @@ -116,7 +112,6 @@ private void assertContainsModdingRuntimeDependencies(String version, String con "build/moddev/artifacts/forge-" + version + ".jar", "build/moddev/artifacts/client-extra-1.2.3.jar", "build/moddev/artifacts/intermediateToNamed.zip", - "net.minecraftforge:forge:" + version + "[net.neoforged:neoforge-dependencies]" - ); + "net.minecraftforge:forge:" + version + "[net.neoforged:neoforge-dependencies]"); } } diff --git a/src/test/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinMappingTest.java b/src/test/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinMappingTest.java index f7716036..39e31c88 100644 --- a/src/test/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinMappingTest.java +++ b/src/test/java/net/neoforged/moddevgradle/legacyforge/dsl/MixinMappingTest.java @@ -1,5 +1,7 @@ package net.neoforged.moddevgradle.legacyforge.dsl; +import static org.assertj.core.api.Assertions.assertThat; + import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; import net.neoforged.moddevgradle.legacyforge.internal.LegacyForgeModDevPlugin; import net.neoforged.moddevgradle.legacyforge.tasks.RemapJar; @@ -7,8 +9,6 @@ import org.gradle.testfixtures.ProjectBuilder; import org.junit.jupiter.api.Test; -import static org.assertj.core.api.Assertions.assertThat; - class MixinMappingTest { /** * Tests that we expect the Mixin AP to create for each refmap is added to the reobfuscation tasks diff --git a/src/test/java/net/neoforged/moddevgradle/tasks/JarJarTest.java b/src/test/java/net/neoforged/moddevgradle/tasks/JarJarTest.java index 7b4e4355..9f4ccae6 100644 --- a/src/test/java/net/neoforged/moddevgradle/tasks/JarJarTest.java +++ b/src/test/java/net/neoforged/moddevgradle/tasks/JarJarTest.java @@ -1,5 +1,17 @@ package net.neoforged.moddevgradle.tasks; +import static org.assertj.core.api.Assertions.assertThat; +import static org.gradle.testkit.runner.TaskOutcome.NO_SOURCE; +import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; +import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; import net.neoforged.jarjar.metadata.ContainedJarIdentifier; import net.neoforged.jarjar.metadata.ContainedJarMetadata; import net.neoforged.jarjar.metadata.ContainedVersion; @@ -14,19 +26,6 @@ import org.gradle.testkit.runner.UnexpectedBuildFailure; import org.junit.jupiter.api.Test; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.List; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.gradle.testkit.runner.TaskOutcome.NO_SOURCE; -import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - class JarJarTest extends AbstractFunctionalTest { @Test public void testNoSourceWhenNoDependenciesAreDefined() throws IOException { @@ -83,8 +82,8 @@ void testCannotEmbedLocalFileWithoutExplicitJavaModuleName() throws IOException } """)); assertThat(e).hasMessageFindingMatch("Cannot embed local file dependency .*file.jar because it has no explicit Java module name.\\s*" + - "Please set either 'Automatic-Module-Name' in the Jar manifest, or make it an explicit Java module.\\s*" + - "This ensures that your file does not conflict with another mods library that has the same or a similar filename."); + "Please set either 'Automatic-Module-Name' in the Jar manifest, or make it an explicit Java module.\\s*" + + "This ensures that your file does not conflict with another mods library that has the same or a similar filename."); } @Test @@ -108,10 +107,8 @@ void testCanEmbedLocalFileWithAutomaticModuleName() throws Exception { new ContainedJarIdentifier("", "super_duper_module"), new ContainedVersion(VersionRange.createFromVersionSpec("[" + md5Hash + "]"), new DefaultArtifactVersion(md5Hash)), "META-INF/jarjar/file.jar", - false - ) - ) - ), readMetadata()); + false))), + readMetadata()); } /** @@ -124,7 +121,7 @@ void testEmbeddingSubprojectUsesDefaultCapabilityCoordinate() throws Exception { id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } rootProject.name = 'root_project_name' - + include ':plugin' """); writeProjectFile("build.gradle", """ @@ -150,10 +147,8 @@ void testEmbeddingSubprojectUsesDefaultCapabilityCoordinate() throws Exception { new ContainedJarIdentifier("root_project_name", "plugin"), new ContainedVersion(VersionRange.createFromVersionSpec("[9.0.0,)"), new DefaultArtifactVersion("9.0.0")), "META-INF/jarjar/root_project_name.plugin-9.0.0.jar", - false - ) - ) - ), readMetadata()); + false))), + readMetadata()); } /** @@ -166,7 +161,7 @@ void testEmbeddingSubprojectWithExplicitGroupIdSet() throws Exception { id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } rootProject.name = 'root_project_name' - + include ':plugin' """); writeProjectFile("build.gradle", """ @@ -193,10 +188,8 @@ void testEmbeddingSubprojectWithExplicitGroupIdSet() throws Exception { new ContainedJarIdentifier("net.somegroup", "plugin"), new ContainedVersion(VersionRange.createFromVersionSpec("[9.0.0,)"), new DefaultArtifactVersion("9.0.0")), "META-INF/jarjar/net.somegroup.plugin-9.0.0.jar", - false - ) - ) - ), readMetadata()); + false))), + readMetadata()); } @Test @@ -229,10 +222,8 @@ void testCanEmbedLocalFileWithModuleInfo() throws Exception { new ContainedJarIdentifier("", "super_duper_module"), new ContainedVersion(VersionRange.createFromVersionSpec("[" + md5Hash + "]"), new DefaultArtifactVersion(md5Hash)), "META-INF/jarjar/jijtest-plugin.jar", - false - ) - ) - ), readMetadata()); + false))), + readMetadata()); } @Test @@ -250,18 +241,15 @@ public void testSuccessfulEmbed() throws Exception { assertEquals(SUCCESS, result.task(":jarJar").getOutcome()); assertThat(listFiles()).containsOnly( - "META-INF/jarjar/metadata.json", "META-INF/jarjar/slf4j-api-2.0.13.jar" - ); + "META-INF/jarjar/metadata.json", "META-INF/jarjar/slf4j-api-2.0.13.jar"); assertEquals(new Metadata( List.of( new ContainedJarMetadata( new ContainedJarIdentifier("org.slf4j", "slf4j-api"), new ContainedVersion(VersionRange.createFromVersionSpec("[0.1,3.0)"), new DefaultArtifactVersion("2.0.13")), "META-INF/jarjar/slf4j-api-2.0.13.jar", - false - ) - ) - ), readMetadata()); + false))), + readMetadata()); } @Test @@ -274,18 +262,15 @@ public void testSimpleStringVersion() throws Exception { assertEquals(SUCCESS, result.task(":jarJar").getOutcome()); assertThat(listFiles()).containsOnly( - "META-INF/jarjar/metadata.json", "META-INF/jarjar/slf4j-api-2.0.13.jar" - ); + "META-INF/jarjar/metadata.json", "META-INF/jarjar/slf4j-api-2.0.13.jar"); assertEquals(new Metadata( List.of( new ContainedJarMetadata( new ContainedJarIdentifier("org.slf4j", "slf4j-api"), new ContainedVersion(VersionRange.createFromVersionSpec("[2.0.13,)"), new DefaultArtifactVersion("2.0.13")), "META-INF/jarjar/slf4j-api-2.0.13.jar", - false - ) - ) - ), readMetadata()); + false))), + readMetadata()); } /** @@ -306,18 +291,15 @@ public void testSimpleStringVersionPullsRangeFromResolution() throws Exception { assertEquals(SUCCESS, result.task(":jarJar").getOutcome()); assertThat(listFiles()).containsOnly( - "META-INF/jarjar/metadata.json", "META-INF/jarjar/slf4j-api-2.0.13.jar" - ); + "META-INF/jarjar/metadata.json", "META-INF/jarjar/slf4j-api-2.0.13.jar"); assertEquals(new Metadata( List.of( new ContainedJarMetadata( new ContainedJarIdentifier("org.slf4j", "slf4j-api"), new ContainedVersion(VersionRange.createFromVersionSpec("[2.0.13,)"), new DefaultArtifactVersion("2.0.13")), "META-INF/jarjar/slf4j-api-2.0.13.jar", - false - ) - ) - ), readMetadata()); + false))), + readMetadata()); } @Test @@ -384,13 +366,13 @@ private BuildResult runWithSource(String source) throws IOException { rootProject.name = 'jijtest' """); writeProjectFile("build.gradle", """ - plugins { - id "net.neoforged.moddev" - } - repositories { - mavenCentral() - } - """ + source); + plugins { + id "net.neoforged.moddev" + } + repositories { + mavenCentral() + } + """ + source); return run(); } @@ -421,5 +403,4 @@ private Metadata readMetadata() throws IOException { return MetadataIOHandler.fromStream(in).orElseThrow(); } } - }