Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin] Gradle plugin unconditionally assumes that a clean tasks exists #1492

Open
sschuberth opened this issue Sep 18, 2023 · 4 comments
Open
Labels
gradle Affects Gradle plugins

Comments

@sschuberth
Copy link

In

project.tasks.named('clean', new Action<Task>() {
@Override
void execute(Task t) {
t.doFirst(new Action<Task>() {
@Override
void execute(Task task) {
loggerProvider.get().close()
}
})
}
})

a cleantask is (re-)configured to close the logger. However, when applying the JReleaser plugin (for ChangeLog generation only) to the root project (of a multi-project with multiple application projects), no clean task exists.

Is this code even legit? Why should the logger (only) be closed if the clean task is executed?

@aalmiray
Copy link
Member

a cleantask is (re-)configured to close the logger. However, when applying the JReleaser plugin (for ChangeLog generation only) to the root project (of a multi-project with multiple application projects), no clean task exists.

The current expectation is to have a clean task available. I was under the impression such task is always there as it's very likely that a root project includes a base plugin that provides the task, even if the root has no sources at all.

Is this code even legit?

I don't know what you were expecting to gain with this remark.

Why should the logger (only) be closed if the clean task is executed?

More context #1074

#1292

@sschuberth
Copy link
Author

I was under the impression such task is always there as it's very likely that a root project includes a base plugin that provides the task, even if the root has no sources at all.

Well, all I can say is that in a build file like this no clean task is available.

I don't know what you were expecting to gain with this remark.

I was simply wondering whether, instead of fixing the code to not assume the clean task to exist, the code could simply be removed.

More context #1074

Thanks.

@aalmiray
Copy link
Member

I was simply wondering whether, instead of fixing the code to not assume the clean task to exist, the code could simply be removed.

Then I'd suggest you lead with more explanation as you just did instead of what you wrote on the first message.

Clarity always wins.

@aalmiray
Copy link
Member

And no, the code cannot be removed. The logger must be closed no matter what otherwise a file descriptor will be left open on Windows, leading to other problems.

What could happen is adding a check for the existence of a clean tasks but IIRC that is what the Gradle API offers by registering a lazy action matching tasks by name.

@aalmiray aalmiray added the gradle Affects Gradle plugins label Sep 22, 2023
@aalmiray aalmiray changed the title Gradle plugin unconditionally assumes that a clean tasks exists [plugin] Gradle plugin unconditionally assumes that a clean tasks exists Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gradle Affects Gradle plugins
Projects
None yet
Development

No branches or pull requests

2 participants