From 4f6ebfea487d48c40c803846139a3f218b4df836 Mon Sep 17 00:00:00 2001 From: Sam Gammon Date: Sun, 18 Feb 2024 12:47:14 -0800 Subject: [PATCH] Add summaries and groups to gradle tasks Fixes and closes apple/pkl#188 by adding task names and groups to major Pkl Gradle Plugin tasks Signed-off-by: Sam Gammon --- .../main/java/org/pkl/gradle/PklPlugin.java | 13 ++++++- .../java/org/pkl/gradle/TaskConstants.java | 38 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 pkl-gradle/src/main/java/org/pkl/gradle/TaskConstants.java diff --git a/pkl-gradle/src/main/java/org/pkl/gradle/PklPlugin.java b/pkl-gradle/src/main/java/org/pkl/gradle/PklPlugin.java index 23741970b..6c195e819 100644 --- a/pkl-gradle/src/main/java/org/pkl/gradle/PklPlugin.java +++ b/pkl-gradle/src/main/java/org/pkl/gradle/PklPlugin.java @@ -171,6 +171,8 @@ private void configureJavaCodeGenTasks(NamedDomainObjectContainer { + task.setDescription(TaskConstants.GENERATE_JAVA_DESCRIPTION); + task.setGroup(TaskConstants.TASK_GROUP_CODEGEN); configureCodeGenTask(task, spec); task.getGenerateGetters().set(spec.getGenerateGetters()); task.getGenerateJavadoc().set(spec.getGenerateJavadoc()); @@ -200,6 +202,8 @@ private void configureKotlinCodeGenTasks(NamedDomainObjectContainer { + task.setDescription(TaskConstants.GENERATE_KOTLIN_DESCRIPTION); + task.setGroup(TaskConstants.TASK_GROUP_CODEGEN); configureCodeGenTask(task, spec); task.getGenerateKdoc().set(spec.getGenerateKdoc()); }); @@ -228,7 +232,12 @@ private void configurePkldocTasks(NamedDomainObjectContainer specs) .map(it -> it.dir("pkldoc").dir(spec.getName()))); createModulesTask(PkldocTask.class, spec) - .configure(task -> task.getOutputDir().set(spec.getOutputDir())); + .configure( + task -> { + task.setDescription(TaskConstants.GENERATE_PKLDOC_DESCRIPTION); + task.setGroup(TaskConstants.TASK_GROUP_DOCS); + task.getOutputDir().set(spec.getOutputDir()); + }); }); } @@ -242,6 +251,8 @@ private void configureTestTasks(NamedDomainObjectContainer specs) { var testTask = createModulesTask(TestTask.class, spec); testTask.configure( task -> { + task.setDescription(TaskConstants.GENERATE_PKLDOC_DESCRIPTION); + task.setGroup(TaskConstants.TASK_GROUP_DOCS); task.getJunitReportsDir().set(spec.getJunitReportsDir()); task.getOverwrite().set(spec.getOverwrite()); }); diff --git a/pkl-gradle/src/main/java/org/pkl/gradle/TaskConstants.java b/pkl-gradle/src/main/java/org/pkl/gradle/TaskConstants.java new file mode 100644 index 000000000..01beaa7de --- /dev/null +++ b/pkl-gradle/src/main/java/org/pkl/gradle/TaskConstants.java @@ -0,0 +1,38 @@ +/** + * Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pkl.gradle; + +/** Constant values used by tasks */ +class TaskConstants { + private TaskConstants() { + /* no construction */ + } + + /** 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"; +}