Updaded README with examples, etc.

This commit is contained in:
Erik C. Thauvin 2023-08-28 02:12:07 -07:00
parent cfd6bb7c18
commit 0e48265890
3 changed files with 35 additions and 10 deletions

View file

@ -1,4 +1,4 @@
# [b<span style="color:orange">l</span>d](https://rife2.com/bldb) [Checkstyle](https://checkstyle.sourceforge.io/) Extension
# [Checkstyle](https://checkstyle.sourceforge.io/) Extension for [b<span style="color:orange">l</span>d](https://rife2.com/bldb)
[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
@ -9,4 +9,29 @@
To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions).
**TBD**
To check your code with Chesktyle, include the following in your build file:
```java
@BuildCommand(summary = "Check code style")
public void checkstyle() throws Exception {
new CheckstyleOperation()
.fromProject(this)
.configurationFile("config/sun_checks.xml")
.execute();
}
```
```
./bld checkstyle
```
Please check the [CheckstyleOperation documentation](https://rife2.github.io/bld-checkstyle/rife/bld/extension/CheckstyleOperation.html#method-summary) for all available configuration options.
### Checkstyle Dependency
Don't forget to add a Checkstyle `test` dependency to your build file, as it is not provided by the extension. For example:
```java
repositories = List.of(MAVEN_CENTRAL);
scope(test).include(dependency("com.puppycrawl.tools", "checkstyle", version(10, 12, 2)));

View file

@ -1,11 +1,11 @@
package com.example;
public class ExamplesMain {
public String getMessage() {
return "Hello World!";
}
public static void main(String[] args) {
System.out.println(new ExamplesMain().getMessage());
}
public String getMessage() {
return "Hello World!";
}
}

View file

@ -1,6 +1,10 @@
package com.example;
public class ExamplesTest {
public static void main(String[] args) {
new ExamplesTest().verifyHello();
}
void verifyHello() {
if (!"Hello World!".equals(new ExamplesMain().getMessage())) {
throw new AssertionError();
@ -8,8 +12,4 @@ public class ExamplesTest {
System.out.println("Succeeded");
}
}
public static void main(String[] args) {
new ExamplesTest().verifyHello();
}
}