@@ -71,6 +71,8 @@ public void apply(Project project) {
7171 pullFixture .setEnabled (false );
7272 return ;
7373 }
74+ preProcessFixture .onlyIf (spec -> buildFixture .getEnabled ());
75+ postProcessFixture .onlyIf (spec -> buildFixture .getEnabled ());
7476
7577 project .apply (spec -> spec .plugin (BasePlugin .class ));
7678 project .apply (spec -> spec .plugin (DockerComposePlugin .class ));
@@ -94,21 +96,26 @@ public void apply(Project project) {
9496 (name , port ) -> postProcessFixture .getExtensions ()
9597 .getByType (ExtraPropertiesExtension .class ).set (name , port )
9698 );
99+ extension .fixtures .add (project );
97100 }
98101
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+
100111 if (dockerComposeSupported (project ) == false ) {
101112 project .getLogger ().warn (
102113 "Tests for {} require docker-compose at /usr/local/bin/docker-compose or /usr/bin/docker-compose " +
103114 "but none could be found so these will be skipped" , project .getPath ()
104115 );
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 );
110116 return ;
111117 }
118+
112119 tasks .withType (getTaskClass ("com.carrotsearch.gradle.junit4.RandomizedTestingTask" ), task ->
113120 extension .fixtures .all (fixtureProject -> {
114121 fixtureProject .getTasks ().matching (it -> it .getName ().equals ("buildFixture" )).all (buildFixture ->
@@ -128,6 +135,16 @@ public void apply(Project project) {
128135
129136 }
130137
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+
131148 private void configureServiceInfoForTask (Task task , Project fixtureProject , BiConsumer <String , Integer > consumer ) {
132149 // Configure ports for the tests as system properties.
133150 // We only know these at execution time so we need to do it in doFirst
0 commit comments