gradle-docker-compose-plugin icon indicating copy to clipboard operation
gradle-docker-compose-plugin copied to clipboard

removeContainers = false is broken when using gradle 8.x

Open kwonglau opened this issue 2 years ago • 5 comments

it seems that the value is not override

kwonglau avatar Jul 12 '23 22:07 kwonglau

I got it working again when doing

getRemoveContainers() {
    return false;
}

however, this syntax is not recommended in gradle 8

kwonglau avatar Jul 12 '23 22:07 kwonglau

Hello, what do you please mean by is broken? 🙏

augi avatar Aug 09 '23 20:08 augi

I figured out the correct syntax a while ago and I forgot to update here.

If I have the following in gradle.properties

removeContainers=false

and If I have the following in build.gradle

dockerCompose {
   mysql {
      removeContainers = project.ext.removeContainers.toBoolean()
   }
}

the above will not work, removeContainers is calling the getter and the "=" is not mutating the removeContainers value. the correct syntax when using gradle 8 should be the following:

dockerCompose {
   mysql {
      removeContainers project.ext.removeContainers.toBoolean()
   }
}

removing the "=" will call the setter

kwonglau avatar Aug 09 '23 21:08 kwonglau

That's interesting. Here you can see that the getRemoveContainers is Property<Boolean> so it should IMHO work 🤔

augi avatar Aug 10 '23 06:08 augi

I get what you mean. I have tried that and set break point to debug. but it didn't work.

This is actually broken for more than a year and I used to use

getRemoveContainers() {
    return false;
}

to get around the issue. And I just figure out a cleaner way to override the value using removeContainers project.ext.removeContainers.toBoolean()

kwonglau avatar Aug 10 '23 19:08 kwonglau