Compare commits
2 commits
b2574279eb
...
8b02e1e45a
Author | SHA1 | Date | |
---|---|---|---|
8b02e1e45a | |||
b26240df76 |
14 changed files with 179 additions and 173 deletions
15
.github/workflows/bld.yml
vendored
15
.github/workflows/bld.yml
vendored
|
@ -22,17 +22,12 @@ jobs:
|
||||||
distribution: "zulu"
|
distribution: "zulu"
|
||||||
java-version: ${{ matrix.java-version }}
|
java-version: ${{ matrix.java-version }}
|
||||||
|
|
||||||
- name: Grant execute permission for bld
|
- name: Download dependencies
|
||||||
run: chmod +x bld
|
|
||||||
|
|
||||||
- name: Download the dependencies
|
|
||||||
run: ./bld download
|
run: ./bld download
|
||||||
|
|
||||||
- name: Download the examples dependencies
|
- name: Download dependencies [examples]
|
||||||
run: |
|
working-directory: examples
|
||||||
cd examples
|
run: ./bld download
|
||||||
chmod +x bld
|
|
||||||
./bld download
|
|
||||||
|
|
||||||
- name: Run tests with bld
|
- name: Run tests
|
||||||
run: ./bld compile test
|
run: ./bld compile test
|
||||||
|
|
4
.idea/libraries/bld.xml
generated
4
.idea/libraries/bld.xml
generated
|
@ -2,12 +2,12 @@
|
||||||
<library name="bld">
|
<library name="bld">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.0-SNAPSHOT.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1-sources.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.0-SNAPSHOT-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<excluded>
|
<excluded>
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -9,7 +9,7 @@
|
||||||
],
|
],
|
||||||
"java.configuration.updateBuildConfiguration": "automatic",
|
"java.configuration.updateBuildConfiguration": "automatic",
|
||||||
"java.project.referencedLibraries": [
|
"java.project.referencedLibraries": [
|
||||||
"${HOME}/.bld/dist/bld-1.9.1.jar",
|
"${HOME}/.bld/dist/bld-2.0.0-SNAPSHOT.jar",
|
||||||
"lib/**/*.jar"
|
"lib/**/*.jar"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,3 +45,7 @@ public void detektBaseline() throws ExitStatusException, IOException, Interrupte
|
||||||
- [View Examples Project](https://github.com/rife2/bld-detekt/tree/main/examples)
|
- [View Examples Project](https://github.com/rife2/bld-detekt/tree/main/examples)
|
||||||
|
|
||||||
Please check the [DetektOperation documentation](https://rife2.github.io/bld-detekt/rife/bld/extension/DetektOperation.html#method-summary) for all available configuration options.
|
Please check the [DetektOperation documentation](https://rife2.github.io/bld-detekt/rife/bld/extension/DetektOperation.html#method-summary) for all available configuration options.
|
||||||
|
|
||||||
|
## Template Project
|
||||||
|
|
||||||
|
There is also a [Kotlin Template Project](https://github.com/rife2/kotlin-bld-example) with support for [Dokka](https://github.com/rife2/bld-dokka) and the Detekt extensions.
|
||||||
|
|
4
examples/.idea/libraries/bld.xml
generated
4
examples/.idea/libraries/bld.xml
generated
|
@ -2,12 +2,12 @@
|
||||||
<library name="bld">
|
<library name="bld">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.0-SNAPSHOT.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC />
|
<JAVADOC />
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="file://$PROJECT_DIR$/lib/bld" />
|
<root url="file://$PROJECT_DIR$/lib/bld" />
|
||||||
<root url="jar://$USER_HOME$/.bld/dist/bld-1.9.1-sources.jar!/" />
|
<root url="jar://$USER_HOME$/.bld/dist/bld-2.0.0-SNAPSHOT-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
<excluded>
|
<excluded>
|
||||||
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
|
||||||
|
|
2
examples/.vscode/settings.json
vendored
2
examples/.vscode/settings.json
vendored
|
@ -9,7 +9,7 @@
|
||||||
],
|
],
|
||||||
"java.configuration.updateBuildConfiguration": "automatic",
|
"java.configuration.updateBuildConfiguration": "automatic",
|
||||||
"java.project.referencedLibraries": [
|
"java.project.referencedLibraries": [
|
||||||
"${HOME}/.bld/dist/bld-1.9.1.jar",
|
"${HOME}/.bld/dist/bld-2.0.0-SNAPSHOT.jar",
|
||||||
"lib/**/*.jar"
|
"lib/**/*.jar"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -5,4 +5,4 @@ bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.5-SNAPSHOT
|
||||||
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.0-SNAPSHOT
|
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.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=
|
||||||
bld.version=1.9.1
|
bld.version=2.0.0-SNAPSHOT
|
||||||
|
|
|
@ -36,8 +36,8 @@ public class ExampleBuild extends Project {
|
||||||
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin));
|
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", kotlin));
|
||||||
scope(test)
|
scope(test)
|
||||||
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
|
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", kotlin))
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)));
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 3)));
|
||||||
|
|
||||||
// Include the Kotlin source directory when creating or publishing sources Java Archives
|
// Include the Kotlin source directory when creating or publishing sources Java Archives
|
||||||
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
|
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
|
||||||
|
@ -45,21 +45,21 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||||
@Override
|
@Override
|
||||||
public void compile() throws IOException {
|
public void compile() throws Exception {
|
||||||
new CompileKotlinOperation()
|
new CompileKotlinOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
.execute();
|
.execute();
|
||||||
|
|
Binary file not shown.
|
@ -2,7 +2,7 @@ bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.downloadLocation=
|
bld.downloadLocation=
|
||||||
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.1
|
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.1
|
||||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.0
|
bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.2
|
||||||
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
bld.sourceDirectories=
|
bld.sourceDirectories=
|
||||||
bld.version=1.9.1
|
bld.version=2.0.0-SNAPSHOT
|
||||||
|
|
|
@ -24,8 +24,7 @@ import rife.bld.publish.PublishScm;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static rife.bld.dependencies.Repository.MAVEN_CENTRAL;
|
import static rife.bld.dependencies.Repository.*;
|
||||||
import static rife.bld.dependencies.Repository.RIFE2_RELEASES;
|
|
||||||
import static rife.bld.dependencies.Scope.compile;
|
import static rife.bld.dependencies.Scope.compile;
|
||||||
import static rife.bld.dependencies.Scope.test;
|
import static rife.bld.dependencies.Scope.test;
|
||||||
import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;
|
import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;
|
||||||
|
@ -39,15 +38,15 @@ public class DetektOperationBuild extends Project {
|
||||||
javaRelease = 17;
|
javaRelease = 17;
|
||||||
downloadSources = true;
|
downloadSources = true;
|
||||||
autoDownloadPurge = true;
|
autoDownloadPurge = true;
|
||||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);
|
||||||
|
|
||||||
scope(compile)
|
scope(compile)
|
||||||
.include(dependency("com.uwyn.rife2", "bld", version(1, 9, 1)))
|
.include(dependency("com.uwyn.rife2", "bld", version(2, 0, 0, "SNAPSHOT")))
|
||||||
.include(dependency("io.gitlab.arturbosch.detekt", "detekt-cli", version(1, 23, 6)));
|
.include(dependency("io.gitlab.arturbosch.detekt", "detekt-cli", version(1, 23, 6)));
|
||||||
scope(test)
|
scope(test)
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 2)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 2)))
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 3)))
|
||||||
.include(dependency("org.assertj", "assertj-core", version(3, 26, 0)));
|
.include(dependency("org.assertj", "assertj-core", version(3, 26, 3)));
|
||||||
javadocOperation()
|
javadocOperation()
|
||||||
.javadocOptions()
|
.javadocOptions()
|
||||||
.author()
|
.author()
|
||||||
|
@ -89,7 +88,7 @@ public class DetektOperationBuild extends Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Checks source code with PMD")
|
@BuildCommand(summary = "Checks source code with PMD")
|
||||||
public void pmd() {
|
public void pmd() throws Exception {
|
||||||
new PmdOperation()
|
new PmdOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
.ruleSets("config/pmd.xml")
|
.ruleSets("config/pmd.xml")
|
||||||
|
|
|
@ -21,7 +21,6 @@ import rife.bld.extension.detekt.Report;
|
||||||
import rife.bld.extension.detekt.ReportId;
|
import rife.bld.extension.detekt.ReportId;
|
||||||
import rife.bld.operations.AbstractProcessOperation;
|
import rife.bld.operations.AbstractProcessOperation;
|
||||||
import rife.bld.operations.exceptions.ExitStatusException;
|
import rife.bld.operations.exceptions.ExitStatusException;
|
||||||
import rife.tools.exceptions.FileUtilsErrorException;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -60,6 +59,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
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<>();
|
||||||
|
private final Collection<String> includes_ = new ArrayList<>();
|
||||||
private final Collection<File> input_ = new ArrayList<>();
|
private final Collection<File> input_ = new ArrayList<>();
|
||||||
private final Collection<File> plugins_ = new ArrayList<>();
|
private final Collection<File> plugins_ = new ArrayList<>();
|
||||||
private final Collection<Report> report_ = new ArrayList<>();
|
private final Collection<Report> report_ = new ArrayList<>();
|
||||||
|
@ -73,7 +73,6 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
private boolean debug_;
|
private boolean debug_;
|
||||||
private boolean disableDefaultRuleSets_;
|
private boolean disableDefaultRuleSets_;
|
||||||
private boolean generateConfig_;
|
private boolean generateConfig_;
|
||||||
private final Collection<String> includes_ = new ArrayList<>();
|
|
||||||
private String jdkHome_;
|
private String jdkHome_;
|
||||||
private String jvmTarget_;
|
private String jvmTarget_;
|
||||||
private String languageVersion_;
|
private String languageVersion_;
|
||||||
|
@ -350,13 +349,18 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
*
|
*
|
||||||
* @throws InterruptedException when the operation was interrupted
|
* @throws InterruptedException when the operation was interrupted
|
||||||
* @throws IOException when an exception occurred during the execution of the process
|
* @throws IOException when an exception occurred during the execution of the process
|
||||||
* @throws FileUtilsErrorException when an exception occurred during the retrieval of the operation output
|
|
||||||
* @throws ExitStatusException when the exit status was changed during the operation
|
* @throws ExitStatusException when the exit status was changed during the operation
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws IOException, FileUtilsErrorException, InterruptedException, ExitStatusException {
|
public void execute() throws IOException, InterruptedException, ExitStatusException {
|
||||||
|
if (project_ == null) {
|
||||||
|
if (LOGGER.isLoggable(Level.SEVERE) && !silent()) {
|
||||||
|
LOGGER.severe("A project must be specified.");
|
||||||
|
}
|
||||||
|
throw new ExitStatusException(ExitStatusException.EXIT_FAILURE);
|
||||||
|
} else {
|
||||||
super.execute();
|
super.execute();
|
||||||
if (successful_ && LOGGER.isLoggable(Level.INFO)) {
|
if (successful_ && LOGGER.isLoggable(Level.INFO) && !silent()){
|
||||||
if (createBaseline_) {
|
if (createBaseline_) {
|
||||||
LOGGER.info("Detekt baseline generated successfully: "
|
LOGGER.info("Detekt baseline generated successfully: "
|
||||||
+ "file://" + new File(baseline_).toURI().getPath());
|
+ "file://" + new File(baseline_).toURI().getPath());
|
||||||
|
@ -365,6 +369,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part of the {@link #execute} operation, constructs the command list
|
* Part of the {@link #execute} operation, constructs the command list
|
||||||
|
@ -372,11 +377,8 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected List<String> executeConstructProcessCommandList() {
|
protected List<String> executeConstructProcessCommandList() {
|
||||||
if (project_ == null) {
|
|
||||||
LOGGER.severe("A project must be specified.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<String> args = new ArrayList<>();
|
final List<String> args = new ArrayList<>();
|
||||||
|
if (project_ != null) {
|
||||||
args.add(javaTool());
|
args.add(javaTool());
|
||||||
args.add("-cp");
|
args.add("-cp");
|
||||||
args.add(getDetektJarList(project_.libBldDirectory()));
|
args.add(getDetektJarList(project_.libBldDirectory()));
|
||||||
|
@ -508,9 +510,10 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGGER.isLoggable(Level.FINE)) {
|
if (LOGGER.isLoggable(Level.FINE) && !silent()) {
|
||||||
LOGGER.fine(String.join(" ", args.stream().filter(this::isNotBlank).toList()));
|
LOGGER.fine(String.join(" ", args.stream().filter(this::isNotBlank).toList()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
@ -551,9 +554,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Retrieves the matching JARs files from the given directory.
|
||||||
* Retrieves the matching JARs files from the given directory.
|
|
||||||
*/
|
|
||||||
private String getDetektJarList(File directory) {
|
private String getDetektJarList(File directory) {
|
||||||
var jars = new ArrayList<String>();
|
var jars = new ArrayList<String>();
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ class DetektOperationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||||
void testCheckAllParameters() throws IOException {
|
void testCheckAllParameters() throws IOException {
|
||||||
var args = Files.readAllLines(Paths.get("src", "test", "resources", "detekt-args.txt"));
|
var args = Files.readAllLines(Paths.get("src", "test", "resources", "detekt-args.txt"));
|
||||||
|
|
||||||
|
@ -190,4 +191,10 @@ class DetektOperationTest {
|
||||||
.debug(true);
|
.debug(true);
|
||||||
assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class);
|
assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testExecuteNoProject() {
|
||||||
|
var op = new DetektOperation();
|
||||||
|
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue