2626import org .jetbrains .annotations .Nullable ;
2727
2828import javax .inject .Inject ;
29+ import java .io .File ;
2930import java .io .IOException ;
3031import java .nio .file .Files ;
3132import java .util .Collection ;
@@ -107,10 +108,10 @@ public final boolean test(String property) {
107108 /// @return The exception to throw
108109 public final RuntimeException illegalPluginTarget (Exception e , Class <?> firstAllowedTarget , Class <?>... allowedTargets ) {
109110 return this .getReporter ().throwing (e , id ("invalid-plugin-target" , "Invalid plugin target" ), spec -> spec
110- .details ("""
111- Attempted to apply the %s plugin to an invalid target.
112- This plugin can only be applied on the following types:
113- %s""" . formatted ( this .displayName , Stream .concat (Stream .of (firstAllowedTarget ), Stream .of (allowedTargets )).map (Class ::getName ).collect (Collectors .joining (", " , "[" , "]" ))))
111+ .details (String . format (
112+ " Attempted to apply the %s plugin to an invalid target.\n " +
113+ " This plugin can only be applied on the following types:\n " +
114+ " %s", this .displayName , Stream .concat (Stream .of (firstAllowedTarget ), Stream .of (allowedTargets )).map (Class ::getName ).collect (Collectors .joining (", " , "[" , "]" ))))
114115 .severity (Severity .ERROR )
115116 .stackLocation ()
116117 .solution ("Use a valid plugin target." )
@@ -124,9 +125,9 @@ public final RuntimeException illegalPluginTarget(Exception e, Class<?> firstAll
124125 /// @return The exception to throw
125126 public final RuntimeException illegalPluginTarget (Exception e , String allowedTargets ) {
126127 return this .getReporter ().throwing (e , id ("invalid-plugin-target" , "Invalid plugin target" ), spec -> spec
127- .details ("""
128- Attempted to apply the %s plugin to an invalid target.
129- This plugin can only be applied on %s""" . formatted ( this .displayName , allowedTargets ))
128+ .details (String . format (
129+ " Attempted to apply the %s plugin to an invalid target.\n " +
130+ " This plugin can only be applied on %s", this .displayName , allowedTargets ))
130131 .severity (Severity .ERROR )
131132 .stackLocation ()
132133 .solution ("Use a valid plugin target." )
@@ -138,9 +139,9 @@ public final RuntimeException illegalPluginTarget(Exception e, String allowedTar
138139 /// @param e The exception that was caught, will be re-thrown (or wrapped with a [RuntimeException])
139140 /// @return The exception to throw
140141 public final RuntimeException pluginNotYetApplied (Exception e ) {
141- return this .getReporter ().throwing (e , id ("plugin-not-yet-applied" , "%s is not applied" . formatted ( this .displayName )), spec -> spec
142- .details ("""
143- Attempted to get details from the %s plugin, but it has not yet been applied to the target.""" . formatted ( this .displayName ))
142+ return this .getReporter ().throwing (e , id ("plugin-not-yet-applied" , String . format ( "%s is not applied" , this .displayName )), spec -> spec
143+ .details (String . format (
144+ " Attempted to get details from the %s plugin, but it has not yet been applied to the target.", this .displayName ))
144145 .severity (Severity .ERROR )
145146 .stackLocation ()
146147 .solution ("Apply the plugin before attempting to use it from the target's plugin manager." )
@@ -157,10 +158,10 @@ public final RuntimeException pluginNotYetApplied(Exception e) {
157158 /// @param task The affected task
158159 public final void reportToolExecNotEnhanced (Task task ) {
159160 this .getReporter ().report (id ("tool-exec-not-enhanced" , "ToolExec subclass doesn't implement EnhancedTask" ), spec -> spec
160- .details ("""
161- Implementing subclass of ToolExecBase should also implement (a subclass of) EnhancedTask.
162- Not doing so will result in global caches being ignored. Please check your implementations.
163- Affected task: %s (%s)""" . formatted ( task , task .getClass ()))
161+ .details (String . format (
162+ " Implementing subclass of ToolExecBase should also implement (a subclass of) EnhancedTask.\n " +
163+ " Not doing so will result in global caches being ignored. Please check your implementations.\n " +
164+ " Affected task: %s (%s)", task , task .getClass ()))
164165 .severity (Severity .WARNING )
165166 .stackLocation ()
166167 .solution ("Double check your task implementation." ));
@@ -171,9 +172,9 @@ Implementing subclass of ToolExecBase should also implement (a subclass of) Enha
171172 /// @param task The affected task
172173 public final void reportToolExecNotEnhanced (Class <?> task ) {
173174 this .getReporter ().report (id ("enhanced-task-no-plugin" , "EnhancedTask doesn't implement #pluginType" ), spec -> spec
174- .details ("""
175- Implementation of EnhancedTask must implement #pluginType
176- Affected task type: %s""" . formatted ( task ))
175+ .details (String . format (
176+ " Implementation of EnhancedTask must implement #pluginType\n " +
177+ " Affected task type: %s", task ))
177178 .severity (Severity .ERROR )
178179 .stackLocation ()
179180 .solution ("Double check your task implementation." ));
@@ -184,10 +185,10 @@ public final void reportToolExecNotEnhanced(Class<?> task) {
184185 /// @param task The affected task
185186 public final void reportToolExecEagerArgs (Task task ) {
186187 this .getReporter ().report (id ("tool-exec-eager-args" , "ToolExecBase implementation adds arguments without using addArguments()" ), spec -> spec
187- .details ("""
188- A ToolExecBase task is eagerly adding arguments using JavaExec#args without using ToolExecBase#addArguments.
189- This may cause implementations or superclasses to have their arguments ignored or missing.
190- Affected task: %s (%s)""" . formatted ( task , task .getClass ()))
188+ .details (String . format (
189+ " A ToolExecBase task is eagerly adding arguments using JavaExec#args without using ToolExecBase#addArguments.\n " +
190+ " This may cause implementations or superclasses to have their arguments ignored or missing.\n " +
191+ " Affected task: %s (%s)", task , task .getClass ()))
191192 .severity (Severity .WARNING )
192193 .stackLocation ()
193194 .solution ("Use ToolExecBase#addArguments" ));
@@ -203,15 +204,15 @@ public final void reportToolExecEagerArgs(Task task) {
203204 /// @return The transformer to apply onto a provider
204205 public final <T extends FileSystemLocation > Transformer <T , T > ensureFileLocation () {
205206 return file -> {
206- var dir = file instanceof Directory ? file .getAsFile () : file .getAsFile ().getParentFile ();
207+ File dir = file instanceof Directory ? file .getAsFile () : file .getAsFile ().getParentFile ();
207208 try {
208209 Files .createDirectories (dir .toPath ());
209210 } catch (IOException e ) {
210211 throw this .getReporter ().throwing (e , id ("cannot-ensure-directory" , "Failed to create directory" ), spec -> spec
211- .details ("""
212- Failed to create a directory required for %s to function.
213- Directory: %s"""
214- . formatted ( this .displayName , dir .getAbsolutePath ()))
212+ .details (String . format (
213+ " Failed to create a directory required for %s to function.\n " +
214+ " Directory: %s",
215+ this .displayName , dir .getAbsolutePath ()))
215216 .severity (Severity .ERROR )
216217 .stackLocation ()
217218 .solution ("Ensure that the you have write access to the directory that needs to be created." )
@@ -264,8 +265,8 @@ default RuntimeException throwing(Throwable exception, Collection<? extends Prob
264265 return this .toRTE (exception );
265266 }
266267
267- private RuntimeException toRTE (Throwable exception ) {
268- return exception instanceof RuntimeException rte ? rte : new RuntimeException (exception );
268+ default RuntimeException toRTE (Throwable exception ) {
269+ return exception instanceof RuntimeException ? ( RuntimeException ) exception : new RuntimeException (exception );
269270 }
270271 }
271272
@@ -310,7 +311,7 @@ private Problems unwrapProblems() {
310311
311312 private Predicate <String > unwrapProperties () {
312313 try {
313- var providers = Objects .requireNonNull (this .getProviders ());
314+ ProviderFactory providers = Objects .requireNonNull (this .getProviders ());
314315 return property -> isTrue (providers , property );
315316 } catch (Exception e ) {
316317 return Boolean ::getBoolean ;
0 commit comments