|
7 | 7 | import org.codehaus.groovy.runtime.DefaultGroovyMethods; |
8 | 8 | import org.gradle.api.DefaultTask; |
9 | 9 | import org.gradle.api.Transformer; |
| 10 | +import org.gradle.api.artifacts.Dependency; |
| 11 | +import org.gradle.api.artifacts.dsl.DependencyFactory; |
10 | 12 | import org.gradle.api.file.ConfigurableFileCollection; |
11 | 13 | import org.gradle.api.file.DirectoryProperty; |
12 | 14 | import org.gradle.api.file.FileSystemLocation; |
|
19 | 21 | import org.gradle.api.provider.ListProperty; |
20 | 22 | import org.gradle.api.provider.Property; |
21 | 23 | import org.gradle.api.provider.Provider; |
| 24 | +import org.gradle.api.provider.ProviderConvertible; |
22 | 25 | import org.gradle.api.provider.ProviderFactory; |
23 | 26 | import org.gradle.api.tasks.Classpath; |
24 | 27 | import org.gradle.api.tasks.Console; |
|
30 | 33 | import org.gradle.api.tasks.Optional; |
31 | 34 | import org.gradle.api.tasks.OutputFile; |
32 | 35 | import org.gradle.api.tasks.TaskAction; |
| 36 | +import org.gradle.internal.logging.StandardOutputCapture; |
33 | 37 | import org.gradle.jvm.toolchain.JavaLanguageVersion; |
34 | 38 | import org.gradle.jvm.toolchain.JavaLauncher; |
35 | 39 | import org.gradle.jvm.toolchain.JavaToolchainService; |
@@ -75,11 +79,11 @@ public abstract class ToolExecBase<P extends EnhancedProblems> extends DefaultTa |
75 | 79 | } |
76 | 80 |
|
77 | 81 | //region JavaExec |
78 | | - protected abstract @InputFiles @Classpath ConfigurableFileCollection getClasspath(); |
| 82 | + public abstract @InputFiles @Classpath ConfigurableFileCollection getClasspath(); |
79 | 83 |
|
80 | | - protected abstract @Input @Optional Property<String> getMainClass(); |
| 84 | + public abstract @Input @Optional Property<String> getMainClass(); |
81 | 85 |
|
82 | | - protected abstract @Nested Property<JavaLauncher> getJavaLauncher(); |
| 86 | + public abstract @Nested Property<JavaLauncher> getJavaLauncher(); |
83 | 87 |
|
84 | 88 | protected abstract @Nested Property<JavaLauncher> getToolchainLauncher(); |
85 | 89 |
|
@@ -107,6 +111,8 @@ public abstract class ToolExecBase<P extends EnhancedProblems> extends DefaultTa |
107 | 111 |
|
108 | 112 | protected abstract @Inject ExecOperations getExecOperations(); |
109 | 113 |
|
| 114 | + protected abstract @Inject DependencyFactory getDependencies(); |
| 115 | + |
110 | 116 | protected abstract @Inject JavaToolchainService getJavaToolchains(); |
111 | 117 |
|
112 | 118 | /// Creates a new task instance using the given types and tool information. |
@@ -141,6 +147,26 @@ protected ToolExecBase(Tool tool) { |
141 | 147 | this.getLogFile().convention(this.getDefaultLogFile()); |
142 | 148 | } |
143 | 149 |
|
| 150 | + public final void using(CharSequence dependency) { |
| 151 | + this.using(getDependencies().create(dependency)); |
| 152 | + } |
| 153 | + |
| 154 | + public final void using(Provider<? extends Dependency> dependency) { |
| 155 | + this.getClasspath().setFrom( |
| 156 | + getProject().getConfigurations().detachedConfiguration().withDependencies(d -> d.addLater(dependency)) |
| 157 | + ); |
| 158 | + } |
| 159 | + |
| 160 | + public final void using(ProviderConvertible<? extends Dependency> dependency) { |
| 161 | + this.using(dependency.asProvider()); |
| 162 | + } |
| 163 | + |
| 164 | + public final void using(Dependency dependency) { |
| 165 | + this.getClasspath().setFrom( |
| 166 | + getProject().getConfigurations().detachedConfiguration(dependency) |
| 167 | + ); |
| 168 | + } |
| 169 | + |
144 | 170 | /// The enhanced problems instance to use for this task. |
145 | 171 | /// |
146 | 172 | /// @return The enhanced problems |
|
0 commit comments