@@ -71,6 +71,8 @@ public void apply(Project project) {
71
71
pullFixture .setEnabled (false );
72
72
return ;
73
73
}
74
+ preProcessFixture .onlyIf (spec -> buildFixture .getEnabled ());
75
+ postProcessFixture .onlyIf (spec -> buildFixture .getEnabled ());
74
76
75
77
project .apply (spec -> spec .plugin (BasePlugin .class ));
76
78
project .apply (spec -> spec .plugin (DockerComposePlugin .class ));
@@ -94,21 +96,26 @@ public void apply(Project project) {
94
96
(name , port ) -> postProcessFixture .getExtensions ()
95
97
.getByType (ExtraPropertiesExtension .class ).set (name , port )
96
98
);
99
+ extension .fixtures .add (project );
97
100
}
98
101
99
- extension .fixtures .all (fixtureProject -> project .evaluationDependsOn (fixtureProject .getPath ()));
102
+ extension .fixtures
103
+ .matching (fixtureProject -> fixtureProject .equals (project ) == false )
104
+ .all (fixtureProject -> project .evaluationDependsOn (fixtureProject .getPath ()));
105
+
106
+ conditionTaskByType (tasks , extension , getTaskClass ("com.carrotsearch.gradle.junit4.RandomizedTestingTask" ));
107
+ conditionTaskByType (tasks , extension , getTaskClass ("org.elasticsearch.gradle.test.RestIntegTestTask" ));
108
+ conditionTaskByType (tasks , extension , TestingConventionsTasks .class );
109
+ conditionTaskByType (tasks , extension , ComposeUp .class );
110
+
100
111
if (dockerComposeSupported (project ) == false ) {
101
112
project .getLogger ().warn (
102
113
"Tests for {} require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose " +
103
114
"but none could be found so these will be skipped" , project .getPath ()
104
115
);
105
- disableTaskByType (tasks , getTaskClass ("com.carrotsearch.gradle.junit4.RandomizedTestingTask" ));
106
- disableTaskByType (tasks , getTaskClass ("org.elasticsearch.gradle.test.RestIntegTestTask" ));
107
- // conventions are not honored when the tasks are disabled
108
- disableTaskByType (tasks , TestingConventionsTasks .class );
109
- disableTaskByType (tasks , ComposeUp .class );
110
116
return ;
111
117
}
118
+
112
119
tasks .withType (getTaskClass ("com.carrotsearch.gradle.junit4.RandomizedTestingTask" ), task ->
113
120
extension .fixtures .all (fixtureProject -> {
114
121
fixtureProject .getTasks ().matching (it -> it .getName ().equals ("buildFixture" )).all (buildFixture ->
@@ -128,6 +135,16 @@ public void apply(Project project) {
128
135
129
136
}
130
137
138
+ private void conditionTaskByType (TaskContainer tasks , TestFixtureExtension extension , Class <? extends DefaultTask > taskClass ) {
139
+ tasks .withType (
140
+ taskClass ,
141
+ task -> task .onlyIf (spec ->
142
+ extension .fixtures .stream ()
143
+ .anyMatch (fixtureProject -> fixtureProject .getTasks ().getByName ("buildFixture" ).getEnabled () == false ) == false
144
+ )
145
+ );
146
+ }
147
+
131
148
private void configureServiceInfoForTask (Task task , Project fixtureProject , BiConsumer <String , Integer > consumer ) {
132
149
// Configure ports for the tests as system properties.
133
150
// We only know these at execution time so we need to do it in doFirst
0 commit comments