From a34257d26d637d20cbf18366753186d7d4b96934 Mon Sep 17 00:00:00 2001 From: Richard J Hancock Date: Wed, 18 Sep 2024 15:18:16 -0500 Subject: [PATCH 1/5] Added JavaDoc to Pipeline Added CheckStyle Added EditorConfig --- .editorconfig | 16 + .github/workflows/ci.yml | 6 - .github/workflows/javadoc.yml | 64 +++ megameklab/build.gradle | 21 +- megameklab/config/checkstyle/checkstyle.xml | 427 ++++++++++++++++++ megameklab/config/checkstyle/suppressions.xml | 0 6 files changed, 526 insertions(+), 8 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/javadoc.yml create mode 100644 megameklab/config/checkstyle/checkstyle.xml create mode 100644 megameklab/config/checkstyle/suppressions.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..60d4a95d0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true +charset = "utf-8" + +[*.java] +indent_style = "space" +indent_size = 4 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 100 # Google Style Guide +curly_bracket_next_line = false +spaces_around_operators = true +spaces_around_brackets = "both" +indent_brace_style = "K&R" +wildcard_import_limit = 10 +continuation_indent_size = 4 # Google Style Guid diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c1c7c49b..32eab2836 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,12 +85,6 @@ jobs: fail_ci_if_error: false verbose: true - # - name: Upload Zip Release - # uses: actions/upload-artifact@v4 - # with: - # name: mml-release-zip-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }} - # path: ./megameklab/megameklab/build/distributions/*.zip - - name: Upload TarGZ Release uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml new file mode 100644 index 000000000..3d020259c --- /dev/null +++ b/.github/workflows/javadoc.yml @@ -0,0 +1,64 @@ +name: JavaDoc Generation + +on: + pull_request: + branches: [master] + +env: + GRADLE_OPTS: "-Dscan.link.VCS=${{ github.event.pull_request.html_url }}" + +jobs: + ci_cd: + runs-on: ${{ matrix.os }} + + outputs: + mmRepo: ${{ steps.find_mm.outputs.mmRepo }} + mmBranch: ${{ steps.find_mm.outputs.mmBranch }} + + strategy: + matrix: + os: [ubuntu-latest] # For CI/CD running on *nix is sufficient + java-distribution: [temurin] + java-version: [17] + fail-fast: false + + steps: + - name: Checking out MegaMekLab + uses: actions/checkout@v4 + with: + path: megameklab + + - name: Find the Right MegaMek Branch + id: find_mm + shell: bash {0} + run: | + git ls-remote --exit-code --heads ${{ github.event.pull_request.head.repo.owner.html_url }}/megamek.git ${{ github.event.pull_request.head.ref }} + if [ "$?" == "0" ] + then + echo "mmRepo=${{ github.event.pull_request.head.repo.owner.login }}/megamek" >> $GITHUB_OUTPUT + echo "mmBranch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT + else + echo "mmRepo=MegaMek/megamek" >> $GITHUB_OUTPUT + echo "mmBranch=master" >> $GITHUB_OUTPUT + fi + exit 0 + + - name: Checkout MegaMek + uses: actions/checkout@v4 + with: + repository: ${{ steps.find_mm.outputs.mmRepo }} + ref: ${{ steps.find_mm.outputs.mmBranch }} + path: megamek + + - name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }} + uses: actions/setup-java@v4 + with: + distribution: ${{ matrix.java-distribution }} + java-version: ${{ matrix.java-version }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Build with Gradle + working-directory: megameklab + run: ./gradlew javadoc diff --git a/megameklab/build.gradle b/megameklab/build.gradle index 434b5e187..2dc1a24b6 100644 --- a/megameklab/build.gradle +++ b/megameklab/build.gradle @@ -2,11 +2,13 @@ import java.time.LocalDateTime plugins { id 'application' + id 'checkstyle' + id 'com.palantir.git-version' version '3.1.0' id 'edu.sc.seis.launch4j' version '3.0.6' + id "io.sentry.jvm.gradle" version "4.11.0" id 'jacoco' id 'java' - id "io.sentry.jvm.gradle" version "4.11.0" - id 'com.palantir.git-version' version '3.1.0' + id 'org.ec4j.editorconfig' version '0.1.0' } java { @@ -89,6 +91,12 @@ application { mainClass = 'megameklab.MegaMekLab' } +checkstyle { + toolVersion '10.18.1' + configFile file("config/checkstyle/checkstyle.xml") + ignoreFailures false +} + jar { archiveFileName = "MegaMekLab.jar" manifest { @@ -259,3 +267,12 @@ task cleanAll() { dependsOn gradle.includedBuild('megamek').task(':megamek:clean') dependsOn clean } + +tasks.withType(Checkstyle) { + minHeapSize = "200m" + maxHeapSize = "1g" + reports { + xml.required = false + html.required = true + } +} diff --git a/megameklab/config/checkstyle/checkstyle.xml b/megameklab/config/checkstyle/checkstyle.xml new file mode 100644 index 000000000..36a790e38 --- /dev/null +++ b/megameklab/config/checkstyle/checkstyle.xml @@ -0,0 +1,427 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/megameklab/config/checkstyle/suppressions.xml b/megameklab/config/checkstyle/suppressions.xml new file mode 100644 index 000000000..e69de29bb From 6dc77db04b0b561473cd454a876cec5a94f304fb Mon Sep 17 00:00:00 2001 From: Richard J Hancock Date: Wed, 18 Sep 2024 15:43:31 -0500 Subject: [PATCH 2/5] Adjusted to 4 spaces --- megameklab/config/checkstyle/checkstyle.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megameklab/config/checkstyle/checkstyle.xml b/megameklab/config/checkstyle/checkstyle.xml index 36a790e38..72a7eeb73 100644 --- a/megameklab/config/checkstyle/checkstyle.xml +++ b/megameklab/config/checkstyle/checkstyle.xml @@ -277,7 +277,7 @@ https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resource value="GenericWhitespace ''{0}'' is not preceded with whitespace." /> - + From a59d9dbccb67e81ba8536aeda9654b05f30f43de Mon Sep 17 00:00:00 2001 From: Richard J Hancock Date: Wed, 18 Sep 2024 16:00:28 -0500 Subject: [PATCH 3/5] Fixed naming of Actions and disable checkStyle on build --- .github/workflows/ci.yml | 2 +- .github/workflows/javadoc.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32eab2836..11ecec0c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: - name: Build with Gradle working-directory: megameklab - run: ./gradlew build --stacktrace --scan + run: ./gradlew build -x checkstyleMain -x checkstyleTest --stacktrace --scan - name: Upload Test Logs on Failure uses: actions/upload-artifact@v4 diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index 3d020259c..466f3802f 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -8,7 +8,7 @@ env: GRADLE_OPTS: "-Dscan.link.VCS=${{ github.event.pull_request.html_url }}" jobs: - ci_cd: + javadoc: runs-on: ${{ matrix.os }} outputs: From 6fb1e0848a1f7a25525f937aae376cb91539d054 Mon Sep 17 00:00:00 2001 From: Richard J Hancock Date: Wed, 18 Sep 2024 16:07:14 -0500 Subject: [PATCH 4/5] Gradle Daemon Properties --- gradle/gradle-daemon-jvm.properties | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 gradle/gradle-daemon-jvm.properties diff --git a/gradle/gradle-daemon-jvm.properties b/gradle/gradle-daemon-jvm.properties new file mode 100644 index 000000000..858feb7e3 --- /dev/null +++ b/gradle/gradle-daemon-jvm.properties @@ -0,0 +1,2 @@ +#This file is generated by updateDaemonJvm +toolchainVersion=17 From 2b382cce550e8fa90806dc6b3a2b6758fbc183d4 Mon Sep 17 00:00:00 2001 From: Richard J Hancock Date: Fri, 20 Sep 2024 16:44:17 -0500 Subject: [PATCH 5/5] Adjusted to 140 width. Added config for XML, MTF, and BLK as a precaution --- .editorconfig | 19 +- megameklab/config/checkstyle/checkstyle.xml | 702 ++++++++++---------- 2 files changed, 369 insertions(+), 352 deletions(-) diff --git a/.editorconfig b/.editorconfig index 60d4a95d0..274d11b5d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,10 +7,27 @@ indent_size = 4 end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true -max_line_length = 100 # Google Style Guide +max_line_length = 140 # Google Style Guide curly_bracket_next_line = false spaces_around_operators = true spaces_around_brackets = "both" indent_brace_style = "K&R" wildcard_import_limit = 10 continuation_indent_size = 4 # Google Style Guid + +[*.xml] +indent_style = "space" +indent_size = 4 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + +[*.blk] +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + +[*.mtf] +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/megameklab/config/checkstyle/checkstyle.xml b/megameklab/config/checkstyle/checkstyle.xml index 72a7eeb73..3ed9c8d6b 100644 --- a/megameklab/config/checkstyle/checkstyle.xml +++ b/megameklab/config/checkstyle/checkstyle.xml @@ -19,116 +19,114 @@ https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resource --> + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - + - - - - - - + + + + - - - - + + + + + + - - - - + + + + + - - + + + + + - - + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - - - + + + - - - - - - - - + + + + + + - - - - - - - - - + + + + + + + - - - - - - + + + + - - - - + + - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + - - - + - - - - + + + - - - - + + - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - - + + - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + -