Minor cleanup

This commit is contained in:
Erik C. Thauvin 2023-11-03 22:08:45 -07:00
parent f837b26903
commit c7578a870f
6 changed files with 135 additions and 14 deletions

View file

@ -16,13 +16,12 @@
package rife.bld.extension;
import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.operations.RunOperation;
import rife.bld.publish.PublishDeveloper;
import rife.bld.publish.PublishLicense;
import rife.bld.publish.PublishScm;
import java.io.File;
import java.util.List;
import static rife.bld.dependencies.Repository.*;
@ -78,4 +77,13 @@ public class CompileKotlinOperationBuild extends Project {
public static void main(String[] args) {
new CompileKotlinOperationBuild().start(args);
}
@BuildCommand(summary = "Runs PMD analysis")
public void pmd() {
new PmdOperation()
.fromProject(this)
.failOnViolation(true)
.ruleSets("config/pmd.xml")
.execute();
}
}

View file

@ -203,6 +203,8 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
/**
* Performs the compile operation.
*/
@Override
@SuppressWarnings("PMD.SystemPrintln")
public void execute()
throws IOException {
executeCreateBuildDirectories();
@ -259,9 +261,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
args.addAll(compileOptions());
// source
sources.forEach(f -> {
args.add(f.getAbsolutePath());
});
sources.forEach(f -> args.add(f.getAbsolutePath()));
if (LOGGER.isLoggable(Level.FINE) && !silent()) {
LOGGER.fine("kotlinc " + String.join(" ", args));
@ -292,15 +292,11 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
* Part of the {@link #execute} operation, creates the build directories.
*/
protected void executeCreateBuildDirectories() throws IOException {
if (buildMainDirectory() != null && !buildMainDirectory().exists()) {
if (!buildMainDirectory().mkdirs()) {
throw new IOException("Could not created build main directory: " + buildMainDirectory().getAbsolutePath());
}
if (buildMainDirectory() != null && !buildMainDirectory().exists() && !buildMainDirectory().mkdirs()) {
throw new IOException("Could not created build main directory: " + buildMainDirectory().getAbsolutePath());
}
if (buildTestDirectory() != null && !buildTestDirectory().exists()) {
if (!buildTestDirectory().mkdirs()) {
throw new IOException("Could not created build test directory: " + buildTestDirectory().getAbsolutePath());
}
if (buildTestDirectory() != null && !buildTestDirectory().exists() && !buildTestDirectory().mkdirs()) {
throw new IOException("Could not created build test directory: " + buildTestDirectory().getAbsolutePath());
}
}

View file

@ -16,6 +16,7 @@
package rife.bld.extension;
@SuppressWarnings({"PMD.TestClassWithoutTestCases", "PMD.SystemPrintln"})
public class CompileKotlinOperationTest {
void verifyHello() {
if (!"Hello World!".equals(new CompileKotlinOperation().getMessage())) {