From 555fdffec0c95afa2cc14032dece20b2585f2eb3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Ho=C3=9F?= Date: Sun, 18 Apr 2021 04:01:58 +0200 Subject: [PATCH] multiple build enhancements for #127 and #131 --- .github/workflows/build.yml | 41 ++-- .github/workflows/codeql-analysis.yml | 78 +++++++ .github/workflows/release.yml | 244 +++++++++++++++++++++ .github/workflows/update-parent.yml | 44 ++++ pom.xml | 18 +- .../yosql-tooling-gradle/build.gradle.kts | 10 +- .../yosql-tooling-gradle/gradle.properties | 2 + .../yosql-tooling-gradle/settings.gradle.kts | 7 + .../metio/yosql/tooling/gradle/YoSqlPlugin.java | 8 +- yosql-website/content/tooling/gradle.md | 7 +- yosql-website/content/tooling/maven.md | 106 +-------- yosql-website/layouts/shortcodes/gradleplugin.html | 13 ++ yosql-website/layouts/shortcodes/mavenplugin.html | 28 +++ .../layouts/shortcodes/mavenplugin_full.html | 32 +++ .../layouts/shortcodes/mavenplugin_multi.html | 58 +++++ .../layouts/shortcodes/mavenplugin_split.html | 37 ++++ 16 files changed, 600 insertions(+), 133 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/update-parent.yml create mode 100644 yosql-tooling/yosql-tooling-gradle/gradle.properties create mode 100644 yosql-website/layouts/shortcodes/gradleplugin.html create mode 100644 yosql-website/layouts/shortcodes/mavenplugin.html create mode 100644 yosql-website/layouts/shortcodes/mavenplugin_full.html create mode 100644 yosql-website/layouts/shortcodes/mavenplugin_multi.html create mode 100644 yosql-website/layouts/shortcodes/mavenplugin_split.html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ccf8b442..ad327d14 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,9 +4,15 @@ on: branches: [ main ] pull_request: branches: [ main ] +env: + JAVA_VERSION: 16 + JAVA_PACKAGE: jdk + JAVA_ARCH: x64 + JAVA_DISTRO: adopt + PROJECT_URL: yosql.projects.metio.wtf jobs: build: - name: "Build & Deploy" + name: "Build" runs-on: ubuntu-latest steps: - id: checkout @@ -16,10 +22,10 @@ jobs: name: Setup Java uses: actions/setup-java@v2 with: - java-version: 16 - java-package: jdk - architecture: x64 - distribution: 'adopt' + java-version: ${{ env.JAVA_VERSION }} + java-package: ${{ env.JAVA_PACKAGE }} + architecture: ${{ env.JAVA_ARCH }} + distribution: ${{ env.JAVA_DISTRO }} - id: cache name: Cache Maven Repository uses: actions/cache@v2.1.5 @@ -28,14 +34,12 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- - - id: install - name: Install Project + - id: maven + name: Maven Artifacts run: mvn --batch-mode install - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - id: gradle-plugin name: Gradle Plugin - run: cd ./yosql-tooling/yosql-tooling-gradle/ && ./gradlew publishPlugins -Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }} + run: cd ./yosql-tooling/yosql-tooling-gradle/ && ./gradlew build benchmarks: name: Benchmarks runs-on: ubuntu-latest @@ -51,10 +55,10 @@ jobs: name: Setup Java uses: actions/setup-java@v2 with: - java-version: 16 - java-package: jdk - architecture: x64 - distribution: 'adopt' + java-version: ${{ env.JAVA_VERSION }} + java-package: ${{ env.JAVA_PACKAGE }} + architecture: ${{ env.JAVA_ARCH }} + distribution: ${{ env.JAVA_DISTRO }} - id: cache name: Cache Maven Repository uses: actions/cache@v2.1.5 @@ -66,8 +70,6 @@ jobs: - id: run-benchmark name: Run Benchmark [${{ matrix.benchmark }}] run: mvn --batch-mode --projects yosql-benchmarks/yosql-benchmarks-${{ matrix.benchmark }} --also-make --activate-profiles benchmarks verify -Dorg.slf4j.simpleLogger.log.yosql=warn -DskipTests 2>&1 1> build.log - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - id: upload-benchmark name: Upload Benchmark Results uses: actions/upload-artifact@v2 @@ -97,9 +99,14 @@ jobs: - id: copy-jdbc-results name: Copy JDBC Results run: cp ./benchmark-jdbc/yosql-benchmarks-jdbc.json ./yosql-website/content/benchmarks/current/yosql-benchmarks-jdbc.json + - id: previous + name: Get Last Release + run: echo "::set-output name=version::$(git describe --abbrev=0 --tags)" - id: website name: Build Website run: hugo --minify --i18n-warnings --path-warnings --source yosql-website + env: + YOSQL_RELEASE: ${{ steps.previous.outputs.version }} - id: deploy name: Deploy Website uses: peaceiris/actions-gh-pages@v3 @@ -107,4 +114,4 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./yosql-website/public force_orphan: true - cname: yosql.projects.metio.wtf + cname: ${{ env.PROJECT_URL }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..47ad6c3e --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,78 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + paths: + - "src/**" + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '44 20 * * 6' +env: + JAVA_VERSION: 16 + JAVA_PACKAGE: jdk + JAVA_ARCH: x64 + JAVA_DISTRO: adopt +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Set up Java + uses: actions/setup-java@v2 + with: + java-version: ${{ env.JAVA_VERSION }} + java-package: ${{ env.JAVA_PACKAGE }} + architecture: ${{ env.JAVA_ARCH }} + distribution: ${{ env.JAVA_DISTRO }} + - uses: actions/cache@v2.1.5 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + #- run: | + # make bootstrap + # make release + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..7e7b0fe4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,244 @@ +name: Perform Release +on: + schedule: + - cron: "45 3 * * WED" +env: + JAVA_VERSION: 16 + JAVA_PACKAGE: jdk + JAVA_ARCH: x64 + JAVA_DISTRO: adopt + PROJECT_URL: yosql.projects.metio.wtf +jobs: + prepare: + name: Prepare Release + runs-on: ubuntu-latest + outputs: + commit_count: ${{ steps.commits.outputs.count }} + release_version: ${{ steps.release.outputs.version }} + previous_version: ${{ steps.previous.outputs.version }} + changelog: ${{ steps.changelog.outputs.content }} + release_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - id: checkout + name: Clone Git Repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - id: commits + name: Count Commits + run: echo "::set-output name=count::$(git rev-list --count HEAD --since='last Wednesday')" + - id: release + name: Create Release Version + if: steps.commits.outputs.count > 0 + run: echo "::set-output name=version::$(date +'%Y.%-m.%-d')" + - id: previous + name: Get Last Release + if: steps.commits.outputs.count > 0 + run: echo "::set-output name=version::$(git describe --abbrev=0 --tags)" + - id: generate_changelog + name: Generate Changelog + if: steps.commits.outputs.count > 0 + uses: heinrichreimer/github-changelog-generator-action@v2.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + unreleased: true + issues: true + issuesWoLabels: true + pullRequests: true + prWoLabels: true + filterByMilestone: false + futureRelease: ${{ steps.release.outputs.version }} + sinceTag: ${{ steps.previous.outputs.version }} + stripGeneratorNotice: true + stripHeaders: true + - name: Check Changelog Existence + id: check_changelog + uses: andstor/file-existence-action@v1 + with: + files: "CHANGELOG.md" + - name: Create Empty Changelog + id: empty_changelog + uses: 1arp/create-a-file-action@0.2 + if: steps.check_changelog.outputs.files_exists == 'false' + with: + file: CHANGELOG.md + content: | + no user facing changes + - name: Read Changelog + id: changelog + uses: juliangruber/read-file-action@v1 + with: + path: ./CHANGELOG.md + - id: create_release + name: Create Release + if: steps.commits.outputs.count > 0 + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.release.outputs.version }} + release_name: ${{ steps.release.outputs.version }} + draft: false + prerelease: false + body: | + # YoSQL + Write more SQL! Take a look at the [website](https://${{ env.PROJECT_URL }}/) for detailed information. **This release requires at least Java ${{ env.JAVA_VERSION }}**. + ## Changes + ${{ steps.changelog.outputs.content }} + build: + name: "Build & Deploy" + runs-on: ubuntu-latest + needs: prepare + steps: + - id: checkout + name: Clone Git Repository + uses: actions/checkout@v2 + if: needs.prepare.outputs.commit_count > 0 + - id: java + name: Setup Java + uses: actions/setup-java@v2 + if: needs.prepare.outputs.commit_count > 0 + with: + java-version: ${{ env.JAVA_VERSION }} + java-package: ${{ env.JAVA_PACKAGE }} + architecture: ${{ env.JAVA_ARCH }} + distribution: ${{ env.JAVA_DISTRO }} + server-id: ossrh + server-username: MAVEN_CENTRAL_USERNAME + server-password: MAVEN_CENTRAL_TOKEN + - id: cache + name: Cache Maven Repository + uses: actions/cache@v2.1.5 + if: needs.prepare.outputs.commit_count > 0 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Set release version + run: mvn --batch-mode versions:set -DnewVersion=${{ needs.prepare.outputs.release_version }} -DgenerateBackupPoms=false + if: needs.prepare.outputs.commit_count > 0 + - id: deploy-maven + name: Deploy Maven Artifacts + run: mvn --batch-mode install deploy + if: needs.prepare.outputs.commit_count > 0 + env: + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} + - id: deploy-gradle + name: Deploy Gradle Plugin + run: cd ./yosql-tooling/yosql-tooling-gradle/ && ./gradlew publishPlugins -Pversion=${{ needs.prepare.outputs.release_version }} -Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }} + if: needs.prepare.outputs.commit_count > 0 + benchmarks: + name: Benchmarks + runs-on: ubuntu-latest + needs: [prepare, build] + strategy: + matrix: + benchmark: ["codegen", "jdbc"] + steps: + - id: checkout + name: Clone Git Repository + uses: actions/checkout@v2 + if: needs.prepare.outputs.commit_count > 0 + - id: java + name: Setup Java + uses: actions/setup-java@v2 + if: needs.prepare.outputs.commit_count > 0 + with: + java-version: ${{ env.JAVA_VERSION }} + java-package: ${{ env.JAVA_PACKAGE }} + architecture: ${{ env.JAVA_ARCH }} + distribution: ${{ env.JAVA_DISTRO }} + - id: cache + name: Cache Maven Repository + uses: actions/cache@v2.1.5 + if: needs.prepare.outputs.commit_count > 0 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - id: run-benchmark + name: Run Benchmark [${{ matrix.benchmark }}] + run: mvn --batch-mode --projects yosql-benchmarks/yosql-benchmarks-${{ matrix.benchmark }} --also-make --activate-profiles benchmarks verify -Dorg.slf4j.simpleLogger.log.yosql=warn -DskipTests 2>&1 1> build.log + if: needs.prepare.outputs.commit_count > 0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - id: upload-benchmark + name: Upload Benchmark Results + uses: actions/upload-artifact@v2 + if: needs.prepare.outputs.commit_count > 0 + with: + name: benchmark-${{ matrix.benchmark }} + path: ./yosql-benchmarks/yosql-benchmarks-${{ matrix.benchmark }}/target/benchmark/yosql-benchmarks-${{ matrix.benchmark }}.json + website: + name: Website + runs-on: ubuntu-latest + needs: [prepare, benchmarks] + if: ${{ github.ref == 'refs/heads/main' }} + steps: + - id: checkout + name: Clone Git Repository + uses: actions/checkout@v2 + if: needs.prepare.outputs.commit_count > 0 + - id: hugo + name: Setup Hugo + uses: peaceiris/actions-hugo@v2 + if: needs.prepare.outputs.commit_count > 0 + with: + hugo-version: latest + - id: download + name: Download Benchmarks Results + uses: actions/download-artifact@v2 + if: needs.prepare.outputs.commit_count > 0 + - id: copy-codegen-results + name: Copy Codegen Results + run: cp ./benchmark-codegen/yosql-benchmarks-codegen.json ./yosql-website/content/benchmarks/releases/yosql-benchmarks-codegen.json + if: needs.prepare.outputs.commit_count > 0 + - id: copy-jdbc-results + name: Copy JDBC Results + run: cp ./benchmark-jdbc/yosql-benchmarks-jdbc.json ./yosql-website/content/benchmarks/releases/yosql-benchmarks-jdbc.json + if: needs.prepare.outputs.commit_count > 0 + - id: website + name: Build Website + run: hugo --minify --i18n-warnings --path-warnings --source yosql-website + if: needs.prepare.outputs.commit_count > 0 + env: + YOSQL_RELEASE: ${{ needs.prepare.outputs.release_version }} + - id: deploy + name: Deploy Website + uses: peaceiris/actions-gh-pages@v3 + if: needs.prepare.outputs.commit_count > 0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./yosql-website/public + force_orphan: true + cname: ${{ env.PROJECT_URL }} + announce: + name: Announcements + needs: [prepare, website] + runs-on: ubuntu-latest + steps: + - id: email + name: Send Mail + uses: dawidd6/action-send-mail@v2 + if: needs.prepare.outputs.commit_count > 0 + with: + server_address: ${{ secrets.MAIL_SERVER }} + server_port: ${{ secrets.MAIL_PORT }} + username: ${{ secrets.MAIL_USERNAME }} + password: ${{ secrets.MAIL_PASSWORD }} + to: ${{ secrets.MAIL_TO }} + from: ${{ secrets.MAIL_SENDER }} + subject: "release ${{ needs.prepare.outputs.release_version }}" + body: See https://github.com/metio/yosql/releases/tag/${{ needs.prepare.outputs.release_version }} for details. + - id: matrix + name: Send Matrix Message + uses: s3krit/matrix-message-action@v0.0.3 + if: needs.prepare.outputs.commit_count > 0 + with: + access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} + room_id: ${{ secrets.MATRIX_ROOM_ID }} + server: ${{ secrets.MATRIX_SERVER }} + message: "release ${{ needs.prepare.outputs.release_version }} published - see https://github.com/metio/yosql/releases/tag/${{ needs.prepare.outputs.release_version }} for details" diff --git a/.github/workflows/update-parent.yml b/.github/workflows/update-parent.yml new file mode 100644 index 00000000..279450a8 --- /dev/null +++ b/.github/workflows/update-parent.yml @@ -0,0 +1,44 @@ +name: Update Parent +on: + schedule: + - cron: "0 1 28 * *" +env: + JAVA_VERSION: 16 + JAVA_PACKAGE: jdk + JAVA_ARCH: x64 + JAVA_DISTRO: adopt +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Java + uses: actions/setup-java@v2 + with: + java-version: ${{ env.JAVA_VERSION }} + java-package: ${{ env.JAVA_PACKAGE }} + architecture: ${{ env.JAVA_ARCH }} + distribution: ${{ env.JAVA_DISTRO }} + - uses: actions/cache@v2.1.5 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Update parent + run: mvn --batch-mode versions:update-parent -DgenerateBackupPoms=false + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v3.8.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update parent to latest version + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + title: 'Update parent to latest version' + body: | + `mvn --batch-mode versions:update-parent -DgenerateBackupPoms=false` + labels: enhancement + assignees: sebhoss + draft: false + branch: update-parent diff --git a/pom.xml b/pom.xml index 1a1aa6fe..9d4b560e 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ wtf.metio.maven.parents maven-parents-java-prototype - 2021.4.9 + 2021.4.16 @@ -70,6 +70,22 @@ + + + + + + metio + official website + https://yosql.projects.metio.wtf + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + + diff --git a/yosql-tooling/yosql-tooling-gradle/build.gradle.kts b/yosql-tooling/yosql-tooling-gradle/build.gradle.kts index 329e7d11..8d385f04 100644 --- a/yosql-tooling/yosql-tooling-gradle/build.gradle.kts +++ b/yosql-tooling/yosql-tooling-gradle/build.gradle.kts @@ -11,14 +11,6 @@ plugins { id("com.gradle.plugin-publish") version "0.12.0" } -group = "wtf.metio.yosql.tooling.gradle" -version = "2021.4.13" - -repositories { - mavenCentral() - mavenLocal() -} - java { toolchain { languageVersion.set(JavaLanguageVersion.of(16)) @@ -41,7 +33,7 @@ pluginBundle { } dependencies { - implementation("wtf.metio.yosql.tooling:yosql-tooling-dagger:0.0.0-SNAPSHOT") + implementation("wtf.metio.yosql.tooling:yosql-tooling-dagger:${version}") } tasks.named("wrapper") { diff --git a/yosql-tooling/yosql-tooling-gradle/gradle.properties b/yosql-tooling/yosql-tooling-gradle/gradle.properties new file mode 100644 index 00000000..bba58f4e --- /dev/null +++ b/yosql-tooling/yosql-tooling-gradle/gradle.properties @@ -0,0 +1,2 @@ +version=0.0.0-SNAPSHOT +group=wtf.metio.yosql.tooling.gradle diff --git a/yosql-tooling/yosql-tooling-gradle/settings.gradle.kts b/yosql-tooling/yosql-tooling-gradle/settings.gradle.kts index 39d5e9b6..00e4ec47 100644 --- a/yosql-tooling/yosql-tooling-gradle/settings.gradle.kts +++ b/yosql-tooling/yosql-tooling-gradle/settings.gradle.kts @@ -1 +1,8 @@ rootProject.name = "yosql-tooling-gradle" + +dependencyResolutionManagement { + repositories { + mavenCentral() + mavenLocal() + } +} diff --git a/yosql-tooling/yosql-tooling-gradle/src/main/java/wtf/metio/yosql/tooling/gradle/YoSqlPlugin.java b/yosql-tooling/yosql-tooling-gradle/src/main/java/wtf/metio/yosql/tooling/gradle/YoSqlPlugin.java index a0df3efe..f5f634e6 100644 --- a/yosql-tooling/yosql-tooling-gradle/src/main/java/wtf/metio/yosql/tooling/gradle/YoSqlPlugin.java +++ b/yosql-tooling/yosql-tooling-gradle/src/main/java/wtf/metio/yosql/tooling/gradle/YoSqlPlugin.java @@ -17,12 +17,10 @@ public class YoSqlPlugin implements Plugin { @Override public void apply(final Project project) { - final var extension = project.getExtensions() - .create("yosql", YoSqlExtension.class); + final var extension = project.getExtensions().create("yosql", YoSqlExtension.class); - project.getTasks().register("generateJavaCode", GenerateTask.class, task -> { - task.getFiles().set(extension.files()); - }); + project.getTasks().register("generateJavaCode", GenerateTask.class, task -> + task.getFiles().set(extension.files())); } } diff --git a/yosql-website/content/tooling/gradle.md b/yosql-website/content/tooling/gradle.md index 48182c51..098b28c2 100644 --- a/yosql-website/content/tooling/gradle.md +++ b/yosql-website/content/tooling/gradle.md @@ -12,12 +12,7 @@ tags: [Gradle](https://gradle.org/) projects can use the [yosql-tooling-gradle](https://plugins.gradle.org/plugin/wtf.metio.yosql) plugin to use `YoSQL` in their builds. The following steps show how a basic setup looks like. In case you are looking for more details, check out the configuration section further down below. -1. Add the plugin to your `build.gradle.kts`: - ```kotlin - plugins { - id("wtf.metio.yosql") - } - ``` +1. Add the [plugin](https://plugins.gradle.org/plugin/wtf.metio.yosql) to your `build.gradle(.kts)` file as describe in the Gradle plugin portal. 2. Add .sql files in `src/main/yosql` and write SQL statements into them. Take a look at the various options to [structure](/sql/structure/) your [SQL files](/sql/sql-files/). ``` / diff --git a/yosql-website/content/tooling/maven.md b/yosql-website/content/tooling/maven.md index 1d3b7d70..63894174 100644 --- a/yosql-website/content/tooling/maven.md +++ b/yosql-website/content/tooling/maven.md @@ -12,26 +12,8 @@ tags: [Maven](https://maven.apache.org/) projects can use the `yosql-tooling-maven` plugin to use `YoSQL` in their builds. The following steps show how a basic setup looks like. In case you are looking for more details, check out the configuration section further down below. -1. Add the plugin to your `pom.xml`: - ```xml - - - ... - - wtf.metio.yosql - yosql-tooling-maven - - - - generate - - - - - ... - - - ``` +1. Add the [plugin](https://search.maven.org/artifact/wtf.metio.yosql.tooling/yosql-tooling-maven) to your `pom.xml`: + {{< mavenplugin >}} 2. Add .sql files in `src/main/yosql` and write SQL statements into them. Take a look at the various options to [structure](/sql/structure/) your [SQL files](/sql/sql-files/). ``` / @@ -84,31 +66,7 @@ As an optional and final step to complete the setup of `YoSQL`, you can add the You can configure how YoSQL operates and how the generated code looks like by using the [default Maven configuration mechanism](https://maven.apache.org/guides/mini/guide-configuring-plugins.html). Take a look at the [available configuration options](/configuration/) in order to see what can be configured. -```xml - - - ... - - wtf.metio.yosql - yosql-tooling-maven - - - configValue - - - - generate-sources - - generate - - - - - - ... - - -``` +{{< mavenplugin_full >}} The `generate` goal binds itself automatically to the `generate-sources` phase. In case you want to run it in another phase, change the above example accordingly. @@ -125,54 +83,12 @@ In some cases it might be preferable to generate some repositories with a specif Make sure that multiple executions do not make use of the same .sql files. Otherwise, the executions will overwrite the generated code of each other. The last execution will win. Share configuration across all executions by using a single top level `configuration` block. -```xml - - - ... - - wtf.metio.yosql - yosql-tooling-maven - - - your.domain.persistence - - - - - config-a - - generate - - - - src/main/database/reactive - - - true - - - - - - - config-b - - generate - - - - src/main/database/synchronous - - - 16 - - - - - - ... - - -``` +{{< mavenplugin_multi >}} + +#### Dev/Prod Split + +In case you want generate logging statements while developing, but not have any log statements in production code in order to optimize runtime performance, you can use the following setup: + +{{< mavenplugin_split >}} -TODO: split dev/prod builds? dev build contains log outputs, prod build contains none +This setup requires no additional step during development (which you would have to do a lot), but instead allows you to specify the logging API like this `mvn -DloggingApi=NONE` in order to change the logging API per invocation of Maven, thus allow you to pass in `NONE` to disable log statements during release builds. diff --git a/yosql-website/layouts/shortcodes/gradleplugin.html b/yosql-website/layouts/shortcodes/gradleplugin.html new file mode 100644 index 00000000..06f5ec71 --- /dev/null +++ b/yosql-website/layouts/shortcodes/gradleplugin.html @@ -0,0 +1,13 @@ + + +

+plugins {
+  id("wtf.metio.yosql") version "{{ getenv "YOSQL_RELEASE" }}"
+}
+
+
diff --git a/yosql-website/layouts/shortcodes/mavenplugin.html b/yosql-website/layouts/shortcodes/mavenplugin.html new file mode 100644 index 00000000..ff549c98 --- /dev/null +++ b/yosql-website/layouts/shortcodes/mavenplugin.html @@ -0,0 +1,28 @@ + + +

+<build>
+    <plugins>
+        ...
+        <plugin>
+            <groupId>wtf.metio.yosql</groupId>
+            <artifactId>yosql-tooling-maven</artifactId>
+            <version>{{ getenv "YOSQL_RELEASE" }}</version>
+            <executions>
+                <execution>
+                    <goals>
+                        <goal>generate</goal>
+                    </goals>
+                </execution>
+            </executions>
+        </plugin>
+        ...
+    </plugins>
+</build>
+
+
diff --git a/yosql-website/layouts/shortcodes/mavenplugin_full.html b/yosql-website/layouts/shortcodes/mavenplugin_full.html new file mode 100644 index 00000000..dc52974e --- /dev/null +++ b/yosql-website/layouts/shortcodes/mavenplugin_full.html @@ -0,0 +1,32 @@ + + +

+<build>
+    <plugins>
+        ...
+        <plugin>
+            <groupId>wtf.metio.yosql</groupId>
+            <artifactId>yosql-tooling-maven</artifactId>
+            <version>{{ getenv "YOSQL_RELEASE" }}</version>
+            <configuration>
+              <configOption>configValue</configOption>
+            </configuration>
+            <executions>
+                <execution>
+                    <phase>generate-sources</phase>
+                    <goals>
+                        <goal>generate</goal>
+                    </goals>
+                </execution>
+            </executions>
+        </plugin>
+        ...
+    </plugins>
+</build>
+
+
diff --git a/yosql-website/layouts/shortcodes/mavenplugin_multi.html b/yosql-website/layouts/shortcodes/mavenplugin_multi.html new file mode 100644 index 00000000..5b5cf6b4 --- /dev/null +++ b/yosql-website/layouts/shortcodes/mavenplugin_multi.html @@ -0,0 +1,58 @@ + + +

+<build>
+    <plugins>
+        ...
+        <plugin>
+            <groupId>wtf.metio.yosql</groupId>
+            <artifactId>yosql-tooling-maven</artifactId>
+            <version>{{ getenv "YOSQL_RELEASE" }}</version>
+            <configuration>
+                <repositories>
+                    <basePackageName>your.domain.persistence</basePackageName>
+                </repositories>
+            </configuration>
+            <executions>
+                <execution>
+                    <id>cofig-a</id>
+                    <goals>
+                        <goal>generate</goal>
+                    </goals>
+                    <configuration>
+                        <files>
+                            <inputBaseDirectory>src/main/database/reactive</inputBaseDirectory>
+                        </files>
+                        <repositories>
+                            <generateRxJavaApi>true</generateRxJavaApi>
+                        </repositories>
+                    </configuration>
+                </execution>
+            </executions>
+            <executions>
+                <execution>
+                    <id>config-b</id>
+                    <goals>
+                        <goal>generate</goal>
+                    </goals>
+                    <configuration>
+                        <files>
+                            <inputBaseDirectory>src/main/database/synchronous</inputBaseDirectory>
+                        </files>
+                        <repositories>
+                            <apiVersion>16</apiVersion>
+                        </repositories>
+                    </configuration>
+                </execution>
+            </executions>
+        </plugin>
+        ...
+    </plugins>
+</build>
+
+
diff --git a/yosql-website/layouts/shortcodes/mavenplugin_split.html b/yosql-website/layouts/shortcodes/mavenplugin_split.html new file mode 100644 index 00000000..97a28277 --- /dev/null +++ b/yosql-website/layouts/shortcodes/mavenplugin_split.html @@ -0,0 +1,37 @@ + + +

+<properties>
+    <loggingApi>SLF4J</loggingApi>
+</properties>
+<build>
+    <plugins>
+        ...
+        <plugin>
+            <groupId>wtf.metio.yosql</groupId>
+            <artifactId>yosql-tooling-maven</artifactId>
+            <version>{{ getenv "YOSQL_RELEASE" }}</version>
+            <configuration>
+              <apis>
+                <loggingApi>${loggingApi}</loggingApi>
+              </apis>
+            </configuration>
+            <executions>
+                <execution>
+                    <phase>generate-sources</phase>
+                    <goals>
+                        <goal>generate</goal>
+                    </goals>
+                </execution>
+            </executions>
+        </plugin>
+        ...
+    </plugins>
+</build>
+
+
-- 2.11.4.GIT