88import org .gradle .api .Transformer ;
99import org .gradle .api .artifacts .Dependency ;
1010import org .gradle .api .artifacts .ExternalModuleDependency ;
11- import org .gradle .api .artifacts .FileCollectionDependency ;
1211import org .gradle .api .file .Directory ;
1312import org .gradle .api .problems .Problem ;
1413import org .gradle .api .problems .ProblemGroup ;
@@ -175,7 +174,7 @@ RuntimeException invalidMinecraftDependencyType(Dependency dependency) {
175174 This means that it cannot be substituted with file or project dependencies.
176175 Expected: (implementation of) %s, Actual: '%s
177176 Dependency: '%s'"""
178- .formatted (ExternalModuleDependency .class .getName (), dependency .getClass ().getName (), depToString (dependency )))
177+ .formatted (ExternalModuleDependency .class .getName (), dependency .getClass ().getName (), Util . toString (dependency )))
179178 .severity (Severity .ERROR )
180179 .stackLocation ()
181180 .solution ("Declare a module dependency instead." )
@@ -199,49 +198,24 @@ void reportMissingMetadata(Throwable throwable) {
199198 );
200199 }
201200
202- RuntimeException multipleMinecraftDependencies (Dependency current , Dependency replacement ) {
203- return this .getReporter ().throwing (new IllegalArgumentException ("Cannot have more than one Minecraft dependency" ), id ("multiple-minecraft-dependencies" , "Multiple Minecraft dependencies declared" ), spec -> spec
204- .details ("""
205- Attempted to use multiple Minecraft dependencies. Only one can be declared
206- Current: %s, Replacement: '%s'"""
207- .formatted (depToString (current ), depToString (replacement )))
208- .severity (Severity .ERROR )
209- .stackLocation ()
210- .solution ("Declare only one Minecraft dependency using `minecraft.dep(...)`." )
211- .solution (HELP_MESSAGE )
212- );
213- }
214-
215201 RuntimeException changingMinecraftDependency (Dependency dependency ) {
216202 return this .getReporter ().throwing (new IllegalArgumentException ("Minecraft dependency cannot be changing" ), id ("changing-minecraft-dependency" , "Minecraft dependency marked as changing" ), spec -> spec
217203 .details ("""
218204 Attempted to use a Minecraft dependency that was marked as changing.
219205 This is currently unsupported.
220206 Dependency: %s"""
221- .formatted (depToString (dependency )))
207+ .formatted (Util . toString (dependency )))
222208 .severity (Severity .ERROR )
223209 .solution ("Do not mark the Minecraft dependency as changing." )
224210 .solution (HELP_MESSAGE )
225211 );
226212 }
227-
228- private static String depToString (Dependency dependency ) {
229- var group = dependency .getGroup ();
230- var version = dependency .getVersion ();
231- var reason = dependency .getReason ();
232- return "(%s) %s%s%s%s%s" .formatted (
233- dependency .getClass ().getName (),
234- group != null ? group + ':' : "" ,
235- dependency .getName (),
236- version != null ? ':' + version : "" ,
237- reason != null ? " (" + reason + ')' : "" ,
238- dependency instanceof FileCollectionDependency files ? " [%s]" .formatted (String .join (", " , files .getFiles ().getFiles ().stream ().map (File ::getAbsolutePath ).map (CharSequence .class ::cast )::iterator )) : ""
239- );
240- }
241213 //endregion
242214
243215 //region Minecraft Maven
244216 void reportMcMavenNotDeclared () {
217+ if (!properties .test ("net.minecraftforge.gradle.warnings.missingRepository.mcmaven" )) return ;
218+
245219 this .getReporter ().report (id ("minecraft-maven-not-declared" , "Minecraft Maven not declared" ), spec -> spec
246220 .details ("""
247221 ForgeGradle was configured to sync the Minecraft Maven, but it was not declared as a repository!
@@ -253,6 +227,8 @@ void reportMcMavenNotDeclared() {
253227 }
254228
255229 void reportMcLibsMavenNotDeclared () {
230+ if (!properties .test ("net.minecraftforge.gradle.warnings.missingRepository.mclibs" )) return ;
231+
256232 this .getReporter ().report (id ("minecraft-libs-maven-not-declared" , "Minecraft Libraries maven not declared" ), spec -> spec
257233 .details ("""
258234 ForgeGradle was configured to sync the Minecraft Maven, but the Minecraft Libraries maven was not declared!
@@ -265,6 +241,8 @@ void reportMcLibsMavenNotDeclared() {
265241 }
266242
267243 void reportForgeMavenNotDeclared () {
244+ if (!properties .test ("net.minecraftforge.gradle.warnings.missingRepository.forge" )) return ;
245+
268246 this .getReporter ().report (id ("forge-maven-not-declared" , "Forge maven not declared" ), spec -> spec
269247 .details ("""
270248 ForgeGradle was configured to sync the Minecraft Maven, but the Forge maven was not declared!
@@ -275,26 +253,14 @@ void reportForgeMavenNotDeclared() {
275253 .solution (HELP_MESSAGE )
276254 );
277255 }
278-
279- void reportMcMavenNotFound (Throwable e ) {
280- this .getReporter ().report (id ("minecraft-maven-not-found" , "Minecraft Maven not found" ), spec -> spec
281- .details ("""
282- Attempted to sync the Minecraft Maven, but the Minecraft Mavenizer tool was not found!""" )
283- .withException (e )
284- .severity (Severity .ERROR )
285- .solution ("Ensure that the Forge Maven (`fg.forgeMaven`) exists in your project/settings repositories." )
286- .solution ("If you are using a custom tool, ensure that you added your repository and it is up and running." )
287- .solution (HELP_MESSAGE )
288- );
289- }
290256 //endregion
291257
292258 //region Deobfuscation
293259 RuntimeException invalidDeobfDependencyType (Dependency dependency ) {
294- return this .getReporter ().throwing (new IllegalArgumentException ("Non-module dependencies are not currently supported" ), id ("unsupported-dependency-type" , "Non-module dependency used as Minecraft/deobf dependency" ), spec -> spec
260+ return this .getReporter ().throwing (new IllegalArgumentException ("Non-module deobf dependencies are not supported" ), id ("unsupported-dependency-type" , "Non-module dependency used as Minecraft/deobf dependency" ), spec -> spec
295261 .details ("""
296262 Attempted to use a non-module dependency as a deobf dependency, which is currently unsupported.
297- Support for file dependencies will come at a later time. Project dependencies are not supported.
263+ Support for file dependencies may come at a later time. Project dependencies will not be supported.
298264 Expected: (implementation of) %s, Actual: '%s
299265 Dependency: '%s'"""
300266 .formatted (ExternalModuleDependency .class .getName (), dependency .getClass ().getName (), dependency .toString ()))
0 commit comments