Compare commits

..

No commits in common. "5526cfdcf4e3124139aa8c85c74a91e2ea142234" and "7d5b50641c69be0a0e805a4972e7a3e77ebd86af" have entirely different histories.

6 changed files with 24 additions and 55 deletions

View file

@ -28,9 +28,9 @@ jobs:
working-directory: examples working-directory: examples
run: ./bld download run: ./bld download
- name: Run Detekt [examples] - name: Run tests [examples]
working-directory: examples working-directory: examples
run: ./bld compile detekt run: ./bld compile test
- name: Download dependencies - name: Download dependencies
run: ./bld download run: ./bld download

View file

@ -1,7 +1,7 @@
bld.downloadExtensionJavadoc=false bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.downloadLocation= bld.downloadLocation=
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.9
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.sourceDirectories= bld.sourceDirectories=

View file

@ -46,14 +46,14 @@ public class ExampleBuild extends Project {
public static void main(String[] args) { public static void main(String[] args) {
// Enable detailed logging // Enable detailed logging
var level = Level.ALL; // var level = Level.ALL;
var logger = Logger.getLogger("rife.bld.extension"); // var logger = Logger.getLogger("rife.bld.extension");
var consoleHandler = new ConsoleHandler(); // var consoleHandler = new ConsoleHandler();
//
consoleHandler.setLevel(level); // consoleHandler.setLevel(level);
logger.addHandler(consoleHandler); // logger.addHandler(consoleHandler);
logger.setLevel(level); // logger.setLevel(level);
logger.setUseParentHandlers(false); // logger.setUseParentHandlers(false);
new ExampleBuild().start(args); new ExampleBuild().start(args);
} }

View file

@ -28,7 +28,6 @@ import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -56,8 +55,6 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
"snakeyaml-engine-", "snakeyaml-engine-",
"trove4j-"); "trove4j-");
private static final Logger LOGGER = Logger.getLogger(DetektOperation.class.getName()); private static final Logger LOGGER = Logger.getLogger(DetektOperation.class.getName());
private static final String OS_NAME =
System.getProperty("os.name") != null ? System.getProperty("os.name").toLowerCase(Locale.US) : null;
private final Collection<File> classpath_ = new ArrayList<>(); private final Collection<File> classpath_ = new ArrayList<>();
private final Collection<File> config_ = new ArrayList<>(); private final Collection<File> config_ = new ArrayList<>();
private final Collection<String> excludes_ = new ArrayList<>(); private final Collection<String> excludes_ = new ArrayList<>();
@ -293,17 +290,6 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
return classPath(paths.stream().map(File::new).toList()); return classPath(paths.stream().map(File::new).toList());
} }
private String cleanPath(File path) {
return cleanPath(path.getAbsolutePath());
}
private String cleanPath(String path) {
if (isWindows()) {
return path.replaceAll("\\\\", "\\\\\\\\");
}
return path;
}
/** /**
* Paths to the config files ({@code path/to/config.yml}). * Paths to the config files ({@code path/to/config.yml}).
* *
@ -337,6 +323,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
return configStrings(List.of(configs)); return configStrings(List.of(configs));
} }
/** /**
* Paths to the config files ({@code path/to/config.yml}). * Paths to the config files ({@code path/to/config.yml}).
* *
@ -538,13 +525,13 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
// base-path // base-path
if (isNotBlank(basePath_)) { if (isNotBlank(basePath_)) {
args.add("--base-path"); args.add("--base-path");
args.add(cleanPath(basePath_)); args.add(basePath_);
} }
// baseline // baseline
if (isNotBlank(baseline_)) { if (isNotBlank(baseline_)) {
args.add("--baseline"); args.add("--baseline");
args.add(cleanPath(baseline_)); args.add(baseline_);
} }
// build-upon-default-config // build-upon-default-config
@ -555,19 +542,19 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
// classpath // classpath
if (!classpath_.isEmpty()) { if (!classpath_.isEmpty()) {
args.add("--classpath"); args.add("--classpath");
args.add(String.join(File.pathSeparator, classpath_.stream().map(this::cleanPath).toList())); args.add(String.join(File.pathSeparator, classpath_.stream().map(File::getAbsolutePath).toList()));
} }
// config // config
if (!config_.isEmpty()) { if (!config_.isEmpty()) {
args.add("-config"); args.add("-config");
args.add(String.join(";", config_.stream().map(this::cleanPath).toList())); args.add(String.join(";", config_.stream().map(File::getAbsolutePath).toList()));
} }
// config-resource // config-resource
if (isNotBlank(configResource_)) { if (isNotBlank(configResource_)) {
args.add("--config-resource"); args.add("--config-resource");
args.add(cleanPath(configResource_)); args.add(configResource_);
} }
// create-baseline // create-baseline
@ -588,7 +575,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
// excludes // excludes
if (!excludes_.isEmpty()) { if (!excludes_.isEmpty()) {
args.add("--excludes"); args.add("--excludes");
args.add(String.join(",", excludes_.stream().map(this::cleanPath).toList())); args.add(String.join(",", excludes_));
} }
// generate-config // generate-config
@ -599,19 +586,19 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
// includes // includes
if (!includes_.isEmpty()) { if (!includes_.isEmpty()) {
args.add("--includes"); args.add("--includes");
args.add(String.join(",", includes_.stream().map(this::cleanPath).toList())); args.add(String.join(",", includes_));
} }
// input // input
if (!input_.isEmpty()) { if (!input_.isEmpty()) {
args.add("--input"); args.add("--input");
args.add(String.join(",", input_.stream().map(this::cleanPath).toList())); args.add(String.join(",", input_.stream().map(File::getAbsolutePath).toList()));
} }
// jdk-home // jdk-home
if (isNotBlank(jdkHome_)) { if (isNotBlank(jdkHome_)) {
args.add("--jdk-home"); args.add("--jdk-home");
args.add(cleanPath(jdkHome_)); args.add(jdkHome_);
} }
// jvm-target // jvm-target
@ -640,14 +627,14 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
// plugins // plugins
if (!plugins_.isEmpty()) { if (!plugins_.isEmpty()) {
args.add("--plugins"); args.add("--plugins");
args.add(String.join(",", plugins_.stream().map(this::cleanPath).toList())); args.add(String.join(",", plugins_.stream().map(File::getAbsolutePath).toList()));
} }
// report // report
if (!report_.isEmpty()) { if (!report_.isEmpty()) {
report_.forEach(it -> { report_.forEach(it -> {
args.add("--report"); args.add("--report");
args.add(it.id().name().toLowerCase() + ":" + cleanPath(it.path())); args.add(it.id().name().toLowerCase() + ":" + it.path());
}); });
} }
@ -706,7 +693,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
if (!f.getName().endsWith("-sources.jar") && !f.getName().endsWith("-javadoc.jar")) { if (!f.getName().endsWith("-sources.jar") && !f.getName().endsWith("-javadoc.jar")) {
for (var m : DETEKT_JARS) { for (var m : DETEKT_JARS) {
if (f.getName().startsWith(m)) { if (f.getName().startsWith(m)) {
jars.add(cleanPath(f)); jars.add(f.getAbsolutePath());
break; break;
} }
} }
@ -832,15 +819,6 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
return s != null && !s.isBlank(); return s != null && !s.isBlank();
} }
/**
* Determines if the current operating system is Windows.
*
* @return true if the operating system is Windows, false otherwise.
*/
private boolean isWindows() {
return OS_NAME != null && OS_NAME.contains("win");
}
/** /**
* EXPERIMENTAL: Use a custom JDK home directory to include into the * EXPERIMENTAL: Use a custom JDK home directory to include into the
* classpath. * classpath.

View file

@ -264,7 +264,6 @@ class DetektOperationTest {
var op = new DetektOperation() var op = new DetektOperation()
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
"example", "Example")) "example", "Example"))
.baseline("src/test/resources/detekt-baseline.xml")
.maxIssues(8); .maxIssues(8);
assertThatNoException().isThrownBy(op::execute); assertThatNoException().isThrownBy(op::execute);
} }
@ -282,7 +281,6 @@ class DetektOperationTest {
var op = new DetektOperation() var op = new DetektOperation()
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
"example", "Example")) "example", "Example"))
.baseline("src/test/resources/detekt-baseline.xml")
.report(new Report(ReportId.HTML, html.getAbsolutePath())) .report(new Report(ReportId.HTML, html.getAbsolutePath()))
.report(new Report(ReportId.XML, xml.getAbsolutePath())) .report(new Report(ReportId.XML, xml.getAbsolutePath()))
.report(new Report(ReportId.TXT, txt.getAbsolutePath())) .report(new Report(ReportId.TXT, txt.getAbsolutePath()))
@ -301,7 +299,6 @@ class DetektOperationTest {
var op = new DetektOperation() var op = new DetektOperation()
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
"example", "Example")) "example", "Example"))
.baseline("src/test/resources/detekt-baseline.xml")
.debug(true); .debug(true);
assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class); assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class);
} }

View file

@ -1,6 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
</CurrentIssues>
</SmellBaseline>