25
25
import org .gradle .api .Project ;
26
26
import org .gradle .api .Task ;
27
27
import org .gradle .api .artifacts .Configuration ;
28
+ import org .gradle .api .artifacts .component .ComponentArtifactIdentifier ;
28
29
import org .gradle .api .execution .TaskActionListener ;
29
30
import org .gradle .api .execution .TaskExecutionListener ;
31
+ import org .gradle .api .file .FileTree ;
30
32
import org .gradle .api .logging .Logger ;
31
33
import org .gradle .api .logging .Logging ;
32
34
import org .gradle .api .plugins .ExtraPropertiesExtension ;
35
+ import org .gradle .api .tasks .Sync ;
33
36
import org .gradle .api .tasks .TaskState ;
34
37
35
38
import java .io .File ;
39
42
import java .util .List ;
40
43
import java .util .Map ;
41
44
import java .util .Set ;
45
+ import java .util .concurrent .Callable ;
42
46
import java .util .concurrent .ConcurrentHashMap ;
43
47
import java .util .concurrent .ExecutorService ;
44
48
import java .util .concurrent .Executors ;
@@ -87,6 +91,20 @@ public void apply(Project project) {
87
91
"Internal helper configuration used by cluster configuration to download " +
88
92
"ES distributions and plugins."
89
93
);
94
+ helperConfiguration .getIncoming ().afterResolve (resolvableDependencies -> {
95
+ Set <ComponentArtifactIdentifier > nonZipComponents = resolvableDependencies .getArtifacts ()
96
+ .getArtifacts ()
97
+ .stream ()
98
+ .filter (artifact -> artifact .getFile ().getName ().endsWith (".zip" ) == false )
99
+ .map (artifact -> artifact .getId ())
100
+ .collect (Collectors .toSet ());
101
+
102
+ if (nonZipComponents .isEmpty () == false ) {
103
+ throw new IllegalStateException ("Dependencies with non-zip artifacts found in configuration '" +
104
+ TestClustersPlugin .HELPER_CONFIGURATION_NAME + "': " + nonZipComponents
105
+ );
106
+ }
107
+ });
90
108
91
109
// When running in the Daemon it's possible for this to hold references to past
92
110
usedClusters .clear ();
@@ -98,7 +116,15 @@ public void apply(Project project) {
98
116
// the clusters will look for artifacts there based on the naming conventions.
99
117
// Tasks that use a cluster will add this as a dependency automatically so it's guaranteed to run early in
100
118
// the build.
101
- rootProject .getTasks ().create (SYNC_ARTIFACTS_TASK_NAME , SyncTestClustersConfiguration .class );
119
+ rootProject .getTasks ().create (SYNC_ARTIFACTS_TASK_NAME , Sync .class , sync -> {
120
+ sync .from ((Callable <List <FileTree >>) () ->
121
+ helperConfiguration .getFiles ()
122
+ .stream ()
123
+ .map (project ::zipTree )
124
+ .collect (Collectors .toList ())
125
+ );
126
+ sync .into (new File (getTestClustersConfigurationExtractDir (project ), "zip" ));
127
+ });
102
128
103
129
// When we know what tasks will run, we claim the clusters of those task to differentiate between clusters
104
130
// that are defined in the build script and the ones that will actually be used in this invocation of gradle
@@ -129,7 +155,7 @@ private NamedDomainObjectContainer<ElasticsearchNode> createTestClustersContaine
129
155
project .getPath (),
130
156
name ,
131
157
GradleServicesAdapter .getInstance (project ),
132
- SyncTestClustersConfiguration . getTestClustersConfigurationExtractDir (project ),
158
+ getTestClustersConfigurationExtractDir (project ),
133
159
new File (project .getBuildDir (), "testclusters" )
134
160
)
135
161
);
@@ -249,8 +275,8 @@ public void beforeExecute(Task task) {}
249
275
);
250
276
}
251
277
252
- static File getTestClustersBuildDir (Project project ) {
253
- return new File (project .getRootProject ().getBuildDir (), "testclusters" );
278
+ static File getTestClustersConfigurationExtractDir (Project project ) {
279
+ return new File (project .getRootProject ().getBuildDir (), "testclusters/extract " );
254
280
}
255
281
256
282
/**
0 commit comments