77import org .gradle .api .Project ;
88import org .gradle .api .Task ;
99import org .gradle .api .file .Directory ;
10+ import org .gradle .api .file .DirectoryProperty ;
1011import org .gradle .api .file .RegularFile ;
1112import org .gradle .api .provider .Provider ;
1213import org .gradle .api .tasks .Internal ;
1314
15+ import java .io .File ;
16+
1417/// The enhanced task contains a handful of helper methods to make working with the enhanced plugin and caches easier.
15- ///
16- /// @param <T> The type of enhanced plugin
17- public interface EnhancedTask <T extends EnhancedPlugin <? super Project >> extends Task {
18+ public interface EnhancedTask extends Task {
1819 /// The enhanced plugin type for this task.
1920 ///
2021 /// @return The plugin type
21- @ Internal Class <T > getPluginType ();
22+ Class <? extends EnhancedPlugin <? super Project >> pluginType ();
2223
23- /// The enhanced plugin associated with this task.
24- ///
25- /// @return The plugin
26- default @ Internal T getPlugin () {
27- return this .getProject ().getPlugins ().getPlugin (this .getPluginType ());
24+ private EnhancedPlugin <? super Project > getPlugin () {
25+ return this .getProject ().getPlugins ().getPlugin (this .pluginType ());
26+ }
27+
28+ /// @see EnhancedPlugin#getTool(Tool)
29+ default Provider <File > getTool (Tool tool ) {
30+ return this .getPlugin ().getTool (tool );
31+ }
32+
33+ /// @see EnhancedPlugin#globalCaches()
34+ default DirectoryProperty globalCaches () {
35+ return this .getPlugin ().globalCaches ();
36+ }
37+
38+ /// @see EnhancedPlugin#localCaches()
39+ default DirectoryProperty localCaches () {
40+ return this .getPlugin ().localCaches ();
2841 }
2942
3043 /// The default output directory to use for this task if it outputs a directory.
3144 ///
3245 /// @return A provider for the directory
3346 default @ Internal Provider <Directory > getDefaultOutputDirectory () {
34- return this .getPlugin (). localCaches ().dir (this .getName ()).map (this .getPlugin ().getProblemsInternal ().ensureFileLocation ());
47+ return this .localCaches ().dir (this .getName ()).map (this .getPlugin ().getProblemsInternal ().ensureFileLocation ());
3548 }
3649
3750 /// The default output file to use for this task if it outputs a file. Uses the `.jar` extension.
@@ -46,6 +59,6 @@ public interface EnhancedTask<T extends EnhancedPlugin<? super Project>> extends
4659 /// @param ext The extension to use for the file
4760 /// @return A provider for the file
4861 default Provider <RegularFile > getDefaultOutputFile (String ext ) {
49- return this .getPlugin (). localCaches ().file ("%s/output.%s" .formatted (this .getName (), ext )).map (this .getPlugin ().getProblemsInternal ().ensureFileLocation ());
62+ return this .localCaches ().file ("%s/output.%s" .formatted (this .getName (), ext )).map (this .getPlugin ().getProblemsInternal ().ensureFileLocation ());
5063 }
5164}
0 commit comments