44 */
55package net .minecraftforge .gradleutils .shared ;
66
7- import groovy .lang .GroovyObjectSupport ;
87import org .gradle .api .Action ;
98import org .gradle .api .Task ;
109import org .gradle .api .Transformer ;
3130import java .io .Serializable ;
3231import java .nio .file .Files ;
3332import java .util .Collection ;
33+ import java .util .Locale ;
3434import java .util .function .Predicate ;
3535import java .util .stream .Collectors ;
3636import java .util .stream .Stream ;
@@ -136,15 +136,8 @@ public final boolean test(String property) {
136136 /* DEFAULT PROBLEMS */
137137
138138 //region Enhanced Plugin
139-
140- /// Reports an illegal plugin target.
141- ///
142- /// @param e The exception that was caught, will be re-thrown (or wrapped with a
143- /// [RuntimeException])
144- /// @param firstAllowedTarget The first allowed target for the plugin
145- /// @param allowedTargets The remaining allowed targets for the plugin
146- /// @return The exception to throw
147- public final RuntimeException illegalPluginTarget (Exception e , Class <?> firstAllowedTarget , Class <?>... allowedTargets ) {
139+ @ SuppressWarnings ("SameParameterValue" )
140+ final RuntimeException illegalPluginTarget (Exception e , Class <?> firstAllowedTarget , Class <?>... allowedTargets ) {
148141 return this .getReporter ().throwing (e , id ("invalid-plugin-target" , "Invalid plugin target" ), spec -> spec
149142 .details (String .format (
150143 "Attempted to apply the %s plugin to an invalid target.\n " +
@@ -156,12 +149,8 @@ public final RuntimeException illegalPluginTarget(Exception e, Class<?> firstAll
156149 .solution (HELP_MESSAGE ));
157150 }
158151
159- /// Reports an illegal plugin target.
160- ///
161- /// @param e The exception that was caught, will be re-thrown (or wrapped with a [RuntimeException])
162- /// @param allowedTargets A string stating the allowed targets for the plugin
163- /// @return The exception to throw
164- public final RuntimeException illegalPluginTarget (Exception e , String allowedTargets ) {
152+ @ SuppressWarnings ("SameParameterValue" )
153+ final RuntimeException illegalPluginTarget (Exception e , String allowedTargets ) {
165154 return this .getReporter ().throwing (e , id ("invalid-plugin-target" , "Invalid plugin target" ), spec -> spec
166155 .details (String .format (
167156 "Attempted to apply the %s plugin to an invalid target.\n " +
@@ -172,11 +161,7 @@ public final RuntimeException illegalPluginTarget(Exception e, String allowedTar
172161 .solution (HELP_MESSAGE ));
173162 }
174163
175- /// Reports an illegal access of a plugin before it has been applied.
176- ///
177- /// @param e The exception that was caught, will be re-thrown (or wrapped with a [RuntimeException])
178- /// @return The exception to throw
179- public final RuntimeException pluginNotYetApplied (Exception e ) {
164+ final RuntimeException pluginNotYetApplied (Exception e ) {
180165 return this .getReporter ().throwing (e , id ("plugin-not-yet-applied" , String .format ("%s is not applied" , this .displayName )), spec -> spec
181166 .details (String .format (
182167 "Attempted to get details from the %s plugin, but it has not yet been applied to the target." , this .displayName ))
@@ -190,39 +175,23 @@ public final RuntimeException pluginNotYetApplied(Exception e) {
190175 //endregion
191176
192177 //region ToolExecBase
193-
194- /// Reports an implementation of [ToolExecBase] that is not enhanced with [EnhancedTask].
195- ///
196- /// @param task The affected task
197- public final void reportToolExecNotEnhanced (Task task ) {
198- this .getReporter ().report (id ("tool-exec-not-enhanced" , "ToolExec subclass doesn't implement EnhancedTask" ), spec -> spec
178+ final void reportToolExecNotEnhanced (Task task ) {
179+ String className = task .getClass ().getSimpleName ().replace ('.' , '-' );
180+ task .getLogger ().warn ("WARNING: {} doesn't implement EnhancedTask" , className );
181+ this .getReporter ().report (id (String .format ("%s-not-enhanced" , className .toLowerCase (Locale .ROOT )), String .format ("%s doesn't implement EnhancedTask" , className )), spec -> spec
199182 .details (String .format (
200- "Implementing subclass of ToolExecBase should also implement (a subclass of) EnhancedTask.\n " +
183+ "Implementing subclasses of ToolExecBase should also implement (a subclass of) EnhancedTask.\n " +
201184 "Not doing so will result in global caches being ignored. Please check your implementations.\n " +
202185 "Affected task: %s (%s)" , task , task .getClass ()))
203186 .severity (Severity .WARNING )
204187 .stackLocation ()
205188 .solution ("Double check your task implementation." ));
206189 }
207190
208- /// Reports an implementation of [EnhancedTask] that does not implement [EnhancedTask#pluginType()]
209- ///
210- /// @param task The affected task
211- public final void reportToolExecNotEnhanced (Class <?> task ) {
212- this .getReporter ().report (id ("enhanced-task-no-plugin" , "EnhancedTask doesn't implement #pluginType" ), spec -> spec
213- .details (String .format (
214- "Implementation of EnhancedTask must implement #pluginType\n " +
215- "Affected task type: %s" , task ))
216- .severity (Severity .ERROR )
217- .stackLocation ()
218- .solution ("Double check your task implementation." ));
219- }
220-
221- /// Reports an implementation of [ToolExecBase] that adds arguments without using [ToolExecBase#addArguments()]
222- ///
223- /// @param task The affected task
224- public final void reportToolExecEagerArgs (Task task ) {
225- this .getReporter ().report (id ("tool-exec-eager-args" , "ToolExecBase implementation adds arguments without using addArguments()" ), spec -> spec
191+ final void reportToolExecEagerArgs (Task task ) {
192+ String className = task .getClass ().getSimpleName ().replace ('.' , '-' );
193+ task .getLogger ().warn ("WARNING: {} implementation adds arguments without using addArguments()" , className );
194+ this .getReporter ().report (id (String .format ("%s-eager-args" , className .toLowerCase (Locale .ROOT )), String .format ("%s implementation adds arguments without using addArguments()" , className )), spec -> spec
226195 .details (String .format (
227196 "A ToolExecBase task is eagerly adding arguments using JavaExec#args without using ToolExecBase#addArguments.\n " +
228197 "This may cause implementations or superclasses to have their arguments ignored or missing.\n " +
0 commit comments