Skip to content

Commit

Permalink
Add summaries and groups to gradle tasks
Browse files Browse the repository at this point in the history
Fixes and closes apple#188 by adding task names and groups to
major Pkl Gradle Plugin tasks

Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Feb 20, 2024
1 parent 277f1e0 commit 4f6ebfe
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkl-gradle/src/main/java/org/pkl/gradle/PklPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ private void configureJavaCodeGenTasks(NamedDomainObjectContainer<JavaCodeGenSpe
createModulesTask(JavaCodeGenTask.class, spec)
.configure(
task -> {
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());
Expand Down Expand Up @@ -200,6 +202,8 @@ private void configureKotlinCodeGenTasks(NamedDomainObjectContainer<KotlinCodeGe
createModulesTask(KotlinCodeGenTask.class, spec)
.configure(
task -> {
task.setDescription(TaskConstants.GENERATE_KOTLIN_DESCRIPTION);
task.setGroup(TaskConstants.TASK_GROUP_CODEGEN);
configureCodeGenTask(task, spec);
task.getGenerateKdoc().set(spec.getGenerateKdoc());
});
Expand Down Expand Up @@ -228,7 +232,12 @@ private void configurePkldocTasks(NamedDomainObjectContainer<PkldocSpec> 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());
});
});
}

Expand All @@ -242,6 +251,8 @@ private void configureTestTasks(NamedDomainObjectContainer<TestSpec> 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());
});
Expand Down
38 changes: 38 additions & 0 deletions pkl-gradle/src/main/java/org/pkl/gradle/TaskConstants.java
Original file line number Diff line number Diff line change
@@ -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";
}

0 comments on commit 4f6ebfe

Please sign in to comment.