From 965316a9e1c6a202d49a5aef4a02bd7805f7a322 Mon Sep 17 00:00:00 2001 From: Hunter Mellema Date: Tue, 19 Mar 2024 08:56:11 -0600 Subject: [PATCH] Move validate task to base plugin --- .../smithy/gradle/tasks/SmithyValidateTask.java | 17 +++++------------ .../amazon/smithy/gradle/SmithyJarPlugin.java | 3 +-- 2 files changed, 6 insertions(+), 14 deletions(-) rename {smithy-jar => smithy-base}/src/main/java/software/amazon/smithy/gradle/tasks/SmithyValidateTask.java (83%) diff --git a/smithy-jar/src/main/java/software/amazon/smithy/gradle/tasks/SmithyValidateTask.java b/smithy-base/src/main/java/software/amazon/smithy/gradle/tasks/SmithyValidateTask.java similarity index 83% rename from smithy-jar/src/main/java/software/amazon/smithy/gradle/tasks/SmithyValidateTask.java rename to smithy-base/src/main/java/software/amazon/smithy/gradle/tasks/SmithyValidateTask.java index e7cd947..c89cbe0 100644 --- a/smithy-jar/src/main/java/software/amazon/smithy/gradle/tasks/SmithyValidateTask.java +++ b/smithy-base/src/main/java/software/amazon/smithy/gradle/tasks/SmithyValidateTask.java @@ -42,21 +42,14 @@ public SmithyValidateTask(ObjectFactory objectFactory) { } /** - * Jar file to use as a source for the Smithy CLI validate command. + * Files to use as a sources for the Smithy CLI {@code validate} command. * - *

This is a required input for the {@link SmithyValidateTask}. In general - * this should be the output of a {@link org.gradle.jvm.tasks.Jar task}. For example: + *

This is a required input of the SmithyValidate task. * - *

-     *     Task jarTask = project.getTasks()
-     *      .getByName(JavaPlugin.JAR_TASK_NAME);
-     *     ...
-     *     validateTask.getJarToValidate().set(
-     *      jarTask.getOutputs().getFiles());
-     * 
+ * @return file collection to use as sources for the validate task. */ @InputFiles - public abstract Property getJarToValidate(); + public abstract Property getSources(); /** * Disable model discovery. @@ -107,7 +100,7 @@ public void execute() { // Set models to an empty collection so source models are not included in validation path. executeCliProcess("validate", extraArgs, - getJarToValidate().get(), + getSources().get(), getDisableModelDiscovery().get() ); } diff --git a/smithy-jar/src/main/java/software/amazon/smithy/gradle/SmithyJarPlugin.java b/smithy-jar/src/main/java/software/amazon/smithy/gradle/SmithyJarPlugin.java index df8cc27..1bdd06d 100644 --- a/smithy-jar/src/main/java/software/amazon/smithy/gradle/SmithyJarPlugin.java +++ b/smithy-jar/src/main/java/software/amazon/smithy/gradle/SmithyJarPlugin.java @@ -140,8 +140,7 @@ private void addJavaTasksForSourceSet(SourceSet sourceSet, SmithyBuildTask build // Only enable validation if the jar Task is also enabled validateTask.setEnabled(jarTask.getEnabled()); - - validateTask.getJarToValidate().set(jarTask.getOutputs().getFiles()); + validateTask.getSources().set(jarTask.getOutputs().getFiles()); validateTask.getAllowUnknownTraits().set(extension.getAllowUnknownTraits()); // Add to verification group, so this tasks shows up in the output of `gradle tasks`