diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml
index bf65051..6966bcb 100644
--- a/.github/workflows/bld.yml
+++ b/.github/workflows/bld.yml
@@ -1,14 +1,16 @@
name: bld-ci
-on: [push, pull_request, workflow_dispatch]
+on: [ push, pull_request, workflow_dispatch ]
jobs:
build-bld-project:
- runs-on: ubuntu-latest
-
strategy:
matrix:
- java-version: [17, 21, 22]
+ java-version: [ 17, 21, 24 ]
+ kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ]
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
+
+ runs-on: ${{ matrix.os }}
steps:
- name: Checkout source repository
@@ -22,8 +24,16 @@ jobs:
distribution: "zulu"
java-version: ${{ matrix.java-version }}
+ - name: Download dependencies [examples]
+ working-directory: examples
+ run: ./bld download
+
+ - name: Compile and Run Checkstyle [examples]
+ working-directory: examples
+ run: ./bld compile checkstyle-custom
+
- name: Download dependencies
run: ./bld download
- name: Run tests
- run: ./bld compile test
+ run: ./bld compile test
\ No newline at end of file
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
index bf43624..508f6a5 100644
--- a/.github/workflows/pages.yml
+++ b/.github/workflows/pages.yml
@@ -47,11 +47,11 @@ jobs:
uses: actions/configure-pages@v3
- name: Upload artifact
- uses: actions/upload-pages-artifact@v1
+ uses: actions/upload-pages-artifact@v3
with:
# Upload generated Javadocs repository
path: "build/javadoc/"
- name: Deploy to GitHub Pages
id: deployment
- uses: actions/deploy-pages@v1
+ uses: actions/deploy-pages@v4
diff --git a/.idea/bld.xml b/.idea/bld.xml
new file mode 100644
index 0000000..6600cee
--- /dev/null
+++ b/.idea/bld.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
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/.idea/icon.svg b/.idea/icon.svg
new file mode 100644
index 0000000..81220b4
--- /dev/null
+++ b/.idea/icon.svg
@@ -0,0 +1,13 @@
+
+
+
diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml
index 4dd96bf..153a060 100644
--- a/.idea/libraries/bld.xml
+++ b/.idea/libraries/bld.xml
@@ -2,12 +2,12 @@
-
+
-
+
diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml
index 9bd86aa..99cc0c0 100644
--- a/.idea/libraries/compile.xml
+++ b/.idea/libraries/compile.xml
@@ -7,7 +7,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml
index 2ae5c4b..d4069f2 100644
--- a/.idea/libraries/runtime.xml
+++ b/.idea/libraries/runtime.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml
index b80486a..57ed5ef 100644
--- a/.idea/libraries/test.xml
+++ b/.idea/libraries/test.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 5422c5f..ce89108 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -9,7 +9,7 @@
],
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
- "${HOME}/.bld/dist/bld-2.0.1.jar",
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
"lib/**/*.jar"
],
"java.compile.nullAnalysis.mode": "automatic"
diff --git a/README.md b/README.md
index 0bb407c..abf2d99 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,20 @@
[](https://opensource.org/licenses/Apache-2.0)
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
-[](https://rife2.com/bld)
+[](https://rife2.com/bld)
[](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-checkstyle)
[](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-checkstyle)
[](https://github.com/rife2/bld-checkstyle/actions/workflows/bld.yml)
-To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions).
+To install the latest version, add the following to the `lib/bld/bld-wrapper.properties` file:
+
+```properties
+bld.extension-checkstyle=com.uwyn.rife2:bld-checkstyle
+```
+
+For more information, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) documentation.
+
+## Check Source Code with Checkstyle
To check your code with Chesktyle, include the following in your build file:
@@ -37,5 +45,5 @@ not provided by the extension. For example:
```java
repositories = List.of(MAVEN_CENTRAL);
-scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 17, 0)));
+scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 23, 0)));
```
diff --git a/config/pmd.xml b/config/pmd.xml
index 3d3203c..2641880 100644
--- a/config/pmd.xml
+++ b/config/pmd.xml
@@ -7,9 +7,9 @@
-
-
+
+
diff --git a/examples/.idea/libraries/bld.xml b/examples/.idea/libraries/bld.xml
index 4dd96bf..153a060 100644
--- a/examples/.idea/libraries/bld.xml
+++ b/examples/.idea/libraries/bld.xml
@@ -2,12 +2,12 @@
-
+
-
+
diff --git a/examples/.idea/libraries/compile.xml b/examples/.idea/libraries/compile.xml
index 9bd86aa..99cc0c0 100644
--- a/examples/.idea/libraries/compile.xml
+++ b/examples/.idea/libraries/compile.xml
@@ -7,7 +7,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/.idea/libraries/runtime.xml b/examples/.idea/libraries/runtime.xml
index 2ae5c4b..d4069f2 100644
--- a/examples/.idea/libraries/runtime.xml
+++ b/examples/.idea/libraries/runtime.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/.idea/libraries/test.xml b/examples/.idea/libraries/test.xml
index b80486a..57ed5ef 100644
--- a/examples/.idea/libraries/test.xml
+++ b/examples/.idea/libraries/test.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/examples/.vscode/settings.json b/examples/.vscode/settings.json
index 5b2667b..ba429d0 100644
--- a/examples/.vscode/settings.json
+++ b/examples/.vscode/settings.json
@@ -9,7 +9,7 @@
],
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
- "${HOME}/.bld/dist/bld-2.0.1.jar",
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
"lib/**/*.jar"
]
}
diff --git a/examples/lib/bld/bld-wrapper.jar b/examples/lib/bld/bld-wrapper.jar
index 4579129..862a228 100644
Binary files a/examples/lib/bld/bld-wrapper.jar and b/examples/lib/bld/bld-wrapper.jar differ
diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties
index 66ee51a..ab1936c 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.2
+bld.extension-checkstyle=com.uwyn.rife2:bld-checkstyle:1.0.14
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories=
-bld.version=2.0.1
+bld.version=2.2.1
diff --git a/examples/src/bld/java/com/example/ExamplesBuild.java b/examples/src/bld/java/com/example/ExamplesBuild.java
index f271cb5..af647ee 100644
--- a/examples/src/bld/java/com/example/ExamplesBuild.java
+++ b/examples/src/bld/java/com/example/ExamplesBuild.java
@@ -5,6 +5,9 @@ import rife.bld.BuildCommand;
import rife.bld.extension.CheckstyleOperation;
import java.util.List;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
import static rife.bld.dependencies.Scope.*;
@@ -20,19 +23,29 @@ public class ExamplesBuild extends BaseProject {
autoDownloadPurge = true;
downloadSources = true;
-
+
repositories = List.of(MAVEN_CENTRAL);
- scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 17, 0)));
+ scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 23, 0)));
testOperation().mainClass("com.example.ExamplesTest");
}
public static void main(String[] args) {
+ // Enable detailed logging for the extensions
+ var level = Level.ALL;
+ var logger = Logger.getLogger("rife.bld.extension");
+ var consoleHandler = new ConsoleHandler();
+
+ consoleHandler.setLevel(level);
+ logger.addHandler(consoleHandler);
+ logger.setLevel(level);
+ logger.setUseParentHandlers(false);
+
new ExamplesBuild().start(args);
}
- @BuildCommand(summary = "Check code style")
+ @BuildCommand(summary = "Check code style using Sun coding conventions")
public void checkstyle() throws Exception {
new CheckstyleOperation()
.fromProject(this)
@@ -40,4 +53,11 @@ public class ExamplesBuild extends BaseProject {
.execute();
}
+ @BuildCommand(value = "checkstyle-custom", summary = "Check code style using custom coding conventions")
+ public void checkstyleCustom() throws Exception {
+ new CheckstyleOperation()
+ .fromProject(this)
+ .configurationFile("src/test/resources/checkstyle.xml")
+ .execute();
+ }
}
diff --git a/examples/src/test/resources/checkstyle.xml b/examples/src/test/resources/checkstyle.xml
new file mode 100644
index 0000000..e601ecb
--- /dev/null
+++ b/examples/src/test/resources/checkstyle.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar
index 1934a36..ee9e249 100644
Binary files a/lib/bld/bld-wrapper.jar and b/lib/bld/bld-wrapper.jar differ
diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties
index 79b2f59..2b5c0ac 100644
--- a/lib/bld/bld-wrapper.properties
+++ b/lib/bld/bld-wrapper.properties
@@ -1,8 +1,8 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.downloadLocation=
-bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.2
-bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.4
+bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5
+bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.2
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories=
-bld.version=2.0.1
+bld.version=2.2.1
diff --git a/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java b/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java
index b75b15d..dc827f2 100644
--- a/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java
+++ b/src/bld/java/rife/bld/extension/CheckstyleOperationBuild.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023-2024 the original author or authors.
+ * Copyright 2023-2025 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.
@@ -23,6 +23,7 @@ import rife.bld.publish.PublishLicense;
import rife.bld.publish.PublishScm;
import java.util.List;
+import java.util.Locale;
import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.Scope.compile;
@@ -33,20 +34,23 @@ public class CheckstyleOperationBuild extends Project {
public CheckstyleOperationBuild() {
pkg = "rife.bld.extension";
name = "CheckstyleOperation";
- version = version(1, 0, 2);
+ version = version(1, 0, 15, "SNAPSHOT");
javaRelease = 17;
+
downloadSources = true;
autoDownloadPurge = true;
+
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);
scope(compile)
- .include(dependency("com.uwyn.rife2", "bld", version(2, 0, 1)));
+ .include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1)));
scope(test)
- .include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 17, 0)))
- .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3)))
- .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 3)))
- .include(dependency("org.assertj", "assertj-core", version(3, 26, 3)));
+ .include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 23, 0)))
+ .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1)))
+ .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1)))
+ .include(dependency("org.assertj", "assertj-core", version(3, 27, 3)));
+
javadocOperation()
.javadocOptions()
.author()
@@ -56,28 +60,26 @@ public class CheckstyleOperationBuild extends Project {
publishOperation()
.repository(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2"))
+ .repository(repository("github"))
.info()
.groupId("com.uwyn.rife2")
.artifactId("bld-checkstyle")
.description("bld Checkstyle Extension")
.url("https://github.com/rife2/bld-checkstyle")
- .developer(
- new PublishDeveloper()
- .id("ethauvin")
- .name("Erik C. Thauvin")
- .email("erik@thauvin.net")
- .url("https://erik.thauvin.net/")
+ .developer(new PublishDeveloper()
+ .id("ethauvin")
+ .name("Erik C. Thauvin")
+ .email("erik@thauvin.net")
+ .url("https://erik.thauvin.net/")
)
- .license(
- new PublishLicense()
- .name("The Apache License, Version 2.0")
- .url("https://www.apache.org/licenses/LICENSE-2.0.txt")
+ .license(new PublishLicense()
+ .name("The Apache License, Version 2.0")
+ .url("https://www.apache.org/licenses/LICENSE-2.0.txt")
)
- .scm(
- new PublishScm()
- .connection("scm:git:https://github.com/rife2/bld-checkstyle.git")
- .developerConnection("scm:git:git@github.com:rife2/bld-checkstyle.git")
- .url("https://github.com/rife2/bld-checkstyle")
+ .scm(new PublishScm()
+ .connection("scm:git:https://github.com/rife2/bld-checkstyle.git")
+ .developerConnection("scm:git:git@github.com:rife2/bld-checkstyle.git")
+ .url("https://github.com/rife2/bld-checkstyle")
)
.signKey(property("sign.key"))
.signPassphrase(property("sign.passphrase"));
@@ -98,10 +100,13 @@ public class CheckstyleOperationBuild extends Project {
@Override
public void test() throws Exception {
- new ExecOperation()
- .fromProject(this)
- .command("scripts/cliargs.sh")
- .execute();
+ var os = System.getProperty("os.name");
+ if (os != null && os.toLowerCase(Locale.US).contains("linux")) {
+ new ExecOperation()
+ .fromProject(this)
+ .command("scripts/cliargs.sh")
+ .execute();
+ }
super.test();
}
}
diff --git a/src/main/java/rife/bld/extension/CheckstyleOperation.java b/src/main/java/rife/bld/extension/CheckstyleOperation.java
index 7959d0b..97eeb55 100644
--- a/src/main/java/rife/bld/extension/CheckstyleOperation.java
+++ b/src/main/java/rife/bld/extension/CheckstyleOperation.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023-2024 the original author or authors.
+ * Copyright 2023-2025 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.
@@ -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;
@@ -84,7 +85,19 @@ public class CheckstyleOperation extends AbstractProcessOperation paths) {
exclude_.addAll(paths);
@@ -138,19 +161,30 @@ 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.
*
* @param regex the pattern to exclude
* @return the checkstyle operation
* @see #excludeRegex(Collection)
*/
public CheckstyleOperation excludeRegex(String... regex) {
- excludeRegex_.addAll(List.of(regex));
- return this;
+ return excludeRegex(List.of(regex));
}
/**
- * Directory/file pattern to exclude from CheckStyle. Multiple exclude are allowed.
+ * Directory/file pattern to exclude from Checkstyle. Multiple exclude are allowed.
*
* @param regex the patterns to exclude
* @return the checkstyle operation
@@ -161,6 +195,18 @@ public class CheckstyleOperation extends AbstractProcessOperation paths) {
+ return exclude(paths.stream().map(File::new).toList());
+ }
+
@Override
public void execute() throws IOException, InterruptedException, ExitStatusException {
if (project_ == null) {
@@ -189,9 +235,9 @@ public class CheckstyleOperation extends AbstractProcessOperation {
@@ -204,7 +250,8 @@ 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().getAbsolutePath());
+ }
+
/**
* Sets the property files to load.
*
@@ -368,35 +428,54 @@ public class CheckstyleOperation extends AbstractProcessOperation dirs) {
sourceDir_.addAll(dirs);
@@ -412,6 +491,28 @@ public class CheckstyleOperation extends AbstractProcessOperation dirs) {
+ return sourceDir(dirs.stream().map(Path::toFile).toList());
+ }
+
+ /**
+ * Specifies 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) {
+ return sourceDir(dirs.stream().map(File::new).toList());
+ }
+
/**
* 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
diff --git a/src/main/java/rife/bld/extension/checkstyle/OutputFormat.java b/src/main/java/rife/bld/extension/checkstyle/OutputFormat.java
index c37a585..0ba8021 100644
--- a/src/main/java/rife/bld/extension/checkstyle/OutputFormat.java
+++ b/src/main/java/rife/bld/extension/checkstyle/OutputFormat.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023-2024 the original author or authors.
+ * Copyright 2023-2025 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.
@@ -17,7 +17,7 @@
package rife.bld.extension.checkstyle;
/**
- * The Checkstyle output format for XML, sarif and default (plaib) logger.
+ * The Checkstyle output format for XML, sarif and default (plain) logger.
*/
public enum OutputFormat {
XML("xml"),
@@ -26,6 +26,9 @@ public enum OutputFormat {
public final String label;
+ /**
+ * Sets the label of this output format.
+ */
OutputFormat(String label) {
this.label = label;
}
diff --git a/src/test/java/rife/bld/extension/CheckstyleOperationTest.java b/src/test/java/rife/bld/extension/CheckstyleOperationTest.java
index 578846f..0d0e1b2 100644
--- a/src/test/java/rife/bld/extension/CheckstyleOperationTest.java
+++ b/src/test/java/rife/bld/extension/CheckstyleOperationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2023-2024 the original author or authors.
+ * Copyright 2023-2025 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.
@@ -16,8 +16,11 @@
package rife.bld.extension;
+import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import rife.bld.BaseProject;
import rife.bld.Project;
import rife.bld.WebProject;
@@ -27,6 +30,7 @@ import rife.bld.operations.exceptions.ExitStatusException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.logging.ConsoleHandler;
@@ -36,7 +40,6 @@ import java.util.logging.Logger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
-
class CheckstyleOperationTest {
public static final String SRC_MAIN_JAVA = "src/main/java";
public static final String SRC_TEST_JAVA = "src/test/java";
@@ -64,6 +67,7 @@ class CheckstyleOperationTest {
}
@Test
+ @EnabledOnOs(OS.LINUX)
void checkAllParameters() throws IOException {
var args = Files.readAllLines(Paths.get("src", "test", "resources", "checkstyle-args.txt"));
@@ -89,15 +93,17 @@ class CheckstyleOperationTest {
.treeWithJavadoc(true)
.executeConstructProcessCommandList();
- for (var p : args) {
- var found = false;
- for (var a : params) {
- if (a.startsWith(p)) {
- found = true;
- break;
+ try (var softly = new AutoCloseableSoftAssertions()) {
+ for (var p : args) {
+ var found = false;
+ for (var a : params) {
+ if (a.startsWith(p)) {
+ found = true;
+ break;
+ }
}
+ softly.assertThat(found).as(p + " not found.").isTrue();
}
- assertThat(found).as(p + " not found.").isTrue();
}
}
@@ -119,17 +125,30 @@ class CheckstyleOperationTest {
void exclude() {
var foo = new File(SRC_MAIN_JAVA);
var bar = new File(SRC_TEST_JAVA);
- var op = new CheckstyleOperation().fromProject(new Project()).exclude(SRC_MAIN_JAVA, SRC_TEST_JAVA);
var e = "-e ";
- assertThat(op.executeConstructProcessCommandList()).as("strings")
+
+ var op = new CheckstyleOperation().fromProject(new Project()).exclude(SRC_MAIN_JAVA, SRC_TEST_JAVA);
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("String...")
+ .contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
+
+ op = new CheckstyleOperation().fromProject(new Project()).excludeStrings(List.of(SRC_MAIN_JAVA, SRC_TEST_JAVA));
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("List(String...)")
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
op = new CheckstyleOperation().fromProject(new Project()).exclude(foo, bar);
- assertThat(op.executeConstructProcessCommandList()).as("files")
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("File...")
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(foo, bar));
- assertThat(op.executeConstructProcessCommandList()).as("list")
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("List(File...)")
+ .contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
+
+ op = new CheckstyleOperation().fromProject(new Project()).exclude(foo.toPath(), bar.toPath());
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("Path...")
+ .contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
+
+ op = new CheckstyleOperation().fromProject(new Project()).excludePaths(List.of(foo.toPath(), bar.toPath()));
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("List(Path...)")
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
}
@@ -137,10 +156,10 @@ class CheckstyleOperationTest {
void excludeRegex() {
var op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(FOO, BAR);
var x = "-x ";
- assertThat(op.executeConstructProcessCommandList()).contains(x + FOO, x + BAR);
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).contains(x + FOO, x + BAR);
op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(List.of(FOO, BAR));
- assertThat(op.executeConstructProcessCommandList()).as("as list").contains(x + FOO, x + BAR);
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("as list").contains(x + FOO, x + BAR);
}
@Test
@@ -150,18 +169,12 @@ class CheckstyleOperationTest {
var op = new CheckstyleOperation()
.fromProject(new WebProject())
.sourceDir(SRC_MAIN_JAVA, SRC_TEST_JAVA)
- .configurationFile("src/test/resources/google_checks.xml")
- .outputPath(tmpFile.getAbsolutePath());
+ .configurationFile(Path.of("src/test/resources/google_checks.xml"))
+ .outputPath(tmpFile.toPath());
op.execute();
assertThat(tmpFile).exists();
}
- @Test
- void executeNoProject() {
- var op = new CheckstyleOperation();
- assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
- }
-
@Test
void executeConstructProcessCommandList() {
var op = new CheckstyleOperation().fromProject(new BaseProject())
@@ -191,6 +204,12 @@ class CheckstyleOperationTest {
assertThat(op.options().containsKey("-E")).as(REMOVE).isFalse();
}
+ @Test
+ void executeNoProject() {
+ var op = new CheckstyleOperation();
+ assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
+ }
+
@Test
void executeSunChecks() throws IOException {
var tmpFile = File.createTempFile("checkstyle-sun", ".txt");
@@ -236,6 +255,10 @@ class CheckstyleOperationTest {
void propertiesFile() {
var op = new CheckstyleOperation().fromProject(new Project()).propertiesFile(FOO);
assertThat(op.options().get("-p")).isEqualTo(FOO);
+
+ var fooPath = Path.of(FOO);
+ op = op.propertiesFile(fooPath);
+ assertThat(op.options().get("-p")).isEqualTo(fooPath.toFile().getAbsolutePath());
}
@Test
@@ -243,18 +266,32 @@ class CheckstyleOperationTest {
var foo = new File(FOO);
var bar = new File(BAR);
- var op = new CheckstyleOperation().fromProject(new Project()).sourceDir(FOO);
- assertThat(op.sourceDir()).contains(foo);
+ var op = new CheckstyleOperation().fromProject(new Project()).sourceDir(FOO, BAR);
+ assertThat(op.sourceDir()).as("String...").hasSize(2).contains(foo, bar);
+ op.sourceDir().clear();
+
+ op = op.sourceDirStrings(List.of(FOO, BAR));
+ assertThat(op.sourceDir()).as("List(String...)").hasSize(2).contains(foo, bar);
+ op.sourceDir().clear();
op = op.sourceDir(foo, bar);
- assertThat(op.sourceDir()).as("foo, bar").hasSize(2)
- .contains(foo).contains(bar);
+ assertThat(op.sourceDir()).as("File...").hasSize(2).contains(foo, bar);
+ op.sourceDir().clear();
op = op.sourceDir(List.of(foo, bar));
- assertThat(op.sourceDir()).as("List.of(foo, bar)").hasSize(2)
- .contains(foo).contains(bar);
+ assertThat(op.sourceDir()).as("List(File...)").hasSize(2).contains(foo, bar);
+ op.sourceDir().clear();
+
+ op = op.sourceDir(foo.toPath(), bar.toPath());
+ assertThat(op.sourceDir()).as("Path...").hasSize(2).contains(foo, bar);
+ op.sourceDir().clear();
+
+ op = op.sourceDirPaths(List.of(foo.toPath(), bar.toPath()));
+ assertThat(op.sourceDir()).as("List(Path...)").hasSize(2).contains(foo, bar);
+ op.sourceDir().clear();
}
+
@Test
void suppressionLineColumnNumber() {
var op = new CheckstyleOperation().fromProject(new Project()).suppressionLineColumnNumber(FOO + ':' + BAR);