File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
main/groovy/com/avast/gradle/dockercompose
test/groovy/com/avast/gradle/dockercompose Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ class ComposeExtension {
4040 void isRequiredBy (Task task ) {
4141 task. dependsOn upTask
4242 task. finalizedBy downTask
43+ def ut = upTask // to access private field from closure
44+ task. getTaskDependencies(). getDependencies(task)
45+ .findAll { Task . class. isAssignableFrom(it. class) && ((Task )it). name. toLowerCase(). contains(' classes' ) }
46+ .each { ut. shouldRunAfter it }
4347 }
4448
4549 Map<String , ServiceInfo > getServicesInfos () {
Original file line number Diff line number Diff line change @@ -31,6 +31,17 @@ class DockerComposePluginTest extends Specification {
3131 task. getFinalizedBy(). getDependencies(task). any { it == project. tasks. composeDown }
3232 }
3333
34+ def " isRequiredBy ensures right order of tasks" () {
35+ def project = ProjectBuilder . builder(). build()
36+ project. plugins. apply ' docker-compose'
37+ project. plugins. apply ' java'
38+ when :
39+ project. dockerCompose. isRequiredBy(project. tasks. test)
40+ then :
41+ project. tasks. composeUp. shouldRunAfter. values. any { it == project. tasks. testClasses }
42+ noExceptionThrown()
43+ }
44+
3445 def " allows usage from integration test" () {
3546 def projectDir = new TmpDirTemporaryFileProvider (). createTemporaryDirectory(" gradle" , " projectDir" )
3647 new File (projectDir, ' docker-compose.yml' ) << '''
You can’t perform that action at this time.
0 commit comments