diff --git a/.idea/copyright/Apache_License.xml b/.idea/copyright/Apache_License.xml index 4446c15..ade80da 100644 --- a/.idea/copyright/Apache_License.xml +++ b/.idea/copyright/Apache_License.xml @@ -1,6 +1,6 @@ - - \ No newline at end of file + diff --git a/README.md b/README.md index 49b1a8b..c223a6e 100644 --- a/README.md +++ b/README.md @@ -37,5 +37,5 @@ not provided by the extension. For example: ```java repositories = List.of(MAVEN_CENTRAL); -scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 16, 0))); +scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 15, 0))); ``` diff --git a/checkcliargs.sh b/checkcliargs.sh index 867c768..1e271db 100755 --- a/checkcliargs.sh +++ b/checkcliargs.sh @@ -7,10 +7,6 @@ TMPOLD=/tmp/checkcliargs-old java -cp "lib/test/*" $MAIN --help >$TMPNEW java -cp "examples/lib/test/*" $MAIN --help >$TMPOLD -if [ "$1" == "-v" ]; then - code --wait --diff $TMPOLD $TMPNEW -else - diff $TMPOLD $TMPNEW -fi +diff $TMPOLD $TMPNEW rm -rf $TMPNEW $TMPOLD diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index eede168..b3d6546 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,6 +1,6 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true -bld.extensions=com.uwyn.rife2:bld-checkstyle:1.0.0 +bld.extensions=com.uwyn.rife2:bld-checkstyle:0.9.6 bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.downloadLocation= bld.sourceDirectories= diff --git a/examples/src/bld/java/com/example/ExamplesBuild.java b/examples/src/bld/java/com/example/ExamplesBuild.java index 52a2409..8900bce 100644 --- a/examples/src/bld/java/com/example/ExamplesBuild.java +++ b/examples/src/bld/java/com/example/ExamplesBuild.java @@ -16,14 +16,12 @@ public class ExamplesBuild extends BaseProject { mainClass = "com.example.ExamplesMain"; version = version(0, 1, 0); - javaRelease = 17; - autoDownloadPurge = true; downloadSources = true; repositories = List.of(MAVEN_CENTRAL); - scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 16, 0))); + scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 15, 0))); testOperation().mainClass("com.example.ExamplesTest"); } diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 13d377b..294731d 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -1,7 +1,7 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true -bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.9 -bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.5 +bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.8 +bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.3 bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.downloadLocation= bld.sourceDirectories= diff --git a/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java b/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java index 9b7c7d6..75dc620 100644 --- a/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java +++ b/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java @@ -35,7 +35,7 @@ public class CheckstyleOperationBuild extends Project { public CheckstyleOperationBuild() { pkg = "rife.bld.extension"; name = "CheckstyleOperation"; - version = version(1, 0, 0); + version = version(0, 9, 6); javaRelease = 17; downloadSources = true; @@ -45,7 +45,7 @@ public class CheckstyleOperationBuild extends Project { scope(compile) .include(dependency("com.uwyn.rife2", "bld", version(1, 9, 0))); scope(test) - .include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 16, 0))) + .include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 15, 0))) .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2))) .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2))) .include(dependency("org.assertj", "assertj-core", version(3, 25, 3))); diff --git a/src/main/java/rife/bld/extension/CheckstyleFormatOption.java b/src/main/java/rife/bld/extension/CheckstyleFormatOption.java deleted file mode 100644 index 09ad8ac..0000000 --- a/src/main/java/rife/bld/extension/CheckstyleFormatOption.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2023-2004 the original author or authors. - * - * 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 rife.bld.extension; - -/** - * The Checkstyle output format for XML, sarif and default (plaib) logger. - */ -public enum CheckstyleFormatOption { - XML("xml"), - SARIF("sarif"), - PLAIN("plain"); - - public final String label; - - CheckstyleFormatOption(String label) { - this.label = label; - } -} \ No newline at end of file diff --git a/src/main/java/rife/bld/extension/CheckstyleOperation.java b/src/main/java/rife/bld/extension/CheckstyleOperation.java index 7e07690..681e992 100644 --- a/src/main/java/rife/bld/extension/CheckstyleOperation.java +++ b/src/main/java/rife/bld/extension/CheckstyleOperation.java @@ -32,12 +32,11 @@ import java.util.logging.Logger; */ public class CheckstyleOperation extends AbstractProcessOperation { private static final Logger LOGGER = Logger.getLogger(CheckstyleOperation.class.getName()); - protected final List exclude = new ArrayList<>(); - protected final List excludeRegex = new ArrayList<>(); /** * The command line options. */ protected final Map options = new ConcurrentHashMap<>(); + /** * The source files(s) or folder(s). */ @@ -98,7 +97,7 @@ public class CheckstyleOperation extends AbstractProcessOperation paths) { for (var p : paths) { if (isNotBlank(p)) { - exclude.add(p); + options.put("-e", p); } } return this; } /** - * Directory/file pattern to exclude from CheckStyle. Multiple exclude are allowed. + * Directory/file pattern to exclude from CheckStyle. Multiple excludes are allowed. * - * @param regex the pattern to exclude + * @param pattern the pattern * @return the checkstyle operation - * @see #excludeRegex(Collection) */ - public CheckstyleOperation excludeRegex(String... regex) { - for (var r : regex) { - if (isNotBlank(r)) { - excludeRegex.add(r); - } + public CheckstyleOperation excludedPathPattern(String pattern) { + if (isNotBlank(pattern)) { + options.put("-x", pattern); } - - return this; - } - - /** - * Directory/file pattern to exclude from CheckStyle. Multiple exclude are allowed. - * - * @param regex the patterns to exclude - * @return the checkstyle operation - * @see #excludeRegex(String...) - */ - public CheckstyleOperation excludeRegex(Collection regex) { - for (var r : regex) { - if (isNotBlank(r)) { - excludeRegex.add(r); - } - } - return this; } @@ -184,22 +162,6 @@ public class CheckstyleOperation extends AbstractProcessOperation - * Defaults to {@link CheckstyleFormatOption#PLAIN}. + * Specifies the output format. Valid values: {@code xml}, {@code sarif}, {@code plain} for the XML, sarif and + * default logger respectively. Defaults to {@code plain}. * - * @param format the output format + * @param format the format * @return the checkstyle operation */ - public CheckstyleOperation format(CheckstyleFormatOption format) { - options.put("-f", format.label.toLowerCase()); + public CheckstyleOperation format(String format) { + if (isNotBlank(format)) { + options.put("-f", format); + } return this; } @@ -248,7 +209,7 @@ public class CheckstyleOperation extends AbstractProcessOperationonly Javadoc comment content + * without including '/**' and '*/' at the beginning and at the end respectively. The option cannot + * be used other options and requires exactly one file to run on to be specified. * * @param isTree {@code true} or {@code false} * @return the checkstyle operation @@ -287,14 +248,31 @@ public class CheckstyleOperation extends AbstractProcessOperation - * Defaults to stdout. + * ATTENTION: generated result will have few queries, joined by pipe(|). Together they will match all AST nodes + * on specified line and column. You need to choose only one and recheck that it works. Usage of all of them is also + * ok, but might result in undesirable matching and suppress other issues. * - * @param file the output file + * @param lineColumn the line column * @return the checkstyle operation */ - public CheckstyleOperation outputPath(String file) { + public CheckstyleOperation lineColumn(String lineColumn) { + if (isNotBlank(lineColumn)) { + options.put("-s", lineColumn); + } + return this; + } + + /** + * Sets the output file. Defaults to stdout. + * + * @param file the file + * @return the checkstyle operation + */ + public CheckstyleOperation output(String file) { if (isNotBlank(file)) { options.put("-o", file); } @@ -339,28 +317,7 @@ public class CheckstyleOperation extends AbstractProcessOperation - * Note that the generated result will have few queries, joined by pipe({@code |}). Together they will match all - * AST nodes on specified line and column. You need to choose only one and recheck that it works. Usage of all of - * them is also ok, but might result in undesirable matching and suppress other issues. - * - * @param lineColumnNumber the line column number - * @return the checkstyle operation - */ - public CheckstyleOperation suppressionLineColumnNumber(String lineColumnNumber) { - if (isNotBlank(lineColumnNumber)) { - options.put("-s", lineColumnNumber); - } - return this; - } - - /** - * Sets the length of the tab character. Used only with the - * {@link #suppressionLineColumnNumber(String) suppressionLineColumnNumber} option. - *

+ * Sets the length of the tab character. Used only with the {@link #lineColumn(String) lineColum} option. * Default value is {@code 8}. * * @param length the length @@ -372,8 +329,8 @@ public class CheckstyleOperation extends AbstractProcessOperation