-
Notifications
You must be signed in to change notification settings - Fork 280
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
Add summaries and groups to Gradle tasks #190
base: main
Are you sure you want to change the base?
Conversation
createModulesTask(JavaCodeGenTask.class, spec) | ||
.configure( | ||
task -> { | ||
task.setDescription(TaskConstants.GENERATE_JAVA_DESCRIPTION); | ||
task.setGroup(TaskConstants.TASK_GROUP_CODEGEN); |
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.
In general, this is how I'm configuring description
and group
on these tasks.
/** Gradle task group declared for code-gen tasks. */ | ||
static final String TASK_GROUP_CODEGEN = "Code generation"; | ||
|
||
/** Gradle task group declared for documentation tasks. */ | ||
static final String TASK_GROUP_DOCS = "Documentation"; | ||
|
||
/** Gradle task description for generating Java code from Pkl modules. */ | ||
static final String GENERATE_JAVA_DESCRIPTION = "Generate Java code from Pkl modules"; | ||
|
||
/** Gradle task description for generating Kotlin code from Pkl modules. */ | ||
static final String GENERATE_KOTLIN_DESCRIPTION = "Generate Kotlin code from Pkl modules"; | ||
|
||
/** Gradle task description for generating Pkldoc from Pkl modules. */ | ||
static final String GENERATE_PKLDOC_DESCRIPTION = "Generate Pkldoc from Pkl modules"; |
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.
Task constants that will show in ./gradlew tasks
for a project with the Pkl Gradle Plugin added.
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.
FWIW, I think that if these strings are not reused anywhere, it might make sense to inline them to the specific task definitions within the plugin code. But I don't have a strong opinion on this.
Fixes and closes apple#188 by adding task names and groups to major Pkl Gradle Plugin tasks Signed-off-by: Sam Gammon <[email protected]>
5d4fe9f
to
4f6ebfe
Compare
package org.pkl.gradle; | ||
|
||
/** Constant values used by tasks */ | ||
class TaskConstants { |
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 believe it is more conventional to put these constants directly to the plugin class.
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.
What about the category settings, which must be shared between plugins? I think there may be symbols for those somewhere in Gradle's API. I'll look for appropriate ones to use.
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.
There's LifecycleBasePlugin which provides the base task names and groups.
Then there's JvmConstants, but this seems less appropriate for us.
I think it's fine to just have these as strings, though.
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.
There is only one plugin in the project, so there is nothing to share, or an I missing something?
Anyway, if you look at the built-in Gradle plugins, they always contain constants related to tasks configured by these plugins within the plugin class. If we ever decide to make new plugins, we can move these constants to the appropriate location at that time.
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.
Maybe one letter and lowercase these group names?
Also; per @netvl's comments, would be good to follow convention and put these constants within PklPlugin
.
static final String TASK_GROUP_CODEGEN = "Code generation"; | ||
|
||
/** Gradle task group declared for documentation tasks. */ | ||
static final String TASK_GROUP_DOCS = "Documentation"; |
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.
Seems like these group names are generally lowercase single words.
static final String TASK_GROUP_CODEGEN = "Code generation"; | |
/** Gradle task group declared for documentation tasks. */ | |
static final String TASK_GROUP_DOCS = "Documentation"; | |
static final String TASK_GROUP_CODEGEN = "codegen"; | |
/** Gradle task group declared for documentation tasks. */ | |
static final String TASK_GROUP_DOCS = "documentation"; |
package org.pkl.gradle; | ||
|
||
/** Constant values used by tasks */ | ||
class TaskConstants { |
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.
There's LifecycleBasePlugin which provides the base task names and groups.
Then there's JvmConstants, but this seems less appropriate for us.
I think it's fine to just have these as strings, though.
Fixes and closes #188 by adding task names and groups to major Pkl Gradle Plugin tasks. I would love advice from library authors that these are the right tasks to expose to users.