Added detekt-main & detekt-test examples
This commit is contained in:
parent
ba4741062c
commit
a13a2b814b
8 changed files with 49 additions and 25 deletions
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
|
@ -1,5 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<pattern value="rife.bld.extension.DetektOperationBuild" method="pmd" />
|
||||||
|
</component>
|
||||||
<component name="PDMPlugin">
|
<component name="PDMPlugin">
|
||||||
<option name="skipTestSources" value="false" />
|
<option name="skipTestSources" value="false" />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -13,7 +13,7 @@ To install, please refer to the [extensions documentation](https://github.com/ri
|
||||||
To check all Kotlin source code located `src/main/kotlin` and `src/test/kotlin`, add the following to your build file
|
To check all Kotlin source code located `src/main/kotlin` and `src/test/kotlin`, add the following to your build file
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@BuildCommand(summary = "Check source with Detekt")
|
@BuildCommand(summary = "Checks source with Detekt")
|
||||||
public void detekt() throws ExitStatusException, IOException, InterruptedException {
|
public void detekt() throws ExitStatusException, IOException, InterruptedException {
|
||||||
new DetektOperation()
|
new DetektOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
|
@ -25,10 +25,12 @@ public void detekt() throws ExitStatusException, IOException, InterruptedExcepti
|
||||||
./bld compile detekt
|
./bld compile detekt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- [View Examples Project](https://github.com/rife2/bld-detekt/tree/main/examples)
|
||||||
|
|
||||||
To generate a Detekt baseline, add the following to your build file:
|
To generate a Detekt baseline, add the following to your build file:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@BuildCommand(value = "detekt-baseline", summary = "Creates a Detekt baseline")
|
@BuildCommand(value = "detekt-baseline", summary = "Creates the Detekt baseline")
|
||||||
public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
|
public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
|
||||||
new DetektOperation()
|
new DetektOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
|
@ -41,5 +43,6 @@ public void detektBaseline() throws ExitStatusException, IOException, Interrupte
|
||||||
```console
|
```console
|
||||||
./bld compile detekt-baseline
|
./bld compile detekt-baseline
|
||||||
```
|
```
|
||||||
|
- [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.
|
||||||
|
|
4
examples/.idea/misc.xml
generated
4
examples/.idea/misc.xml
generated
|
@ -6,6 +6,10 @@
|
||||||
<pattern value="com.example.ExampleBuild" method="dokkaHtml" />
|
<pattern value="com.example.ExampleBuild" method="dokkaHtml" />
|
||||||
<pattern value="com.example.ExampleBuild" method="dokkaGfm" />
|
<pattern value="com.example.ExampleBuild" method="dokkaGfm" />
|
||||||
<pattern value="com.example.ExampleBuild" method="dokkaJekyll" />
|
<pattern value="com.example.ExampleBuild" method="dokkaJekyll" />
|
||||||
|
<pattern value="com.example.ExampleBuild" method="detekt" />
|
||||||
|
<pattern value="com.example.ExampleBuild" method="detektBaseline" />
|
||||||
|
<pattern value="com.example.ExampleBuild" method="detektMain" />
|
||||||
|
<pattern value="com.example.ExampleBuild" method="detektTest" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PDMPlugin">
|
<component name="PDMPlugin">
|
||||||
<option name="customRuleSets">
|
<option name="customRuleSets">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
j## Compile the Kotlin Example
|
## Compile the Kotlin Example
|
||||||
|
|
||||||
```console
|
```console
|
||||||
./bld compile
|
./bld compile
|
||||||
|
@ -8,6 +8,9 @@ j## Compile the Kotlin Example
|
||||||
|
|
||||||
```console
|
```console
|
||||||
./bld detekt
|
./bld detekt
|
||||||
|
|
||||||
|
./bld detekt-main
|
||||||
|
./bld detekt-test
|
||||||
```
|
```
|
||||||
|
|
||||||
## Generate Detekt baseline
|
## Generate Detekt baseline
|
||||||
|
@ -16,4 +19,4 @@ j## Compile the Kotlin Example
|
||||||
./bld detekt-baseline
|
./bld detekt-baseline
|
||||||
```
|
```
|
||||||
|
|
||||||
The `detekt-baseline.xml` will be created in the project's root directory.
|
The `detekt-baseline.xml` file will be created in the project's root directory.
|
||||||
|
|
|
@ -4,14 +4,10 @@ import rife.bld.BuildCommand;
|
||||||
import rife.bld.Project;
|
import rife.bld.Project;
|
||||||
import rife.bld.extension.CompileKotlinOperation;
|
import rife.bld.extension.CompileKotlinOperation;
|
||||||
import rife.bld.extension.DetektOperation;
|
import rife.bld.extension.DetektOperation;
|
||||||
import rife.bld.extension.dokka.DokkaOperation;
|
|
||||||
import rife.bld.extension.dokka.LoggingLevel;
|
|
||||||
import rife.bld.extension.dokka.OutputFormat;
|
|
||||||
import rife.bld.operations.exceptions.ExitStatusException;
|
import rife.bld.operations.exceptions.ExitStatusException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.ConsoleHandler;
|
import java.util.logging.ConsoleHandler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -49,7 +45,7 @@ public class ExampleBuild extends Project {
|
||||||
var logger = Logger.getLogger("rife.bld.extension");
|
var logger = Logger.getLogger("rife.bld.extension");
|
||||||
var consoleHandler = new ConsoleHandler();
|
var consoleHandler = new ConsoleHandler();
|
||||||
|
|
||||||
// Enable detailed logging for the Kotlin extension
|
// Enable detailed logging
|
||||||
consoleHandler.setLevel(level);
|
consoleHandler.setLevel(level);
|
||||||
logger.addHandler(consoleHandler);
|
logger.addHandler(consoleHandler);
|
||||||
logger.setLevel(level);
|
logger.setLevel(level);
|
||||||
|
@ -58,23 +54,22 @@ public class ExampleBuild extends Project {
|
||||||
new ExampleBuild().start(args);
|
new ExampleBuild().start(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Compile the Kotlin project")
|
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||||
@Override
|
@Override
|
||||||
public void compile() throws IOException {
|
public void compile() throws IOException {
|
||||||
// The source code located in src/main/kotlin and src/test/kotlin will be compiled
|
|
||||||
new CompileKotlinOperation()
|
new CompileKotlinOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Check source with Detekt")
|
@BuildCommand(summary = "Checks source with Detekt")
|
||||||
public void detekt() throws ExitStatusException, IOException, InterruptedException {
|
public void detekt() throws ExitStatusException, IOException, InterruptedException {
|
||||||
new DetektOperation()
|
new DetektOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(value = "detekt-baseline", summary = "Creates a Detekt baseline")
|
@BuildCommand(value = "detekt-baseline", summary = "Creates the Detekt baseline")
|
||||||
public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
|
public void detektBaseline() throws ExitStatusException, IOException, InterruptedException {
|
||||||
new DetektOperation()
|
new DetektOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
|
@ -82,4 +77,18 @@ public class ExampleBuild extends Project {
|
||||||
.createBaseline(true)
|
.createBaseline(true)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BuildCommand(value = "detekt-main", summary = "Checks main source with Detekt")
|
||||||
|
public void detektMain() throws ExitStatusException, IOException, InterruptedException {
|
||||||
|
var op = new DetektOperation().fromProject(this);
|
||||||
|
op.input().clear();
|
||||||
|
op.input("src/main/kotlin").execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(value = "detekt-test", summary = "Checks test source with Detekt")
|
||||||
|
public void detektTest() throws ExitStatusException, IOException, InterruptedException {
|
||||||
|
var op = new DetektOperation().fromProject(this);
|
||||||
|
op.input().clear();
|
||||||
|
op.input("src/test/kotlin").execute();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,5 @@
|
||||||
package com.example
|
package com.example
|
||||||
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example class.
|
|
||||||
*/
|
|
||||||
class Example {
|
class Example {
|
||||||
val message: String
|
val message: String
|
||||||
get() = "Hello World!"
|
get() = "Hello World!"
|
||||||
|
|
|
@ -41,13 +41,11 @@ public class DetektOperationBuild extends Project {
|
||||||
autoDownloadPurge = true;
|
autoDownloadPurge = true;
|
||||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||||
|
|
||||||
|
var detekt = version(1, 23, 3);
|
||||||
scope(compile)
|
scope(compile)
|
||||||
.include(dependency("com.uwyn.rife2", "bld", version(1, 7, 5)))
|
.include(dependency("com.uwyn.rife2", "bld", version(1, 7, 5)))
|
||||||
.include(dependency("io.gitlab.arturbosch.detekt", "detekt-cli", version(1, 23, 3)))
|
.include(dependency("io.gitlab.arturbosch.detekt", "detekt-cli", detekt))
|
||||||
// .include(dependency("io.gitlab.arturbosch.detekt", "detekt-core", version(1, 23, 3)))
|
.include(dependency("io.gitlab.arturbosch.detekt", "detekt-tooling", detekt))
|
||||||
// .include(dependency("io.gitlab.arturbosch.detekt", "detekt-rules", version(1, 23, 3)))
|
|
||||||
// .include(dependency("io.gitlab.arturbosch.detekt", "detekt-utils", version(1, 23, 3)))
|
|
||||||
.include(dependency("io.gitlab.arturbosch.detekt", "detekt-tooling", version(1, 23, 3)))
|
|
||||||
.include(dependency("com.beust", "jcommander", "1.82"))
|
.include(dependency("com.beust", "jcommander", "1.82"))
|
||||||
.include(dependency("com.fasterxml:aalto-xml:1.3.2"));
|
.include(dependency("com.fasterxml:aalto-xml:1.3.2"));
|
||||||
scope(test)
|
scope(test)
|
||||||
|
@ -96,10 +94,10 @@ public class DetektOperationBuild extends Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Check source code with PMD")
|
@BuildCommand(summary = "Check source code with PMD")
|
||||||
public void pmd() throws Exception {
|
public void pmd() {
|
||||||
new PmdOperation()
|
new PmdOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
.addRuleSet("config/pmd.xml")
|
.ruleSets("config/pmd.xml")
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -448,6 +448,15 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the input paths to analyze.
|
||||||
|
*
|
||||||
|
* @return the input paths
|
||||||
|
*/
|
||||||
|
public Collection<String> input() {
|
||||||
|
return input_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EXPERIMENTAL: Use a custom JDK home directory to include into the
|
* EXPERIMENTAL: Use a custom JDK home directory to include into the
|
||||||
* classpath.
|
* classpath.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue