From 0e482658904b8a95d383cff43832152fa6f91f23 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 28 Aug 2023 02:12:07 -0700 Subject: [PATCH] Updaded README with examples, etc. --- README.md | 29 +++++++++++++++++-- .../main/java/com/example/ExamplesMain.java | 8 ++--- .../test/java/com/example/ExamplesTest.java | 8 ++--- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b8a7d0b..371cd0d 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# [bld](https://rife2.com/bldb) [Checkstyle](https://checkstyle.sourceforge.io/) Extension +# [Checkstyle](https://checkstyle.sourceforge.io/) Extension for [bld](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** \ No newline at end of file +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))); + diff --git a/examples/src/main/java/com/example/ExamplesMain.java b/examples/src/main/java/com/example/ExamplesMain.java index 1c6a403..946e266 100644 --- a/examples/src/main/java/com/example/ExamplesMain.java +++ b/examples/src/main/java/com/example/ExamplesMain.java @@ -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!"; + } } \ No newline at end of file diff --git a/examples/src/test/java/com/example/ExamplesTest.java b/examples/src/test/java/com/example/ExamplesTest.java index 650551e..65bab3c 100644 --- a/examples/src/test/java/com/example/ExamplesTest.java +++ b/examples/src/test/java/com/example/ExamplesTest.java @@ -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(); - } } \ No newline at end of file