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

Add summaries and groups to Gradle tasks #190

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sgammon
Copy link
Contributor

@sgammon sgammon commented Feb 18, 2024

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.

Comment on lines 171 to +175
createModulesTask(JavaCodeGenTask.class, spec)
.configure(
task -> {
task.setDescription(TaskConstants.GENERATE_JAVA_DESCRIPTION);
task.setGroup(TaskConstants.TASK_GROUP_CODEGEN);
Copy link
Contributor Author

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.

Comment on lines +24 to +37
/** 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";
Copy link
Contributor Author

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.

Copy link

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.

@sgammon sgammon changed the title Add summaries and groups to gradle tasks Add summaries and groups to Gradle tasks Feb 18, 2024
Fixes and closes apple#188 by adding task names and groups to
major Pkl Gradle Plugin tasks

Signed-off-by: Sam Gammon <[email protected]>
package org.pkl.gradle;

/** Constant values used by tasks */
class TaskConstants {
Copy link

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link

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.

Copy link
Contributor

@bioball bioball left a 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.

Comment on lines +25 to +28
static final String TASK_GROUP_CODEGEN = "Code generation";

/** Gradle task group declared for documentation tasks. */
static final String TASK_GROUP_DOCS = "Documentation";
Copy link
Contributor

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.

Suggested change
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 {
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clear task names in Gradle plugin
3 participants