Search code examples
gradlegradlew

Chained Gradle task cannot read file generated by previous task


I have gradle task, taskA, which when run will generate a html file. Then taskB will try opening that file. When I chain these like:

./gradlew taskA taskB

Then taskB cannot see the generated file. Incidentally IntelliJ is open and does not see the file at the same time.

However if I run the commands separately, e.g.

./gradlew taskA
./gradlew taskB

Then taskB can see the file fine. Do you know how I might chain the commands with the effect of running them separately? I have tried using clean at the start of taskB but it does not help.


Solution

  • The way I got it to work was by cd'ing back into the current directory. This can be achieved with the following command, when you are in the correct directory:

    cd .
    

    This forces gradle to pick up any new files immediately.