21
21
import org .gradle .api .DefaultTask ;
22
22
import org .gradle .api .Task ;
23
23
import org .gradle .api .artifacts .Configuration ;
24
+ import org .gradle .api .file .ArchiveOperations ;
24
25
import org .gradle .api .file .DirectoryProperty ;
25
26
import org .gradle .api .file .FileSystemOperations ;
26
27
import org .gradle .api .provider .SetProperty ;
@@ -37,9 +38,12 @@ public abstract class PrepareMavenBinaries extends DefaultTask {
37
38
38
39
private final FileSystemOperations fileSystemOperations ;
39
40
41
+ private final ArchiveOperations archiveOperations ;
42
+
40
43
@ Inject
41
- public PrepareMavenBinaries (FileSystemOperations fileSystemOperations ) {
44
+ public PrepareMavenBinaries (FileSystemOperations fileSystemOperations , ArchiveOperations archiveOperations ) {
42
45
this .fileSystemOperations = fileSystemOperations ;
46
+ this .archiveOperations = archiveOperations ;
43
47
}
44
48
45
49
@ OutputDirectory
@@ -53,10 +57,9 @@ public void prepareBinaries() {
53
57
this .fileSystemOperations .sync ((sync ) -> {
54
58
sync .into (getOutputDir ());
55
59
for (String version : getVersions ().get ()) {
56
- Configuration configuration = getProject ().getConfigurations ()
57
- .detachedConfiguration (getProject ().getDependencies ()
58
- .create ("org.apache.maven:apache-maven:" + version + ":bin@zip" ));
59
- sync .from (getProject ().zipTree (configuration .getSingleFile ()));
60
+ Configuration configuration = getProject ().getConfigurations ().detachedConfiguration (
61
+ getProject ().getDependencies ().create ("org.apache.maven:apache-maven:" + version + ":bin@zip" ));
62
+ sync .from (this .archiveOperations .zipTree (configuration .getSingleFile ()));
60
63
}
61
64
});
62
65
0 commit comments