diff --git a/.circleci/config.yml b/.circleci/config.yml index 09d8896..17b50f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,8 @@ -version: 2 +version: 2.1 + +orbs: + sdkman: joshdholtz/sdkman@0.2.0 + defaults: &defaults working_directory: ~/repo environment: @@ -6,18 +10,31 @@ defaults: &defaults TERM: dumb CI_NAME: "CircleCI" -defaults_bld: &defaults_bld - steps: - - checkout - - run: - name: Download the bld dependencies - command: ./bld download - - run: - name: Compile source with bld - command: ./bld compile - - run: - name: Run tests with bld - command: ./bld test +commands: + build_and_test: + parameters: + reports-dir: + type: string + default: "build/reports/test_results" + steps: + - checkout + - sdkman/setup-sdkman + - sdkman/sdkman-install: + candidate: kotlin + version: 2.0.0 + - run: + name: Download dependencies + command: ./bld download + - run: + name: Compile source + command: ./bld compile + - run: + name: Run tests + command: ./bld jacoco -reports-dir=<< parameters.reports-dir >> + - store_test_results: + path: << parameters.reports-dir >> + - store_artifacts: + path: build/reports/jacoco/test/html jobs: bld_jdk17: @@ -26,7 +43,8 @@ jobs: docker: - image: cimg/openjdk:17.0 - <<: *defaults_bld + steps: + - build_and_test bld_jdk20: <<: *defaults @@ -34,10 +52,10 @@ jobs: docker: - image: cimg/openjdk:20.0 - <<: *defaults_bld + steps: + - build_and_test workflows: - version: 2 bld: jobs: - bld_jdk17 diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index d6911ad..3183ee9 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -7,11 +7,14 @@ jobs: runs-on: ubuntu-latest env: - COVERAGE_SDK: "17" + COVERAGE_JDK: "21" + COVERAGE_KOTLIN: "2.0.0" + KOTLIN_HOME: /usr/share/kotlinc strategy: matrix: java-version: [17, 21, 22] + kotlin-version: [1.9.24, 2.0.0] steps: - name: Checkout source repository @@ -19,34 +22,30 @@ jobs: with: fetch-depth: 0 - - name: Set up JDK ${{ matrix.java-version }} + - name: Set up JDK ${{ matrix.java-version }} with Kotlin ${{ matrix.kotlin-version }} uses: actions/setup-java@v4 with: distribution: "zulu" java-version: ${{ matrix.java-version }} - - name: Grant bld execute permission - run: chmod +x bld - - - name: Download the bld dependencies + - name: Download dependencies run: ./bld download - - name: Compile source with bld + - name: Compile source run: ./bld compile - - name: Run tests with bld + - name: Run tests env: AKISMET_BLOG: ${{ secrets.AKISMET_BLOG }} AKISMET_API_KEY: ${{ secrets.AKISMET_API_KEY }} run: ./bld jacoco - name: Remove pom.xml - if: success() && matrix.java-version == env.COVERAGE_SDK run: rm -rf pom.xml - name: SonarCloud Scan + if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.kotlin-version == env.COVERAGE_KOTLIN uses: sonarsource/sonarcloud-github-action@master - if: success() && matrix.java-version == env.COVERAGE_SDK env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 052df48..10b9b0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,24 @@ -image: openjdk:17 +image: fedora:latest + +variables: + CI_NAME: "GitLab CI" stages: - test +before_script: + - dnf -qy update && dnf -y install zip + - curl -s "https://get.sdkman.io" | bash + - echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config + - echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config + - source "$HOME/.sdkman/bin/sdkman-init.sh" + - sdk install java + - sdk install kotlin + - source "$HOME/.sdkman/bin/sdkman-init.sh" + test: stage: test script: - - ./bld download - - ./bld compile - - ./bld test + - ./bld download + - ./bld compile + - ./bld test diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 7c85194..ace99d2 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,10 +1,20 @@ -image: openjdk:17 +image: ubuntu:latest pipelines: default: - step: name: Test with bld script: + # Install latest Java & Kotlin via SDKMAN! + - apt-get update -qq && apt-get install -y curl zip + - curl -s "https://get.sdkman.io" | bash + - echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config + - echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config + - source "$HOME/.sdkman/bin/sdkman-init.sh" + - sdk install java + - sdk install kotlin + - source "$HOME/.sdkman/bin/sdkman-init.sh" + # Download, compile and test with bld - ./bld download - ./bld compile - ./bld test diff --git a/examples/bld/lib/bld/bld-wrapper.properties b/examples/bld/lib/bld/bld-wrapper.properties index d3f0a91..edf4d9d 100644 --- a/examples/bld/lib/bld/bld-wrapper.properties +++ b/examples/bld/lib/bld/bld-wrapper.properties @@ -1,7 +1,6 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-dokka=com.uwyn.rife2:bld-dokka: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.sourceDirectories= diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar index df1100d..93388ee 100644 Binary files a/lib/bld/bld-wrapper.jar and b/lib/bld/bld-wrapper.jar differ diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 3bc38e2..4d7707f 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -2,7 +2,7 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.4 -#bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.0-SNAPSHOT +bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.0-SNAPSHOT bld.extension-gv=com.uwyn.rife2:bld-generated-version:0.9.8-SNAPSHOT bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.6 bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.0-SNAPSHOT diff --git a/src/bld/java/net/thauvin/erik/AkismetBuild.java b/src/bld/java/net/thauvin/erik/AkismetBuild.java index 8037618..dd8922b 100644 --- a/src/bld/java/net/thauvin/erik/AkismetBuild.java +++ b/src/bld/java/net/thauvin/erik/AkismetBuild.java @@ -33,10 +33,10 @@ package net.thauvin.erik; import rife.bld.BuildCommand; import rife.bld.Project; -import rife.bld.extension.CompileKotlinOperation; -import rife.bld.extension.DetektOperation; -import rife.bld.extension.GeneratedVersionOperation; -import rife.bld.extension.JacocoReportOperation; +import rife.bld.extension.*; +import rife.bld.extension.dokka.LoggingLevel; +import rife.bld.extension.dokka.OutputFormat; +import rife.bld.extension.dokka.SourceSet; import rife.bld.extension.kotlin.CompilerPlugin; import rife.bld.operations.exceptions.ExitStatusException; import rife.bld.publish.PomBuilder; @@ -164,30 +164,30 @@ public class AkismetBuild extends Project { .execute(); } -// @BuildCommand(summary = "Generates documentation in HTML format") -// public void docs() throws ExitStatusException, IOException, InterruptedException { -// new DokkaOperation() -// .fromProject(this) -// .loggingLevel(LoggingLevel.INFO) -// .moduleName("Akismet Kotlin") -// .moduleVersion(version.toString()) -// .outputDir("docs") -// .outputFormat(OutputFormat.HTML) -// .sourceSet( -// new SourceSet() -// .src(srcMainKotlin) -// .classpath(compileClasspathJars()) -// .classpath(providedClasspathJars()) -// .srcLink(srcMainKotlin, "https://github.com/ethauvin/" + name -// + "/tree/master/src/main/kotlin/", "#L") -// .includes("config/dokka/packages.md") -// .jdkVersion(javaRelease) -// .externalDocumentationLinks("https://jakarta.ee/specifications/platform/9/apidocs/", -// "https://jakarta.ee/specifications/platform/9/apidocs/package-list") -// -// ) -// .execute(); -// } + @BuildCommand(summary = "Generates documentation in HTML format") + public void docs() throws ExitStatusException, IOException, InterruptedException { + new DokkaOperation() + .fromProject(this) + .loggingLevel(LoggingLevel.INFO) + .moduleName("Akismet Kotlin") + .moduleVersion(version.toString()) + .outputDir("docs") + .outputFormat(OutputFormat.HTML) + .sourceSet( + new SourceSet() + .src(srcMainKotlin) + .classpath(compileClasspathJars()) + .classpath(providedClasspathJars()) + .srcLink(srcMainKotlin, "https://github.com/ethauvin/" + name + + "/tree/master/src/main/kotlin/", "#L") + .includes("config/dokka/packages.md") + .jdkVersion(javaRelease) + .externalDocumentationLinks("https://jakarta.ee/specifications/platform/9/apidocs/", + "https://jakarta.ee/specifications/platform/9/apidocs/package-list") + + ) + .execute(); + } @BuildCommand(summary = "Generates version class") public void genver() throws Exception { @@ -209,24 +209,18 @@ public class AkismetBuild extends Project { .execute(); } -// @Override -// public void javadoc() throws ExitStatusException, IOException, InterruptedException { -// new DokkaOperation() -// .fromProject(this) -// .loggingLevel(LoggingLevel.INFO) -// .moduleName("Bitly Shorten") -// .moduleVersion(version.toString()) -// .outputDir(new File(buildDirectory(), "javadoc")) -// .outputFormat(OutputFormat.JAVADOC) -// .globalLinks("https://jakarta.ee/specifications/platform/9/apidocs/", -// "https://jakarta.ee/specifications/platform/9/apidocs/package-list") -// .execute(); -// } - - @BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory") - public void pomRoot() throws FileUtilsErrorException { - PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(), - new File(workDirectory, "pom.xml")); + @Override + public void javadoc() throws ExitStatusException, IOException, InterruptedException { + new DokkaOperation() + .fromProject(this) + .loggingLevel(LoggingLevel.INFO) + .moduleName("Bitly Shorten") + .moduleVersion(version.toString()) + .outputDir(new File(buildDirectory(), "javadoc")) + .outputFormat(OutputFormat.JAVADOC) + .globalLinks("https://jakarta.ee/specifications/platform/9/apidocs/", + "https://jakarta.ee/specifications/platform/9/apidocs/package-list") + .execute(); } @Override @@ -234,4 +228,10 @@ public class AkismetBuild extends Project { super.publish(); pomRoot(); } + + @BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory") + public void pomRoot() throws FileUtilsErrorException { + PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(), + new File(workDirectory, "pom.xml")); + } } diff --git a/version.txt b/version.txt index 2686ea8..241bbe2 100644 --- a/version.txt +++ b/version.txt @@ -1,14 +1,14 @@ -/* -* This file is automatically generated. -* Do not modify! -- ALL CHANGES WILL BE ERASED! -*/ +/** + * This file is automatically generated. + * Do not modify! -- ALL CHANGES WILL BE ERASED! + */ package {{v packageName/}} /** -* Provides semantic version information. -*/ -internal object {{v className/}} { + * Provides semantic version information. + */ + internal object {{v className/}} { const val PROJECT = "{{v project/}}" const val VERSION = "{{v version/}}" }