From f623921ff36d31ae840aae68cbeef0e02a15f6ad Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 27 Aug 2024 01:39:34 -0700 Subject: [PATCH] Cleaned up API to match bld operations and options APIs --- .idea/codeStyles/codeStyleConfig.xml | 5 + examples/lib/bld/bld-wrapper.properties | 2 +- .../extension/CheckstyleOperationBuild.java | 2 +- .../bld/extension/CheckstyleOperation.java | 136 +++++++++++++++--- .../extension/CheckstyleOperationTest.java | 22 ++- 5 files changed, 146 insertions(+), 21 deletions(-) create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..d91f848 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 14de935..960c1dd 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,7 +1,7 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-checkstyle=com.uwyn.rife2:bld-checkstyle:1.0.3 +bld.extension-checkstyle=com.uwyn.rife2:bld-checkstyle:1.0.4-SNAPSHOT bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.sourceDirectories= bld.version=2.0.1 diff --git a/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java b/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java index 73d0ad3..9506bc8 100644 --- a/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java @@ -33,7 +33,7 @@ public class CheckstyleOperationBuild extends Project { public CheckstyleOperationBuild() { pkg = "rife.bld.extension"; name = "CheckstyleOperation"; - version = version(1, 0, 3); + version = version(1, 0, 4, "SNAPSHOT"); javaRelease = 17; downloadSources = true; diff --git a/src/main/java/rife/bld/extension/CheckstyleOperation.java b/src/main/java/rife/bld/extension/CheckstyleOperation.java index 41b72f9..0322640 100644 --- a/src/main/java/rife/bld/extension/CheckstyleOperation.java +++ b/src/main/java/rife/bld/extension/CheckstyleOperation.java @@ -23,6 +23,7 @@ import rife.bld.operations.exceptions.ExitStatusException; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; @@ -83,6 +84,18 @@ public class CheckstyleOperation extends AbstractProcessOperation paths) { + return exclude(paths.stream().map(Path::toFile).toList()); + } + /** * Directory/file pattern to exclude from CheckStyle. Multiple exclude are allowed. * @@ -161,6 +196,19 @@ public class CheckstyleOperation extends AbstractProcessOperation paths) { + exclude_.addAll(paths.stream().map(File::new).toList()); + return this; + } + @Override public void execute() throws IOException, InterruptedException, ExitStatusException { if (project_ == null) { @@ -284,6 +332,13 @@ public class CheckstyleOperation extends AbstractProcessOperation + * Defaults to stdout. + * + * @param file the output file + * @return the checkstyle operation + */ + public CheckstyleOperation outputPath(Path file) { + return outputPath(file.toFile()); + } + /** * Sets the property files to load. * @@ -360,16 +427,25 @@ public class CheckstyleOperation extends AbstractProcessOperation dirs) { sourceDir_.addAll(dirs); @@ -405,6 +491,29 @@ public class CheckstyleOperation extends AbstractProcessOperation dirs) { + return sourceDir(dirs.stream().map(Path::toFile).toList()); + } + + /** + * Specified the file(s) or folder(s) containing the source files to check. + * + * @param dirs the directories + * @return the checkstyle operation + * @see #sourceDir(String...) + */ + public CheckstyleOperation sourceDirStrings(Collection dirs) { + sourceDir_.addAll(dirs.stream().map(File::new).toList()); + return this; + } + /** * Prints xpath suppressions at the file's line and column position. Argument is the line and column number * (separated by a {@code :} ) in the file that the suppression should be generated for. The option cannot be @@ -485,11 +594,4 @@ public class CheckstyleOperation extends AbstractProcessOperation