-
Notifications
You must be signed in to change notification settings - Fork 45
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
Refactor gradle plugin #263
Conversation
I see you did not touch bindings logic but we have a failure on |
2b0e1a9
to
df84299
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of an anti-pattern for a task to declare its own dependencies. Normally it's the responsibility of the plugin to setup that. If a task requires some input from another task then it can be passed to the task as an input property. https://docs.gradle.org/current/userguide/custom_tasks.html
open class TaskA: AbstractTask() {
@Output
public val output = objects.stringProperty()
}
open class TaskB: AbstractTask() {
@Input
val input = objects.stringProperty()
}
// somewhere in the plugin
taskB.input.set(taskA.output)
The advantage of doing it this way is we can leverage gradle incremental build support. So if taskB's output didn't change then taskA will not be executed.
So a task should only do one thing, it doesn't know anything about the other tasks.
…nto individual files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but I have a couple of questions.
) | ||
|
||
// START: android specific tasks | ||
val checkD8ToolAccessibleTask = checkD8ToolAccessibleTask() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was expecting an if (isAndroidExportConfigured())
statement here, what happens if the user doesnt' want to build for android?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently taking care of in the setup of the build
task:
if (godotJvmExtension.isAndroidExportEnabled.get()) {
finalizedBy(packageBootstrapDexJarTask, packageMainDexJarTask)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, weird way of doing it - we don't really need to configure the android/native image tasks when they are disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, not a big issue. This will change once I'm done with the refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// END: android specific tasks | ||
|
||
// START: graal native image specific tasks | ||
val checkNativeImageToolAccessibleTask = checkNativeImageToolAccessibleTask() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
import org.gradle.api.Task | ||
|
||
fun Project.checkAndroidJarAccessibleTask(): Task { | ||
return with(tasks.create("checkAndroidJarAccessible")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big issue, but have you tried using register
instead of create
? With register a task is only configured/resolved when it will participate in the execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice to know. I'll change them
Resolves #259
by introducing a task registry with which the individual tasks are properly grouped and accessible and configurable in a typesafe way.by splitting the task registration/creation into individual extension functions residing in their own files.It also splits some functions up into individual parts and removes some parameter passing by introducing extension functions/properties for gradles
Project
class so we can access extensions directly for example.This could further be improved though by using sealed classes or interfaces for the tasks and use them inside theTaskRegistry
as in it's current state, theTaskRegistry
could become unreadable if even more tasks would be added in the future. But to keep this more simple until we actually need it, i opted to just keep them in an enum for now.Edit: updated implementation after: #263 (review)