Minor cleanups
This commit is contained in:
parent
c93c9ea2d0
commit
0a2a2f4b03
2 changed files with 38 additions and 27 deletions
|
@ -93,7 +93,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
* @return the checkstyle operation
|
* @return the checkstyle operation
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation configurationFile(Path file) {
|
public CheckstyleOperation configurationFile(Path file) {
|
||||||
return configurationFile(file.toFile());
|
return configurationFile(file.toFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +117,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
*
|
*
|
||||||
* @param path one or more paths
|
* @param path one or more paths
|
||||||
* @return the checkstyle operation
|
* @return the checkstyle operation
|
||||||
* @see #sourceDir(Collection)
|
* @see #excludeStrings(Collection)
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation exclude(String... path) {
|
public CheckstyleOperation exclude(String... path) {
|
||||||
return excludeStrings(List.of(path));
|
return excludeStrings(List.of(path));
|
||||||
|
@ -129,7 +129,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
*
|
*
|
||||||
* @param path one or more paths
|
* @param path one or more paths
|
||||||
* @return the checkstyle operation
|
* @return the checkstyle operation
|
||||||
* @see #sourceDir(Collection)
|
* @see #exclude(Collection)
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation exclude(File... path) {
|
public CheckstyleOperation exclude(File... path) {
|
||||||
return exclude(List.of(path));
|
return exclude(List.of(path));
|
||||||
|
@ -141,7 +141,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
*
|
*
|
||||||
* @param path one or more paths
|
* @param path one or more paths
|
||||||
* @return the checkstyle operation
|
* @return the checkstyle operation
|
||||||
* @see #sourceDir(Collection)
|
* @see #excludePaths(Collection)
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation exclude(Path... path) {
|
public CheckstyleOperation exclude(Path... path) {
|
||||||
return excludePaths(List.of(path));
|
return excludePaths(List.of(path));
|
||||||
|
@ -153,7 +153,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
*
|
*
|
||||||
* @param paths the paths
|
* @param paths the paths
|
||||||
* @return the checkstyle operation
|
* @return the checkstyle operation
|
||||||
* @see #exclude(String...)
|
* @see #exclude(File...)
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation exclude(Collection<File> paths) {
|
public CheckstyleOperation exclude(Collection<File> paths) {
|
||||||
exclude_.addAll(paths);
|
exclude_.addAll(paths);
|
||||||
|
@ -166,7 +166,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
*
|
*
|
||||||
* @param paths the paths
|
* @param paths the paths
|
||||||
* @return the checkstyle operation
|
* @return the checkstyle operation
|
||||||
* @see #exclude(String...)
|
* @see #exclude(Path...)
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation excludePaths(Collection<Path> paths) {
|
public CheckstyleOperation excludePaths(Collection<Path> paths) {
|
||||||
return exclude(paths.stream().map(Path::toFile).toList());
|
return exclude(paths.stream().map(Path::toFile).toList());
|
||||||
|
@ -180,8 +180,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
* @see #excludeRegex(Collection)
|
* @see #excludeRegex(Collection)
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation excludeRegex(String... regex) {
|
public CheckstyleOperation excludeRegex(String... regex) {
|
||||||
excludeRegex_.addAll(List.of(regex));
|
return excludeRegex(List.of(regex));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,8 +204,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
* @see #exclude(String...)
|
* @see #exclude(String...)
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation excludeStrings(Collection<String> paths) {
|
public CheckstyleOperation excludeStrings(Collection<String> paths) {
|
||||||
exclude_.addAll(paths.stream().map(File::new).toList());
|
return exclude(paths.stream().map(File::new).toList());
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -401,7 +399,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
* @return the checkstyle operation
|
* @return the checkstyle operation
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation outputPath(Path file) {
|
public CheckstyleOperation outputPath(Path file) {
|
||||||
return outputPath(file.toFile());
|
return outputPath(file.toFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -434,7 +432,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
* @return the checkstyle operation
|
* @return the checkstyle operation
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation propertiesFile(Path file) {
|
public CheckstyleOperation propertiesFile(Path file) {
|
||||||
return propertiesFile(file.toFile());
|
return propertiesFile(file.toFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -510,8 +508,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
* @see #sourceDir(String...)
|
* @see #sourceDir(String...)
|
||||||
*/
|
*/
|
||||||
public CheckstyleOperation sourceDirStrings(Collection<String> dirs) {
|
public CheckstyleOperation sourceDirStrings(Collection<String> dirs) {
|
||||||
sourceDir_.addAll(dirs.stream().map(File::new).toList());
|
return sourceDir(dirs.stream().map(File::new).toList());
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -120,21 +120,30 @@ class CheckstyleOperationTest {
|
||||||
void exclude() {
|
void exclude() {
|
||||||
var foo = new File(SRC_MAIN_JAVA);
|
var foo = new File(SRC_MAIN_JAVA);
|
||||||
var bar = new File(SRC_TEST_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 ";
|
var e = "-e ";
|
||||||
assertThat(op.executeConstructProcessCommandList()).as("strings")
|
|
||||||
|
var op = new CheckstyleOperation().fromProject(new Project()).exclude(SRC_MAIN_JAVA, SRC_TEST_JAVA);
|
||||||
|
assertThat(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(op.executeConstructProcessCommandList()).as("List(String...)")
|
||||||
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
|
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
|
||||||
|
|
||||||
op = new CheckstyleOperation().fromProject(new Project()).exclude(foo, bar);
|
op = new CheckstyleOperation().fromProject(new Project()).exclude(foo, bar);
|
||||||
assertThat(op.executeConstructProcessCommandList()).as("files")
|
assertThat(op.executeConstructProcessCommandList()).as("File...")
|
||||||
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
|
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
|
||||||
|
|
||||||
op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(foo, bar));
|
op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(foo, bar));
|
||||||
assertThat(op.executeConstructProcessCommandList()).as("list")
|
assertThat(op.executeConstructProcessCommandList()).as("List(File...)")
|
||||||
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
|
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
|
||||||
|
|
||||||
op = new CheckstyleOperation().fromProject(new Project()).exclude(foo.toPath(), bar.toPath());
|
op = new CheckstyleOperation().fromProject(new Project()).exclude(foo.toPath(), bar.toPath());
|
||||||
assertThat(op.executeConstructProcessCommandList()).as("list")
|
assertThat(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(op.executeConstructProcessCommandList()).as("List(Path...)")
|
||||||
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
|
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,24 +261,29 @@ class CheckstyleOperationTest {
|
||||||
var foo = new File(FOO);
|
var foo = new File(FOO);
|
||||||
var bar = new File(BAR);
|
var bar = new File(BAR);
|
||||||
|
|
||||||
var op = new CheckstyleOperation().fromProject(new Project()).sourceDir(FOO);
|
var op = new CheckstyleOperation().fromProject(new Project()).sourceDir(FOO, BAR);
|
||||||
assertThat(op.sourceDir()).contains(foo);
|
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);
|
op = op.sourceDir(foo, bar);
|
||||||
assertThat(op.sourceDir()).as("foo, bar").hasSize(2)
|
assertThat(op.sourceDir()).as("File...").hasSize(2).contains(foo, bar);
|
||||||
.contains(foo).contains(bar);
|
|
||||||
op.sourceDir().clear();
|
op.sourceDir().clear();
|
||||||
|
|
||||||
op = op.sourceDir(List.of(foo, bar));
|
op = op.sourceDir(List.of(foo, bar));
|
||||||
assertThat(op.sourceDir()).as("List.of(foo, bar)").hasSize(2)
|
assertThat(op.sourceDir()).as("List(File...)").hasSize(2).contains(foo, bar);
|
||||||
.contains(foo).contains(bar);
|
|
||||||
op.sourceDir().clear();
|
op.sourceDir().clear();
|
||||||
|
|
||||||
op = op.sourceDir(foo.toPath(), bar.toPath());
|
op = op.sourceDir(foo.toPath(), bar.toPath());
|
||||||
assertThat(op.sourceDir()).as("foo.toPath(), bar.toPath()").hasSize(2)
|
assertThat(op.sourceDir()).as("Path...").hasSize(2).contains(foo, bar);
|
||||||
.contains(foo).contains(bar);
|
|
||||||
op.sourceDir().clear();
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue