diff --git a/.gitattributes b/.gitattributes index cbf7e448..b8c39d9a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,12 +3,9 @@ dependencies.md linguist-genera versionsMavenPluginRules.xml linguist-generated=true doc/changes/changelog.md linguist-generated=true .github/workflows/broken_links_checker.yml linguist-generated=true -.github/workflows/ci-build-next-java.yml linguist-generated=true .github/workflows/ci-build.yml linguist-generated=true .github/workflows/dependencies_check.yml linguist-generated=true -.github/workflows/release_droid_prepare_original_checksum.yml linguist-generated=true -.github/workflows/release_droid_print_quick_checksum.yml linguist-generated=true -.github/workflows/release_droid_release_on_maven_central.yml linguist-generated=true -.github/workflows/release_droid_upload_github_release_assets.yml linguist-generated=true +.github/workflows/dependencies_update.yml linguist-generated=true +.github/workflows/release.yml linguist-generated=true .settings/org.eclipse.jdt.core.prefs linguist-generated=true .settings/org.eclipse.jdt.ui.prefs linguist-generated=true diff --git a/.github/workflows/broken_links_checker.yml b/.github/workflows/broken_links_checker.yml index c4ff3be8..90488caa 100644 --- a/.github/workflows/broken_links_checker.yml +++ b/.github/workflows/broken_links_checker.yml @@ -1,30 +1,35 @@ +# Generated by Project Keeper +# https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/broken_links_checker.yml name: Broken Links Checker on: schedule: - cron: "0 5 * * 0" - push: - branches: - - main - pull_request: jobs: linkChecker: runs-on: ubuntu-latest + permissions: + contents: read + defaults: + run: + shell: "bash" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Configure broken links checker run: | mkdir -p ./target echo '{"aliveStatusCodes": [429, 200], "ignorePatterns": [' \ '{"pattern": "^https?://(www|dev).mysql.com/"},' \ '{"pattern": "^https?://(www.)?opensource.org"}' \ + '{"pattern": "^https?://(www.)?eclipse.org"}' \ + '{"pattern": "^https?://projects.eclipse.org"}' \ ']}' > ./target/broken_links_checker.json - uses: gaurav-nelson/github-action-markdown-link-check@v1 with: - use-quiet-mode: 'yes' - use-verbose-mode: 'yes' + use-quiet-mode: "yes" + use-verbose-mode: "yes" config-file: ./target/broken_links_checker.json diff --git a/.github/workflows/ci-build-next-java.yml b/.github/workflows/ci-build-next-java.yml deleted file mode 100644 index e0c15cfb..00000000 --- a/.github/workflows/ci-build-next-java.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: CI Build next Java - -on: - push: - branches: - - main - pull_request: - -jobs: - java-17-compatibility: - runs-on: ubuntu-latest - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - steps: - - name: Checkout the repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - cache: 'maven' - - name: Run tests and build with Maven - run: | - mvn --batch-mode --update-snapshots clean package -DtrimStackTrace=false \ - -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn - - name: Publish Test Report - uses: scacap/action-surefire-report@v1 - if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }} - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - fail_if_no_tests: false diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index e5208701..7c087e95 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -1,55 +1,217 @@ +# This file was generated by Project Keeper. name: CI Build - on: push: - branches: - - main + branches: [ + main + ] + pull_request: - + types: [ + opened, + synchronize, + reopened, + ready_for_review + ] + + workflow_dispatch: null jobs: - build: + build-and-test: runs-on: ubuntu-latest - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + defaults: + run: { + shell: bash + } + permissions: { + contents: read, + issues: read + } + concurrency: { + group: '${{ github.workflow }}-build-and-test-${{ github.ref }}', cancel-in-progress: true + } + outputs: { + release-required: '${{ steps.check-release.outputs.release-required }}' + } steps: + - name: Free Disk Space + id: free-disk-space + if: ${{ false }} + run: | + sudo rm -rf /usr/local/lib/android + sudo rm -rf /usr/share/dotnet - name: Checkout the repository - uses: actions/checkout@v3 - with: + id: checkout + uses: actions/checkout@v4 + with: { fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v3 + } + - name: Set up JDKs + id: setup-java + uses: actions/setup-java@v4 with: - distribution: 'temurin' - java-version: 11 - cache: 'maven' + distribution: temurin + java-version: |- + 11 + 17 + cache: maven - name: Cache SonarCloud packages - uses: actions/cache@v3 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Enable testcontainer reuse + id: cache-sonar + uses: actions/cache@v4 + with: { + path: ~/.sonar/cache, + key: '${{ runner.os }}-sonar', + restore-keys: '${{ runner.os }}-sonar' + } + - { + name: Enable testcontainer reuse, + id: enable-testcontainer-reuse, run: echo 'testcontainers.reuse.enable=true' > "$HOME/.testcontainers.properties" + } - name: Run tests and build with Maven + id: build-pk-verify run: | mvn --batch-mode clean verify \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -DtrimStackTrace=false - - name: Publish Test Report - uses: scacap/action-surefire-report@v1 - if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }} - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - name: Sonar analysis + id: sonar-analysis if: ${{ env.SONAR_TOKEN != null }} run: | mvn --batch-mode org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -DtrimStackTrace=false \ - -Dsonar.organization=exasol \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.login=$SONAR_TOKEN - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + -Dsonar.token=$SONAR_TOKEN + env: { + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}', + SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}' + } + - name: Verify Release Artifacts + id: verify-release-artifacts + run: "print_message() {\n local -r message=$1\n echo \"$message\"\n echo \"$message\" >> \"$GITHUB_STEP_SUMMARY\"\n}\n\nprint_message \"### Release Artifacts\"\n\nIFS=$'\\n' artifacts_array=($ARTIFACTS)\nmissing_files=()\nfor file in \"${artifacts_array[@]}\";\ndo \n echo \"Checking if file $file exists...\"\n if ! [[ -f \"$file\" ]]; then\n print_message \"* ⚠️ \\`$file\\` does not exist ⚠️\"\n echo \"Content of directory $(dirname \"$file\"):\"\n ls \"$(dirname \"$file\")\"\n missing_files+=(\"$file\")\n else\n print_message \"* \\`$file\\` ✅\" \n fi\ndone\nprint_message \"\"\nnumber_of_missing_files=${#missing_files[@]}\nif [[ $number_of_missing_files -gt 0 ]]; then\n print_message \"⚠️ $number_of_missing_files release artifact(s) missing ⚠️\"\n exit 1\nfi\n" + env: { + ARTIFACTS: '${{ steps.build-pk-verify.outputs.release-artifacts }}' + } + - name: Upload artifacts + id: upload-artifacts + uses: actions/upload-artifact@v4 + with: { + name: artifacts, + path: '${{ steps.build-pk-verify.outputs.release-artifacts }}', + retention-days: 5 + } + - name: Configure link check + id: configure-link-check + run: | + mkdir -p ./target + echo '{"aliveStatusCodes": [429, 200], "ignorePatterns": [' \ + '{"pattern": "^https?://(www|dev).mysql.com/"},' \ + '{"pattern": "^https?://(www.)?opensource.org"}' \ + '{"pattern": "^https?://(www.)?eclipse.org"}' \ + '{"pattern": "^https?://projects.eclipse.org"}' \ + ']}' > ./target/broken_links_checker.json + - uses: gaurav-nelson/github-action-markdown-link-check@v1 + id: run-link-check + with: { + use-quiet-mode: yes, + use-verbose-mode: yes, + config-file: ./target/broken_links_checker.json + } + next-java-compatibility: + runs-on: ubuntu-latest + defaults: + run: { + shell: bash + } + permissions: { + contents: read + } + concurrency: { + group: '${{ github.workflow }}-next-java-${{ github.ref }}', + cancel-in-progress: true + } + steps: + - name: Checkout the repository + id: checkout + uses: actions/checkout@v4 + with: { + fetch-depth: 0 + } + - name: Set up JDK 17 + id: setup-java + uses: actions/setup-java@v4 + with: { + distribution: temurin, + java-version: '17', + cache: maven + } + - { + name: Run tests and build with Maven 17, + id: build-next-java, + run: mvn --batch-mode clean package -DtrimStackTrace=false -Djava.version=17 + } + build: + needs: [ + build-and-test, + next-java-compatibility + ] + runs-on: ubuntu-latest + defaults: + run: { + shell: bash + } + permissions: { + contents: read, + issues: read + } + outputs: { + release-required: '${{ steps.check-release.outputs.release-required }}' + } + steps: + - name: Checkout the repository + id: checkout + uses: actions/checkout@v4 + with: { + fetch-depth: 0 + } + - name: Set up JDKs + id: setup-java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: |- + 11 + 17 + cache: maven + - name: Check if release is needed + id: check-release + if: ${{ github.ref == 'refs/heads/main' }} + run: | + if mvn --batch-mode com.exasol:project-keeper-maven-plugin:verify-release --projects .; then + echo "### ✅ Release preconditions met, start release" >> "$GITHUB_STEP_SUMMARY" + echo "release-required=true" >> "$GITHUB_OUTPUT" + else + echo "### 🛑 Not all release preconditions met, skipping release" >> "$GITHUB_STEP_SUMMARY" + echo "See log output for details." >> "$GITHUB_STEP_SUMMARY" + echo "release-required=false" >> "$GITHUB_OUTPUT" + fi + env: { + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + } + start_release: + needs: build + if: ${{ github.ref == 'refs/heads/main' && needs.build.outputs.release-required == 'true' }} + concurrency: { + cancel-in-progress: false, + group: release + } + secrets: inherit + permissions: { + contents: write, + actions: read, + issues: read + } + uses: ./.github/workflows/release.yml + with: { + started-from-ci: true + } diff --git a/.github/workflows/dependencies_check.yml b/.github/workflows/dependencies_check.yml index b2ab2316..02c5aa06 100644 --- a/.github/workflows/dependencies_check.yml +++ b/.github/workflows/dependencies_check.yml @@ -1,20 +1,80 @@ -name: Dependencies Check - +# This file was generated by Project Keeper. +name: Report Security Issues on: + workflow_dispatch: null schedule: - - cron: "0 2 * * *" - + - { + cron: 0 2 * * * + } jobs: - build: + report_security_issues: runs-on: ubuntu-latest - + defaults: + run: { + shell: bash + } + permissions: { + contents: read, + issues: write + } + outputs: { + created-issues: '${{ steps.security-issues.outputs.created-issues }}' + } + concurrency: { + group: '${{ github.workflow }}-report_security_issues', + cancel-in-progress: true + } steps: - - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 + - { + name: Checkout, + id: checkout, + uses: actions/checkout@v4 + } + - name: Set up JDKs + id: setup-jdks + uses: actions/setup-java@v4 with: - distribution: 'temurin' - java-version: 11 - cache: 'maven' - - name: Checking dependencies for vulnerabilities - run: mvn --batch-mode org.sonatype.ossindex.maven:ossindex-maven-plugin:audit -f pom.xml \ No newline at end of file + distribution: temurin + java-version: |- + 11 + 17 + cache: maven + - name: Generate ossindex report + id: ossindex-report + run: | + mvn --batch-mode org.sonatype.ossindex.maven:ossindex-maven-plugin:audit \ + org.sonatype.ossindex.maven:ossindex-maven-plugin:audit-aggregate \ + -Dossindex.reportFile=$(pwd)/ossindex-report.json \ + -Dossindex.fail=false + - name: Report Security Issues + id: security-issues + uses: exasol/python-toolbox/.github/actions/security-issues@main + with: { + format: maven, + command: cat ossindex-report.json, + github-token: '${{ secrets.GITHUB_TOKEN }}' + } + - name: Output security issues (Debugging) + id: debug-print-security-issues + run: | + echo "$CREATED_ISSUES" > test.jsonl + cat test.jsonl + env: { + CREATED_ISSUES: '${{ steps.security-issues.outputs.created-issues }}' + } + start_dependency_udpate: + needs: report_security_issues + if: ${{ needs.report_security_issues.outputs.created-issues }} + concurrency: { + group: '${{ github.workflow }}-start_dependency_update', + cancel-in-progress: false + } + secrets: inherit + permissions: { + contents: write, + pull-requests: write + } + uses: ./.github/workflows/dependencies_update.yml + with: { + vulnerability_issues: '${{ needs.report_security_issues.outputs.created-issues }}' + } diff --git a/.github/workflows/dependencies_update.yml b/.github/workflows/dependencies_update.yml new file mode 100644 index 00000000..c9015062 --- /dev/null +++ b/.github/workflows/dependencies_update.yml @@ -0,0 +1,176 @@ +# This file was generated by Project Keeper. +name: Update dependencies +on: + workflow_call: + inputs: + vulnerability_issues: { + description: GitHub issues for vulnerable dependencies as JSONL, + required: true, + type: string + } + workflow_dispatch: null +jobs: + update_dependencies: + runs-on: ubuntu-latest + defaults: + run: { + shell: bash + } + permissions: { + contents: write, + pull-requests: write + } + concurrency: { + group: '${{ github.workflow }}', + cancel-in-progress: false + } + steps: + - uses: actions/checkout@v4 + id: checkout + with: { + fetch-depth: 0 + } + - name: Set up JDKs + id: setup-jdks + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: |- + 11 + 17 + cache: maven + - name: Print issues + id: debug-print-issues + run: | + echo "Issues from Action input: $ISSUES" + env: { + ISSUES: '${{ inputs.vulnerability_issues }}' + } + - name: Fail if not running on a branch + id: check-branch + if: ${{ !startsWith(github.ref, 'refs/heads/') }} + uses: actions/github-script@v7 + with: + script: | + core.setFailed('Not running on a branch, github.ref is ${{ github.ref }}. Please start this workflow only on main or a branch') + - name: Update dependencies + id: update-dependencies + run: | + mvn --batch-mode com.exasol:project-keeper-maven-plugin:update-dependencies --projects . \ + -Dproject-keeper:vulnerabilities="$CREATED_ISSUES" + env: { + CREATED_ISSUES: '${{ inputs.vulnerability_issues }}' + } + - name: Generate Pull Request comment + id: pr-comment + run: | + echo 'comment<> "$GITHUB_OUTPUT" + echo 'This Pull Request was created by [`dependencies_update.yml`](https://github.com/exasol/project-keeper/blob/main/project-keeper/src/main/resources/templates/.github/workflows/dependencies_update.yml) workflow.' >> "$GITHUB_OUTPUT" + if [ -n "$CREATED_ISSUES" ]; then + echo 'It updates dependencies to fix the following vulnerabilities:' >> "$GITHUB_OUTPUT" + echo $CREATED_ISSUES | jq --raw-output '. | "* Closes " + .issue_url + " (" + .cve + ")"' >> "$GITHUB_OUTPUT" + else + echo 'It updates dependencies.' >> "$GITHUB_OUTPUT" + fi + echo >> "$GITHUB_OUTPUT" + echo '# ⚠️ Notes ⚠️' >> "$GITHUB_OUTPUT" + echo '## Run PK fix manually' >> "$GITHUB_OUTPUT" + echo 'Due to restrictions workflow `dependencies_update.yml` cannot update other workflows, see https://github.com/exasol/project-keeper/issues/578 for details.' >> "$GITHUB_OUTPUT" + echo 'Please checkout this PR locally and run `mvn com.exasol:project-keeper-maven-plugin:fix --projects .`' >> "$GITHUB_OUTPUT" + echo '## This PR does not trigger CI workflows' >> "$GITHUB_OUTPUT" + echo 'Please click the **Close pull request** button and then **Reopen pull request** to trigger running checks.' >> "$GITHUB_OUTPUT" + echo 'See https://github.com/exasol/project-keeper/issues/534 for details.' >> "$GITHUB_OUTPUT" + echo 'EOF' >> "$GITHUB_OUTPUT" + + cat "$GITHUB_OUTPUT" + env: { + CREATED_ISSUES: '${{ inputs.vulnerability_issues }}' + } + - name: Generate Pull Request Title + id: pr-title + run: | + if [ -n "$CREATED_ISSUES" ]; then + echo "Security issues are available" + echo "title=🔐 Update dependencies to fix vulnerabilities" >> "$GITHUB_OUTPUT" + else + echo "Security issues are not available" + echo "title=Update dependencies" >> "$GITHUB_OUTPUT" + fi + + cat "$GITHUB_OUTPUT" + env: { + CREATED_ISSUES: '${{ inputs.vulnerability_issues }}' + } + - name: Configure git + id: configure-git + run: | + git config --global user.email "opensource@exasol.com" + git config --global user.name "Automatic Dependency Updater" + - name: Create branch + id: create-branch + if: ${{ github.ref == 'refs/heads/main' }} + run: | + branch_name="dependency-update/$(date "+%Y%m%d%H%M%S")" + echo "Creating branch $branch_name" + git checkout -b "$branch_name" + - name: Commit changes & push + id: publish-branch + if: ${{ startsWith(github.ref, 'refs/heads/' ) }} + run: | + branch_name=$(git rev-parse --abbrev-ref HEAD) + echo "Current branch: $branch_name" + echo "git diff --stat" + git diff --stat + echo "git diff --numstat" + git diff --numstat + echo "git diff --name-status" + git diff --name-status + echo "Adding untracked files:" + git add . --verbose --all + echo "Committing changes..." + git commit --message "$TITLE" + echo "Pushing branch $branch_name..." + git push --set-upstream origin "$branch_name" + echo "Done." + env: { + TITLE: '${{ steps.pr-title.outputs.title }}' + } + - name: Create pull request + id: create-pr + if: ${{ github.ref == 'refs/heads/main' }} + run: | + pr_url=$(gh pr create --base main --title "$TITLE" --body "$COMMENT") + echo "Created Pull Request: $pr_url" + echo "pr_url=$pr_url" >> "$GITHUB_OUTPUT" + env: { + COMMENT: '${{ steps.pr-comment.outputs.comment }}', + TITLE: '${{ steps.pr-title.outputs.title }}', + GH_TOKEN: '${{ github.token }}' + } + - name: Report failure Status to Slack channel + id: report-failure-slack + if: ${{ always() }} + uses: ravsamhq/notify-slack-action@v2 + with: { + status: '${{ job.status }}', + token: '${{ secrets.GITHUB_TOKEN }}', + notification_title: 'Dependency check in {repo} has {status_message}', + message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>', + notify_when: 'failure,cancelled,warnings' + } + env: { + SLACK_WEBHOOK_URL: '${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }}' + } + - name: Report new Pull Request to Slack channel + id: report-pr-slack + if: ${{ steps.create-pr.outputs.pr_url }} + uses: ravsamhq/notify-slack-action@v2 + with: { + status: '${{ job.status }}', + token: '${{ secrets.GITHUB_TOKEN }}', + notification_title: 'Dependency update for {repo} created a Pull Request', + message_format: '{workflow} created Pull Request ${{ steps.create-pr.outputs.pr_url }}' + } + env: { + SLACK_WEBHOOK_URL: '${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }}' + } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..e4682a32 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,219 @@ +# This file was generated by Project Keeper. +name: Release +on: + workflow_call: + inputs: + started-from-ci: { + description: 'Marks this release as started from CI, skipping precondition check', + type: boolean, + required: true, + default: false + } + workflow_dispatch: + inputs: + skip-maven-central: { + description: Skip deployment to Maven Central, + required: true, + type: boolean, + default: false + } + skip-github-release: { + description: Skip creating the GitHub release, + required: true, + type: boolean, + default: false + } +jobs: + release: + runs-on: ubuntu-latest + defaults: + run: { + shell: bash + } + concurrency: { + group: '${{ github.workflow }}', + cancel-in-progress: false + } + permissions: { + contents: write, + actions: read, + issues: read + } + steps: + - name: Checkout the repository + id: checkout + uses: actions/checkout@v4 + with: { + fetch-depth: 0 + } + - name: Set up Maven Central Repository + id: configure-maven-central-credentials + if: ${{ true }} + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: |- + 11 + 17 + cache: maven + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Set up JDKs + id: setup-jdks + if: ${{ ! true }} + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: |- + 11 + 17 + cache: maven + - name: Fail if not running on main branch + id: check-main-branch + if: ${{ github.ref != 'refs/heads/main' }} + uses: actions/github-script@v7 + with: + script: | + core.setFailed('Not running on main branch, github.ref is ${{ github.ref }}. Please start this workflow only on main') + - name: Check CI build of this commit succeeded + id: check-ci-build-status + if: ${{ ! inputs.started-from-ci }} + run: | + echo "Commit SHA: $COMMIT_SHA" + gh run list --workflow ci-build.yml --branch main --event push --commit $COMMIT_SHA + ci_build_status=$(gh run list --workflow ci-build.yml --branch main --event push --commit $COMMIT_SHA --json conclusion --template '{{range .}}{{.conclusion}}{{"\n"}}{{end}}') + echo "CI build status at commit $COMMIT_SHA was '$ci_build_status'" + if [[ "$ci_build_status" != "success" ]]; then + gh run list --workflow ci-build.yml --commit $COMMIT_SHA >> $GITHUB_STEP_SUMMARY + echo "Status of CI build for commit $COMMIT_SHA was '$ci_build_status', expected 'success'" >> $GITHUB_STEP_SUMMARY + cat $GITHUB_STEP_SUMMARY + exit 1 + fi + env: { + COMMIT_SHA: '${{ github.sha }}', + GH_TOKEN: '${{ github.token }}' + } + - name: Verify release preconditions + id: verify-release + run: | + mvn --batch-mode com.exasol:project-keeper-maven-plugin:verify-release --projects . + echo "$GITHUB_OUTPUT" + env: { + GITHUB_TOKEN: '${{ github.token }}' + } + - { + name: Build project, + id: build, + run: mvn --batch-mode -DskipTests clean verify + } + - { + name: List secret GPG keys, + id: list-secret-gpg-keys, + if: '${{ true && (! inputs.skip-maven-central) }}', + run: gpg --list-secret-keys + } + - name: Publish to Central Repository + id: deploy-maven-central + if: ${{ true && (! inputs.skip-maven-central) }} + run: | + echo "#### Maven Central Release" >> "$GITHUB_STEP_SUMMARY" + mvn --batch-mode -Dgpg.skip=false -DskipTests deploy + echo "Published to Maven Central ✅" >> "$GITHUB_STEP_SUMMARY" + env: { + MAVEN_USERNAME: '${{ secrets.OSSRH_USERNAME }}', + MAVEN_PASSWORD: '${{ secrets.OSSRH_PASSWORD }}', + MAVEN_GPG_PASSPHRASE: '${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}' + } + - name: Calculate Artifact Checksums + id: artifact-checksum + if: ${{ ! inputs.skip-github-release }} + run: | + echo "Calculating sha256 checksum for artifact files" + echo "artifacts<> "$GITHUB_OUTPUT" + IFS=$'\n' artifacts_array=($ARTIFACTS) + for file in "${artifacts_array[@]}"; + do + full_path=$(realpath "$file") + echo "Calculate sha256sum for file '$full_path'" + file_dir="$(dirname "$full_path")" + file_name=$(basename "$full_path") + pushd "$file_dir" + checksum_file_name="${file_name}.sha256" + sha256sum "$file_name" > "$checksum_file_name" + echo "$full_path" >> "$GITHUB_OUTPUT" + echo "${file_dir}/$checksum_file_name" >> "$GITHUB_OUTPUT" + popd + done + echo "EOF" >> "$GITHUB_OUTPUT" + echo "Full artifact file list" + cat "$GITHUB_OUTPUT" + env: { + ARTIFACTS: '${{ steps.verify-release.outputs.release-artifacts }}' + } + - name: Create GitHub Release + id: create-github-release + if: ${{ ! inputs.skip-github-release }} + run: | + echo "### GitHub Release" >> "$GITHUB_STEP_SUMMARY" + IFS=$'\n' artifacts_array=($ARTIFACTS) + echo "#### Attaching Release Artifacts" >> "$GITHUB_STEP_SUMMARY" + for file in "${artifacts_array[@]}"; + do + echo "Attaching artifact '$file'" + echo "* \`$file\`" >> "$GITHUB_STEP_SUMMARY" + done + echo "" >> "$GITHUB_STEP_SUMMARY" + release_url=$(gh release create --latest --title "$TITLE" --notes "$NOTES" --target main $TAG "${artifacts_array[@]}") + echo "Created release $TAG with title '$TITLE' at $release_url ✅" >> "$GITHUB_STEP_SUMMARY" + echo "release-url=$release_url" >> "$GITHUB_OUTPUT" + + # [impl->dsn~release-workflow.create-golang-tags~1] + echo "#### Creating Additional Tags" >> "$GITHUB_STEP_SUMMARY" + IFS=$'\n' tags_array=($ADDITIONAL_TAGS) + for tag in "${tags_array[@]}"; + do + echo "Creating tag '$tag'" + git tag "$tag" + git push origin "$tag" + echo "* \`$tag\`" >> "$GITHUB_STEP_SUMMARY" + done + + git fetch --tags origin + env: { + GH_TOKEN: '${{ github.token }}', + TAG: '${{ steps.verify-release.outputs.release-tag }}', + ADDITIONAL_TAGS: '${{ steps.verify-release.outputs.additional-release-tags }}', + NOTES: '${{ steps.verify-release.outputs.release-notes }}', + TITLE: '${{ steps.verify-release.outputs.release-title }}', + ARTIFACTS: '${{ steps.artifact-checksum.outputs.artifacts }}' + } + - name: Report failure Status to Slack channel + id: report-failure-status-slack + if: ${{ always() }} + uses: ravsamhq/notify-slack-action@v2 + with: { + status: '${{ job.status }}', + token: '${{ github.token }}', + notification_title: 'Release build in {repo} has {status_message}', + message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>', + notify_when: 'failure,cancelled,warnings,skipped' + } + env: { + SLACK_WEBHOOK_URL: '${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }}' + } + - name: Report new release to Slack channel + id: report-new-release-slack + if: ${{ steps.create-github-release.outputs.release-url }} + uses: ravsamhq/notify-slack-action@v2 + with: { + status: '${{ job.status }}', + token: '${{ github.token }}', + notification_title: 'Release build for {repo} created a new release', + message_format: '{workflow} created release ${{ steps.create-github-release.outputs.release-url }}' + } + env: { + SLACK_WEBHOOK_URL: '${{ secrets.INTEGRATION_TEAM_SLACK_NOTIFICATION_WEBHOOK }}' + } diff --git a/.github/workflows/release_droid_prepare_original_checksum.yml b/.github/workflows/release_droid_prepare_original_checksum.yml deleted file mode 100644 index 4a980f83..00000000 --- a/.github/workflows/release_droid_prepare_original_checksum.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Release Droid - Prepare Original Checksum - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - cache: 'maven' - - name: Enable testcontainer reuse - run: echo 'testcontainers.reuse.enable=true' > "$HOME/.testcontainers.properties" - - name: Run tests and build with Maven - run: mvn --batch-mode clean verify --file pom.xml - - name: Prepare checksum - run: find target -maxdepth 1 -name *.jar -exec sha256sum "{}" + > original_checksum - - name: Upload checksum to the artifactory - uses: actions/upload-artifact@v3 - with: - name: original_checksum - retention-days: 5 - path: original_checksum \ No newline at end of file diff --git a/.github/workflows/release_droid_print_quick_checksum.yml b/.github/workflows/release_droid_print_quick_checksum.yml deleted file mode 100644 index 8add957f..00000000 --- a/.github/workflows/release_droid_print_quick_checksum.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Release Droid - Print Quick Checksum - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - cache: 'maven' - - name: Build with Maven skipping tests - run: mvn --batch-mode clean verify -DskipTests - - name: Print checksum - run: echo 'checksum_start==';find target -maxdepth 1 -name *.jar -exec sha256sum "{}" + | xargs;echo '==checksum_end' - diff --git a/.github/workflows/release_droid_release_on_maven_central.yml b/.github/workflows/release_droid_release_on_maven_central.yml deleted file mode 100644 index b4676072..00000000 --- a/.github/workflows/release_droid_release_on_maven_central.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Release Droid - Release On Maven Central - -on: - workflow_dispatch: - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Maven Central Repository - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - cache: 'maven' - server-id: ossrh - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} - gpg-passphrase: MAVEN_GPG_PASSPHRASE - - name: Publish to Central Repository - run: mvn --batch-mode -Dgpg.skip=false -DskipTests clean deploy - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release_droid_upload_github_release_assets.yml b/.github/workflows/release_droid_upload_github_release_assets.yml deleted file mode 100644 index 7350fafd..00000000 --- a/.github/workflows/release_droid_upload_github_release_assets.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Release Droid - Upload GitHub Release Assets - -on: - workflow_dispatch: - inputs: - upload_url: - description: 'Assets upload URL' - required: true - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - cache: 'maven' - - name: Build with Maven skipping tests - run: mvn --batch-mode clean verify -DskipTests - - name: Generate sha256sum files - run: | - cd target - find . -maxdepth 1 -name \*.jar -exec bash -c 'sha256sum {} > {}.sha256' \; - - name: Upload assets to the GitHub release draft - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ github.event.inputs.upload_url }} - asset_path: target/*.jar - - name: Upload sha256sum files - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ github.event.inputs.upload_url }} - asset_path: target/*.sha256 - - name: Upload error-code-report - uses: shogo82148/actions-upload-release-asset@v1 - with: - upload_url: ${{ github.event.inputs.upload_url }} - asset_path: target/error_code_report.json diff --git a/.gitignore b/.gitignore index 1a0d1f78..31506f1a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ /.project /.settings/org.eclipse.jdt.apt.core.prefs /.settings/org.eclipse.m2e.core.prefs +/.settings/org.eclipse.core.resources.prefs +/.settings/org.sonarlint.eclipse.core.prefs **/*.md.html **/*.bak @@ -33,4 +35,4 @@ pom.xml.versionsBackup *.orig *.old *.md.html -*.flattened-pom.xml \ No newline at end of file +*.flattened-pom.xml diff --git a/.project-keeper.yml b/.project-keeper.yml index 516d7653..8171b782 100644 --- a/.project-keeper.yml +++ b/.project-keeper.yml @@ -4,5 +4,4 @@ sources: modules: - maven_central linkReplacements: - - "https://github.com/hamcrest/JavaHamcrest/hamcrest-all|https://github.com/hamcrest/JavaHamcrest" - "https://www.mojohaus.org/flatten-maven-plugin/flatten-maven-plugin|https://www.mojohaus.org/flatten-maven-plugin/" diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index cdfe4f1b..00000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 8b5a9aaa..7644ed3a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,15 +1,19 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.notowning=org.eclipse.jdt.annotation.NotOwning org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.annotation.owning=org.eclipse.jdt.annotation.Owning +org.eclipse.jdt.core.compiler.annotation.resourceanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.methodParameters=generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=11 @@ -17,6 +21,7 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.APILeak=warning +org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -39,8 +44,10 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompatibleOwningContract=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.insufficientResourceAnalysis=warning org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore @@ -56,15 +63,15 @@ org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning @@ -78,7 +85,8 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning @@ -111,7 +119,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.processAnnotations=enabled +org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false @@ -233,7 +241,7 @@ org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert @@ -439,7 +447,7 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constan org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=false org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs index 1add06a7..54d02acc 100644 --- a/.settings/org.eclipse.jdt.ui.prefs +++ b/.settings/org.eclipse.jdt.ui.prefs @@ -76,6 +76,7 @@ sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false +sp_cleanup.also_simplify_lambda=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=true sp_cleanup.always_use_this_for_non_static_field_access=true @@ -130,6 +131,7 @@ sp_cleanup.one_if_rather_than_duplicate_blocks_that_fall_through=false sp_cleanup.operand_factorization=false sp_cleanup.organize_imports=true sp_cleanup.overridden_assignment=false +sp_cleanup.overridden_assignment_move_decl=false sp_cleanup.plain_replacement=false sp_cleanup.precompile_regex=false sp_cleanup.primitive_comparison=false @@ -159,10 +161,12 @@ sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=true sp_cleanup.remove_unused_imports=true sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_method_parameters=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true +sp_cleanup.replace_deprecated_calls=false sp_cleanup.return_expression=false sp_cleanup.simplify_lambda_expression_and_method_ref=false sp_cleanup.single_used_field=false @@ -174,6 +178,8 @@ sp_cleanup.strictly_equal_or_different=false sp_cleanup.stringbuffer_to_stringbuilder=false sp_cleanup.stringbuilder=false sp_cleanup.stringbuilder_for_local_vars=false +sp_cleanup.stringconcat_stringbuffer_stringbuilder=false +sp_cleanup.stringconcat_to_textblock=false sp_cleanup.substring=false sp_cleanup.switch=false sp_cleanup.system_property=false diff --git a/.settings/org.sonarlint.eclipse.core.prefs b/.settings/org.sonarlint.eclipse.core.prefs deleted file mode 100644 index 8e19a74b..00000000 --- a/.settings/org.sonarlint.eclipse.core.prefs +++ /dev/null @@ -1,6 +0,0 @@ -autoEnabled=true -eclipse.preferences.version=1 -idePrefixKey= -projectKey=com.exasol\:sql-statement-builder -serverId=SonarCloud/exasol -sqPrefixKey= diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..ec804ea1 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,25 @@ +# Security + +If you believe you have found a new security vulnerability in this repository, please report it to us as follows. + +## Reporting Security Issues + +* Please do **not** report security vulnerabilities through public GitHub issues. + +* Please create a draft security advisory on the Github page: the reporting form is under `> Security > Advisories`. The URL is https://github.com/exasol/sql-statement-builder/security/advisories/new. + +* If you prefer to email, please send your report to `infosec@exasol.com`. + +## Guidelines + +* When reporting a vulnerability, please include as much information as possible, including the complete steps to reproduce the issue. + +* Avoid sending us executables. + +* Feel free to include any script you wrote and used but avoid sending us scripts that download and run binaries. + +* We will prioritise reports that show how the exploits work in realistic environments. + +* We prefer all communications to be in English. + +* We do not offer financial rewards. We are happy to acknowledge your research publicly when possible. diff --git a/dependencies.md b/dependencies.md index 2f96d41a..40e4e3e4 100644 --- a/dependencies.md +++ b/dependencies.md @@ -3,75 +3,84 @@ ## Test Dependencies -| Dependency | License | -| ---------------------------------------- | -------------------------------- | -| [JUnit Jupiter (Aggregator)][0] | [Eclipse Public License v2.0][1] | -| [Hamcrest All][2] | [New BSD License][3] | -| [mockito-core][4] | [The MIT License][5] | -| [mockito-junit-jupiter][4] | [The MIT License][5] | -| [EqualsVerifier | release normal jar][6] | [Apache License, Version 2.0][7] | +| Dependency | License | +| ----------------------------------------- | -------------------------------- | +| [JUnit Jupiter (Aggregator)][0] | [Eclipse Public License v2.0][1] | +| [Hamcrest][2] | [BSD-3-Clause][3] | +| [mockito-core][4] | [MIT][5] | +| [mockito-junit-jupiter][4] | [MIT][5] | +| [EqualsVerifier \| release normal jar][6] | [Apache License, Version 2.0][7] | ## Plugin Dependencies -| Dependency | License | -| ------------------------------------------------------- | ---------------------------------------------- | -| [SonarQube Scanner for Maven][8] | [GNU LGPL 3][9] | -| [Apache Maven Compiler Plugin][10] | [Apache License, Version 2.0][7] | -| [Apache Maven Enforcer Plugin][11] | [Apache-2.0][7] | -| [Maven Flatten Plugin][12] | [Apache Software Licenese][7] | -| [org.sonatype.ossindex.maven:ossindex-maven-plugin][13] | [ASL2][14] | -| [Maven Surefire Plugin][15] | [Apache License, Version 2.0][7] | -| [Versions Maven Plugin][16] | [Apache License, Version 2.0][7] | -| [Apache Maven Deploy Plugin][17] | [Apache-2.0][7] | -| [Apache Maven GPG Plugin][18] | [Apache License, Version 2.0][7] | -| [Apache Maven Source Plugin][19] | [Apache License, Version 2.0][7] | -| [Apache Maven Javadoc Plugin][20] | [Apache License, Version 2.0][7] | -| [Nexus Staging Maven Plugin][21] | [Eclipse Public License][22] | -| [JaCoCo :: Maven Plugin][23] | [Eclipse Public License 2.0][24] | -| [error-code-crawler-maven-plugin][25] | [MIT License][26] | -| [Reproducible Build Maven Plugin][27] | [Apache 2.0][14] | -| [OpenFastTrace Maven Plugin][28] | [GNU General Public License v3.0][29] | -| [Project keeper maven plugin][30] | [The MIT License][31] | -| [Maven Clean Plugin][32] | [The Apache Software License, Version 2.0][14] | -| [Maven Resources Plugin][33] | [The Apache Software License, Version 2.0][14] | -| [Maven JAR Plugin][34] | [The Apache Software License, Version 2.0][14] | -| [Maven Install Plugin][35] | [The Apache Software License, Version 2.0][14] | -| [Maven Site Plugin 3][36] | [The Apache Software License, Version 2.0][14] | +| Dependency | License | +| ------------------------------------------------------- | ------------------------------------------- | +| [Apache Maven Clean Plugin][8] | [Apache-2.0][7] | +| [Apache Maven Install Plugin][9] | [Apache-2.0][7] | +| [Apache Maven Resources Plugin][10] | [Apache-2.0][7] | +| [Apache Maven Site Plugin][11] | [Apache-2.0][7] | +| [SonarQube Scanner for Maven][12] | [GNU LGPL 3][13] | +| [Apache Maven Toolchains Plugin][14] | [Apache-2.0][7] | +| [Apache Maven Compiler Plugin][15] | [Apache-2.0][7] | +| [Apache Maven Enforcer Plugin][16] | [Apache-2.0][7] | +| [Maven Flatten Plugin][17] | [Apache Software Licenese][7] | +| [org.sonatype.ossindex.maven:ossindex-maven-plugin][18] | [ASL2][19] | +| [Maven Surefire Plugin][20] | [Apache-2.0][7] | +| [Versions Maven Plugin][21] | [Apache License, Version 2.0][7] | +| [duplicate-finder-maven-plugin Maven Mojo][22] | [Apache License 2.0][23] | +| [Apache Maven Artifact Plugin][24] | [Apache-2.0][7] | +| [Apache Maven Deploy Plugin][25] | [Apache-2.0][7] | +| [Apache Maven GPG Plugin][26] | [Apache-2.0][7] | +| [Apache Maven Source Plugin][27] | [Apache License, Version 2.0][7] | +| [Apache Maven Javadoc Plugin][28] | [Apache-2.0][7] | +| [Nexus Staging Maven Plugin][29] | [Eclipse Public License][30] | +| [JaCoCo :: Maven Plugin][31] | [EPL-2.0][32] | +| [Quality Summarizer Maven Plugin][33] | [MIT License][34] | +| [error-code-crawler-maven-plugin][35] | [MIT License][36] | +| [Git Commit Id Maven Plugin][37] | [GNU Lesser General Public License 3.0][38] | +| [OpenFastTrace Maven Plugin][39] | [GNU General Public License v3.0][40] | +| [Project Keeper Maven plugin][41] | [The MIT License][42] | [0]: https://junit.org/junit5/ [1]: https://www.eclipse.org/legal/epl-v20.html -[2]: https://github.com/hamcrest/JavaHamcrest -[3]: http://www.opensource.org/licenses/bsd-license.php +[2]: http://hamcrest.org/JavaHamcrest/ +[3]: https://raw.githubusercontent.com/hamcrest/JavaHamcrest/master/LICENSE [4]: https://github.com/mockito/mockito -[5]: https://github.com/mockito/mockito/blob/main/LICENSE +[5]: https://opensource.org/licenses/MIT [6]: https://www.jqno.nl/equalsverifier [7]: https://www.apache.org/licenses/LICENSE-2.0.txt -[8]: http://sonarsource.github.io/sonar-scanner-maven/ -[9]: http://www.gnu.org/licenses/lgpl.txt -[10]: https://maven.apache.org/plugins/maven-compiler-plugin/ -[11]: https://maven.apache.org/enforcer/maven-enforcer-plugin/ -[12]: https://www.mojohaus.org/flatten-maven-plugin/ -[13]: https://sonatype.github.io/ossindex-maven/maven-plugin/ -[14]: http://www.apache.org/licenses/LICENSE-2.0.txt -[15]: https://maven.apache.org/surefire/maven-surefire-plugin/ -[16]: https://www.mojohaus.org/versions/versions-maven-plugin/ -[17]: https://maven.apache.org/plugins/maven-deploy-plugin/ -[18]: https://maven.apache.org/plugins/maven-gpg-plugin/ -[19]: https://maven.apache.org/plugins/maven-source-plugin/ -[20]: https://maven.apache.org/plugins/maven-javadoc-plugin/ -[21]: http://www.sonatype.com/public-parent/nexus-maven-plugins/nexus-staging/nexus-staging-maven-plugin/ -[22]: http://www.eclipse.org/legal/epl-v10.html -[23]: https://www.jacoco.org/jacoco/trunk/doc/maven.html -[24]: https://www.eclipse.org/legal/epl-2.0/ -[25]: https://github.com/exasol/error-code-crawler-maven-plugin/ -[26]: https://github.com/exasol/error-code-crawler-maven-plugin/blob/main/LICENSE -[27]: http://zlika.github.io/reproducible-build-maven-plugin -[28]: https://github.com/itsallcode/openfasttrace-maven-plugin -[29]: https://www.gnu.org/licenses/gpl-3.0.html -[30]: https://github.com/exasol/project-keeper/ -[31]: https://github.com/exasol/project-keeper/blob/main/LICENSE -[32]: http://maven.apache.org/plugins/maven-clean-plugin/ -[33]: http://maven.apache.org/plugins/maven-resources-plugin/ -[34]: http://maven.apache.org/plugins/maven-jar-plugin/ -[35]: http://maven.apache.org/plugins/maven-install-plugin/ -[36]: http://maven.apache.org/plugins/maven-site-plugin/ +[8]: https://maven.apache.org/plugins/maven-clean-plugin/ +[9]: https://maven.apache.org/plugins/maven-install-plugin/ +[10]: https://maven.apache.org/plugins/maven-resources-plugin/ +[11]: https://maven.apache.org/plugins/maven-site-plugin/ +[12]: http://docs.sonarqube.org/display/PLUG/Plugin+Library/sonar-maven-plugin +[13]: http://www.gnu.org/licenses/lgpl.txt +[14]: https://maven.apache.org/plugins/maven-toolchains-plugin/ +[15]: https://maven.apache.org/plugins/maven-compiler-plugin/ +[16]: https://maven.apache.org/enforcer/maven-enforcer-plugin/ +[17]: https://www.mojohaus.org/flatten-maven-plugin/ +[18]: https://sonatype.github.io/ossindex-maven/maven-plugin/ +[19]: http://www.apache.org/licenses/LICENSE-2.0.txt +[20]: https://maven.apache.org/surefire/maven-surefire-plugin/ +[21]: https://www.mojohaus.org/versions/versions-maven-plugin/ +[22]: https://basepom.github.io/duplicate-finder-maven-plugin +[23]: http://www.apache.org/licenses/LICENSE-2.0.html +[24]: https://maven.apache.org/plugins/maven-artifact-plugin/ +[25]: https://maven.apache.org/plugins/maven-deploy-plugin/ +[26]: https://maven.apache.org/plugins/maven-gpg-plugin/ +[27]: https://maven.apache.org/plugins/maven-source-plugin/ +[28]: https://maven.apache.org/plugins/maven-javadoc-plugin/ +[29]: http://www.sonatype.com/public-parent/nexus-maven-plugins/nexus-staging/nexus-staging-maven-plugin/ +[30]: http://www.eclipse.org/legal/epl-v10.html +[31]: https://www.jacoco.org/jacoco/trunk/doc/maven.html +[32]: https://www.eclipse.org/legal/epl-2.0/ +[33]: https://github.com/exasol/quality-summarizer-maven-plugin/ +[34]: https://github.com/exasol/quality-summarizer-maven-plugin/blob/main/LICENSE +[35]: https://github.com/exasol/error-code-crawler-maven-plugin/ +[36]: https://github.com/exasol/error-code-crawler-maven-plugin/blob/main/LICENSE +[37]: https://github.com/git-commit-id/git-commit-id-maven-plugin +[38]: http://www.gnu.org/licenses/lgpl-3.0.txt +[39]: https://github.com/itsallcode/openfasttrace-maven-plugin +[40]: https://www.gnu.org/licenses/gpl-3.0.html +[41]: https://github.com/exasol/project-keeper/ +[42]: https://github.com/exasol/project-keeper/blob/main/LICENSE diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index 79c03f56..ab4953a2 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,5 +1,6 @@ # Changes +* [4.6.0](changes_4.6.0.md) * [4.5.3](changes_4.5.3.md) * [4.5.2](changes_4.5.2.md) * [4.5.1](changes_4.5.1.md) diff --git a/doc/changes/changes_4.6.0.md b/doc/changes/changes_4.6.0.md new file mode 100644 index 00000000..a2c0dc55 --- /dev/null +++ b/doc/changes/changes_4.6.0.md @@ -0,0 +1,48 @@ +# Exasol SQL Statement Builder 4.6.0, released 2025-05-07 + +Code name: Timestamps with precision + +## Summary + +This release adds support for specifying the fractional seconds precision for columns of type `TIMESTAMP` and +`TIMESTAMP WITH LOCAL TIMEZONE` + +## Features + +* #176 Support `TIMESTAMP` with precision + +## Dependency Updates + +### Test Dependency Updates + +* Updated `nl.jqno.equalsverifier:equalsverifier:3.14.1` to `3.19.4` +* Removed `org.hamcrest:hamcrest-all:1.3` +* Added `org.hamcrest:hamcrest:3.0` +* Updated `org.junit.jupiter:junit-jupiter:5.9.2` to `5.12.2` +* Updated `org.mockito:mockito-core:5.2.0` to `5.17.0` +* Updated `org.mockito:mockito-junit-jupiter:5.2.0` to `5.17.0` + +### Plugin Dependency Updates + +* Updated `com.exasol:error-code-crawler-maven-plugin:1.2.2` to `2.0.3` +* Updated `com.exasol:project-keeper-maven-plugin:2.9.6` to `5.0.1` +* Added `com.exasol:quality-summarizer-maven-plugin:0.2.0` +* Added `io.github.git-commit-id:git-commit-id-maven-plugin:9.0.1` +* Removed `io.github.zlika:reproducible-build-maven-plugin:0.16` +* Added `org.apache.maven.plugins:maven-artifact-plugin:3.6.0` +* Updated `org.apache.maven.plugins:maven-clean-plugin:3.2.0` to `3.4.1` +* Updated `org.apache.maven.plugins:maven-compiler-plugin:3.10.1` to `3.14.0` +* Updated `org.apache.maven.plugins:maven-deploy-plugin:3.1.0` to `3.1.4` +* Updated `org.apache.maven.plugins:maven-enforcer-plugin:3.2.1` to `3.5.0` +* Updated `org.apache.maven.plugins:maven-gpg-plugin:3.0.1` to `3.2.7` +* Updated `org.apache.maven.plugins:maven-install-plugin:3.1.2` to `3.1.4` +* Updated `org.apache.maven.plugins:maven-javadoc-plugin:3.4.1` to `3.11.2` +* Updated `org.apache.maven.plugins:maven-site-plugin:3.12.1` to `3.21.0` +* Updated `org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M8` to `3.5.2` +* Added `org.apache.maven.plugins:maven-toolchains-plugin:3.2.0` +* Added `org.basepom.maven:duplicate-finder-maven-plugin:2.0.1` +* Updated `org.codehaus.mojo:flatten-maven-plugin:1.3.0` to `1.7.0` +* Updated `org.codehaus.mojo:versions-maven-plugin:2.14.2` to `2.18.0` +* Updated `org.jacoco:jacoco-maven-plugin:0.8.8` to `0.8.12` +* Updated `org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184` to `5.0.0.4389` +* Updated `org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13` to `1.7.0` diff --git a/error_code_config.yml b/error_code_config.yml new file mode 100644 index 00000000..292e4842 --- /dev/null +++ b/error_code_config.yml @@ -0,0 +1,5 @@ +error-tags: + ESB: + packages: + - com.exasol + highest-index: 1 diff --git a/launch/sql-statement-builder all tests.launch b/launch/sql-statement-builder all tests.launch deleted file mode 100644 index 39522676..00000000 --- a/launch/sql-statement-builder all tests.launch +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/launch/sql-statement-builder mvn package.launch b/launch/sql-statement-builder mvn package.launch deleted file mode 100644 index 46b13400..00000000 --- a/launch/sql-statement-builder mvn package.launch +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/pk_generated_parent.pom b/pk_generated_parent.pom index e816bc91..83486be5 100644 --- a/pk_generated_parent.pom +++ b/pk_generated_parent.pom @@ -3,12 +3,15 @@ 4.0.0 com.exasol sql-statement-builder-generated-parent - 4.5.3 + 4.6.0 pom UTF-8 UTF-8 + ${git.commit.time} 11 + exasol + https://sonarcloud.io true @@ -45,24 +48,68 @@ + + org.apache.maven.plugins + maven-clean-plugin + 3.4.1 + + + org.apache.maven.plugins + maven-install-plugin + 3.1.4 + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + org.apache.maven.plugins + maven-site-plugin + 3.21.0 + org.sonarsource.scanner.maven sonar-maven-plugin - 3.9.1.2184 + 5.0.0.4389 + + + org.apache.maven.plugins + maven-toolchains-plugin + 3.2.0 + + + + toolchain + + + + + + + ${java.version} + + + org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.14.0 ${java.version} ${java.version} + true + + -Xlint:all + -Werror + org.apache.maven.plugins maven-enforcer-plugin - 3.2.1 + 3.5.0 enforce-maven @@ -72,8 +119,11 @@ - [3.8.7,3.9.0) + 3.8.7 + + 17 + @@ -82,7 +132,7 @@ org.codehaus.mojo flatten-maven-plugin - 1.3.0 + 1.7.0 true oss @@ -121,7 +171,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M8 + 3.5.2 @@ -132,11 +182,11 @@ org.codehaus.mojo versions-maven-plugin - 2.14.2 + 2.18.0 display-updates - package + verify display-plugin-updates display-dependency-updates @@ -145,12 +195,63 @@ file:///${project.basedir}/versionsMavenPluginRules.xml + false + true + true + true + false + true + true + true + false + false + true + true + + + + org.basepom.maven + duplicate-finder-maven-plugin + 2.0.1 + + + default + verify + + check + + + + + true + true + true + true + true + true + false + true + false + + org.apache.maven.plugins + maven-artifact-plugin + 3.6.0 + + + check-build-plan + verify + + check-buildplan + + + + org.apache.maven.plugins maven-deploy-plugin - 3.1.0 + 3.1.4 true @@ -158,7 +259,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.0.1 + 3.2.7 sign-artifacts @@ -178,6 +279,9 @@ org.apache.maven.plugins maven-source-plugin + 3.2.1 @@ -191,7 +295,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.11.2 attach-javadocs @@ -206,12 +310,14 @@ true true true + true + ${java.version} org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.7.0 true ossrh @@ -232,7 +338,7 @@ org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.12 prepare-agent @@ -270,10 +376,23 @@ + + com.exasol + quality-summarizer-maven-plugin + 0.2.0 + + + summarize-metrics + + summarize + + + + com.exasol error-code-crawler-maven-plugin - 1.2.2 + 2.0.3 verify @@ -284,18 +403,25 @@ - io.github.zlika - reproducible-build-maven-plugin - 0.16 + io.github.git-commit-id + git-commit-id-maven-plugin + 9.0.1 - strip-jar - package + get-the-git-infos - strip-jar + revision + initialize + + true + UTC + + git.commit.time + + diff --git a/pom.xml b/pom.xml index 372e9826..43a4be76 100644 --- a/pom.xml +++ b/pom.xml @@ -3,36 +3,26 @@ 4.0.0 com.exasol sql-statement-builder - 4.5.3 + 4.6.0 Exasol SQL Statement Builder - This module provides a Builder for SQL statements that helps creating the correct structure and + This module provides a Builder for SQL statements that helps to create the correct structure and validates variable parts of the statements. https://github.com/exasol/sql-statement-builder/ 2018 - 5.2.0 + 5.17.0 - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - org.junit.jupiter junit-jupiter - 5.9.2 + 5.12.2 test org.hamcrest - hamcrest-all - 1.3 + hamcrest + 3.0 test @@ -50,20 +40,12 @@ nl.jqno.equalsverifier equalsverifier - 3.14.1 + 3.19.4 test - - com.exasol - error-code-crawler-maven-plugin - - - true - - org.itsallcode openfasttrace-maven-plugin @@ -80,7 +62,7 @@ com.exasol project-keeper-maven-plugin - 2.9.6 + 5.0.1 @@ -94,7 +76,7 @@ sql-statement-builder-generated-parent com.exasol - 4.5.3 + 4.6.0 pk_generated_parent.pom diff --git a/release_config.yml b/release_config.yml deleted file mode 100644 index 473c2193..00000000 --- a/release_config.yml +++ /dev/null @@ -1,4 +0,0 @@ -release-platforms: - - GitHub - - Maven -language: Java diff --git a/src/main/java/com/exasol/datatype/type/AbstractTimestampDataType.java b/src/main/java/com/exasol/datatype/type/AbstractTimestampDataType.java new file mode 100644 index 00000000..c32e78f2 --- /dev/null +++ b/src/main/java/com/exasol/datatype/type/AbstractTimestampDataType.java @@ -0,0 +1,33 @@ +package com.exasol.datatype.type; + +import static java.lang.String.format; + +/** + * Implements common logic for Timestamp types. + */ +public abstract class AbstractTimestampDataType implements DataType { + /** + * Default fractional second precision when not specified: milliseconds + */ + public static final int DEFAULT_FRACTIONAL_SECOND_PRECISION = 3; + + private final int precision; + + AbstractTimestampDataType(final int precision) { + validatePrecision(precision); + this.precision = precision; + } + + /** + * @return precision value + */ + public int getPrecision() { + return this.precision; + } + + private static void validatePrecision(final int precision) { + if (precision < 0 || precision > 9) { + throw new IllegalArgumentException(format("Invalid precision: %d. Must be a number between 0 and 9.", precision)); + } + } +} diff --git a/src/main/java/com/exasol/datatype/type/Timestamp.java b/src/main/java/com/exasol/datatype/type/Timestamp.java index b3742020..afaa3f6b 100644 --- a/src/main/java/com/exasol/datatype/type/Timestamp.java +++ b/src/main/java/com/exasol/datatype/type/Timestamp.java @@ -5,9 +5,27 @@ /** * This class implements the SQl data type timestamp */ -public class Timestamp implements DataType { +public class Timestamp extends AbstractTimestampDataType { private static final String NAME = "TIMESTAMP"; + /** + * Create a new instance of a {@link Timestamp} data type + * + * @param precision fractional seconds precision + */ + public Timestamp(final int precision) { + super(precision); + } + + /** + * Create a new instance of a {@link Timestamp} data type with the default fractional + * seconds precision (3, i.e. millisecond precision) + * + */ + public Timestamp() { + this(DEFAULT_FRACTIONAL_SECOND_PRECISION); + } + @Override public String getName() { return NAME; diff --git a/src/main/java/com/exasol/datatype/type/TimestampWithLocalTimezone.java b/src/main/java/com/exasol/datatype/type/TimestampWithLocalTimezone.java index fa1ced51..ff016a41 100644 --- a/src/main/java/com/exasol/datatype/type/TimestampWithLocalTimezone.java +++ b/src/main/java/com/exasol/datatype/type/TimestampWithLocalTimezone.java @@ -5,9 +5,27 @@ /** * This class implements the Exasol-proprietary data type timestamp with local timezone data */ -public class TimestampWithLocalTimezone implements DataType { +public class TimestampWithLocalTimezone extends AbstractTimestampDataType { private static final String NAME = "TIMESTAMP WITH LOCAL TIME ZONE"; + /** + * Create a new instance of a {@link TimestampWithLocalTimezone} data type + * + * @param precision fractional seconds precision + */ + public TimestampWithLocalTimezone(final int precision) { + super(precision); + } + + /** + * Create a new instance of a {@link TimestampWithLocalTimezone} data type with the default fractional + * seconds precision (3, i.e. millisecond precision) + * + */ + public TimestampWithLocalTimezone() { + this(DEFAULT_FRACTIONAL_SECOND_PRECISION); + } + @Override public String getName() { return NAME; @@ -17,4 +35,5 @@ public String getName() { public void accept(final ColumnDefinitionVisitor visitor) { visitor.visit(this); } + } \ No newline at end of file diff --git a/src/main/java/com/exasol/sql/ColumnsDefinition.java b/src/main/java/com/exasol/sql/ColumnsDefinition.java index 4ed29403..7c51e418 100644 --- a/src/main/java/com/exasol/sql/ColumnsDefinition.java +++ b/src/main/java/com/exasol/sql/ColumnsDefinition.java @@ -13,7 +13,7 @@ public class ColumnsDefinition extends AbstractFragment { private List columns = new ArrayList<>(); /** - * Create an new instance of {@link ColumnsDefinition}. + * Create a new instance of {@link ColumnsDefinition}. * * @param root root statement */ @@ -22,7 +22,7 @@ public ColumnsDefinition(final SqlStatement root) { } /** - * Create an new instance of {@link ColumnsDefinition}. + * Create a new instance of {@link ColumnsDefinition}. * * @param columns list of columns */ @@ -155,6 +155,18 @@ public Builder timestampColumn(final String columnName) { return this; } + /** + * Add timestamp column with the specified fractional seconds precision. + * + * @param columnName name of the column to be added + * @param precision fractional seconds precision + * @return {@code this} for fluent programming + */ + public Builder timestampColumn(final String columnName, final int precision) { + this.columns.add(new Column(null, columnName, new Timestamp(precision))); + return this; + } + /** * Add timestamp with local time zone column. * @@ -166,6 +178,18 @@ public Builder timestampWithLocalTimeZoneColumn(final String columnName) { return this; } + /** + * Add timestamp with local time zone column with the specified fractional seconds precision. + * + * @param columnName name of the column to be added + * @param precision fractional seconds precision + * @return {@code this} for fluent programming + */ + public Builder timestampWithLocalTimeZoneColumn(final String columnName, final int precision) { + this.columns.add(new Column(null, columnName, new TimestampWithLocalTimezone(precision))); + return this; + } + /** * Add interval day to second column. * diff --git a/src/main/java/com/exasol/sql/ddl/create/CreateTable.java b/src/main/java/com/exasol/sql/ddl/create/CreateTable.java index b3463c10..13eccd23 100644 --- a/src/main/java/com/exasol/sql/ddl/create/CreateTable.java +++ b/src/main/java/com/exasol/sql/ddl/create/CreateTable.java @@ -103,6 +103,18 @@ public synchronized CreateTable timestampColumn(final String columnName) { return this; } + /** + * Add timestamp column with the specified fractional seconds precision. + * + * @param columnName name of the column to be added + * @param precision fractional seconds precision + * @return {@code this} for fluent programming + */ + public synchronized CreateTable timestampColumn(final String columnName, final int precision) { + this.columnsDefinition.add(columnName, new Timestamp(precision)); + return this; + } + /** * Add timestamp with local time zone column * @@ -114,6 +126,18 @@ public synchronized CreateTable timestampWithLocalTimeZoneColumn(final String co return this; } + /** + * Add timestamp with local time zone column with the specified fractional seconds precision. + * + * @param columnName name of the column to be added + * @param precision fractional seconds precision + * @return {@code this} for fluent programming + */ + public synchronized CreateTable timestampWithLocalTimeZoneColumn(final String columnName, final int precision) { + this.columnsDefinition.add(columnName, new TimestampWithLocalTimezone(precision)); + return this; + } + /** * Add interval day to second column. * diff --git a/src/main/java/com/exasol/sql/rendering/ColumnsDefinitionRenderer.java b/src/main/java/com/exasol/sql/rendering/ColumnsDefinitionRenderer.java index f9151797..55b5f0b9 100644 --- a/src/main/java/com/exasol/sql/rendering/ColumnsDefinitionRenderer.java +++ b/src/main/java/com/exasol/sql/rendering/ColumnsDefinitionRenderer.java @@ -6,6 +6,8 @@ import com.exasol.datatype.type.Boolean; import com.exasol.sql.*; +import static com.exasol.datatype.type.AbstractTimestampDataType.DEFAULT_FRACTIONAL_SECOND_PRECISION; + /** * Renderer for columns definition. */ @@ -75,12 +77,30 @@ public void visit(final DoublePrecision doublePrecisionColumn) { @Override public void visit(final Timestamp timestampColumn) { - appendDataTypeWithoutParameters(timestampColumn); + if (timestampColumn.getPrecision() == DEFAULT_FRACTIONAL_SECOND_PRECISION) { + appendDataTypeWithoutParameters(timestampColumn); + } else { + appendSpace(); + append(timestampColumn.getName()); + append("("); + append(timestampColumn.getPrecision()); + append(")"); + } } @Override public void visit(final TimestampWithLocalTimezone timestampWithLocalTimezoneColumn) { - appendDataTypeWithoutParameters(timestampWithLocalTimezoneColumn); + if (timestampWithLocalTimezoneColumn.getPrecision() == DEFAULT_FRACTIONAL_SECOND_PRECISION) { + appendDataTypeWithoutParameters(timestampWithLocalTimezoneColumn); + } else { + appendSpace(); + append("TIMESTAMP"); + append("("); + append(timestampWithLocalTimezoneColumn.getPrecision()); + append(")"); + appendSpace(); + append("WITH LOCAL TIME ZONE"); + } } @Override diff --git a/src/test/java/com/exasol/sql/ddl/create/TestCreateTable.java b/src/test/java/com/exasol/sql/ddl/create/TestCreateTable.java index bb037390..8dd9e303 100644 --- a/src/test/java/com/exasol/sql/ddl/create/TestCreateTable.java +++ b/src/test/java/com/exasol/sql/ddl/create/TestCreateTable.java @@ -24,6 +24,7 @@ class TestCreateTable { private static final String DECIMAL_COLUMN_NAME = "decimalColumn"; private static final int PRECISION = 18; private static final int SCALE = 0; + private static final int FRACTIONAL_SECONDS_PRECISION = 9; private static final String DOUBLE_PRECISION_COLUMN_NAME = "doublePrecisionColumn"; private static final String TIMESTAMP_COLUMN_NAME = "timestampColumn"; private static final String TIMESTAMP_WITH_LOCAL_TIMEZONE_COLUMN_NAME = "timestampWithLocalTimeZoneColumn"; @@ -87,15 +88,31 @@ void testCreateTableWithDoublePrecisionColumn() { @Test void testCreateTableWithTimestampColumn() { - final Column column = this.createTable.timestampColumn(TIMESTAMP_COLUMN_NAME).getColumnsDefinition().getColumns().get(0); + final Column column = this.createTable.timestampColumn(TIMESTAMP_COLUMN_NAME) + .getColumnsDefinition().getColumns().get(0); + assertInstance(column, TIMESTAMP_COLUMN_NAME, Timestamp.class); + } + + @Test + void testCreateTableWithTimestampColumnWithPrecision() { + final Column column = this.createTable.timestampColumn(TIMESTAMP_COLUMN_NAME, FRACTIONAL_SECONDS_PRECISION) + .getColumnsDefinition().getColumns().get(0); assertInstance(column, TIMESTAMP_COLUMN_NAME, Timestamp.class); } @Test void testCreateTableWithTimestampWithLocalTimeZoneColumn() { final Column column = this.createTable - .timestampWithLocalTimeZoneColumn(TIMESTAMP_WITH_LOCAL_TIMEZONE_COLUMN_NAME).getColumnsDefinition().getColumns() - .get(0); + .timestampWithLocalTimeZoneColumn(TIMESTAMP_WITH_LOCAL_TIMEZONE_COLUMN_NAME) + .getColumnsDefinition().getColumns().get(0); + assertInstance(column, TIMESTAMP_WITH_LOCAL_TIMEZONE_COLUMN_NAME, TimestampWithLocalTimezone.class); + } + + @Test + void testCreateTableWithTimestampWithLocalTimeZoneColumnWithPrecision() { + final Column column = this.createTable + .timestampWithLocalTimeZoneColumn(TIMESTAMP_WITH_LOCAL_TIMEZONE_COLUMN_NAME, FRACTIONAL_SECONDS_PRECISION) + .getColumnsDefinition().getColumns().get(0); assertInstance(column, TIMESTAMP_WITH_LOCAL_TIMEZONE_COLUMN_NAME, TimestampWithLocalTimezone.class); } diff --git a/src/test/java/com/exasol/sql/ddl/create/rendering/TestCreateTableRendering.java b/src/test/java/com/exasol/sql/ddl/create/rendering/TestCreateTableRendering.java index 42d11a4f..e6686989 100644 --- a/src/test/java/com/exasol/sql/ddl/create/rendering/TestCreateTableRendering.java +++ b/src/test/java/com/exasol/sql/ddl/create/rendering/TestCreateTableRendering.java @@ -55,12 +55,36 @@ void testCreateTableWithTimestampColumn() { assertThat(this.createTable.timestampColumn("a"), rendersTo("CREATE TABLE testName (a TIMESTAMP)")); } + @Test + void testCreateTableWithTimestampColumnWithPrecision() { + assertThat(this.createTable.timestampColumn("a", 9), rendersTo("CREATE TABLE testName (a TIMESTAMP(9))")); + } + + @Test + void testCreateTableWithInvalidTimestampColumn() { + assertThrows(IllegalArgumentException.class, () -> this.createTable.timestampColumn("a", -1)); + assertThrows(IllegalArgumentException.class, () -> this.createTable.timestampColumn("a", 10)); + } + @Test void testCreateTableWithTimestampWithLocalTimeZoneColumn() { assertThat(this.createTable.timestampWithLocalTimeZoneColumn("a"), rendersTo("CREATE TABLE testName (a TIMESTAMP WITH LOCAL TIME ZONE)")); } + @Test + void testCreateTableWithTimestampWithLocalTimeZoneColumnWithPrecision() { + assertThat(this.createTable.timestampWithLocalTimeZoneColumn("a", 6), + rendersTo("CREATE TABLE testName (a TIMESTAMP(6) WITH LOCAL TIME ZONE)")); + } + + @Test + void testCreateTableWithInvalidTimestampWithLocalTimeZoneColumn() { + assertThrows(IllegalArgumentException.class, () -> this.createTable.timestampWithLocalTimeZoneColumn("a", -1)); + assertThrows(IllegalArgumentException.class, () -> this.createTable.timestampWithLocalTimeZoneColumn("a", 10)); + } + + @Test void testCreateTableWithCharColumn() { assertThat(this.createTable.charColumn("a", 10), rendersTo("CREATE TABLE testName (a CHAR(10))")); diff --git a/src/test/java/com/exasol/sql/expression/function/exasol/ExasolScalarFunctionTest.java b/src/test/java/com/exasol/sql/expression/function/exasol/ExasolScalarFunctionTest.java index 27c91da7..e8947f44 100644 --- a/src/test/java/com/exasol/sql/expression/function/exasol/ExasolScalarFunctionTest.java +++ b/src/test/java/com/exasol/sql/expression/function/exasol/ExasolScalarFunctionTest.java @@ -10,6 +10,7 @@ import com.exasol.sql.expression.BooleanTerm; +@SuppressWarnings("removal") class ExasolFunctionTest extends AbstractFunctionTest { @Test void testAggregateFunction() { diff --git a/src/test/java/com/exasol/sql/expression/rendering/ExasolUdfFunctionRenderingTest.java b/src/test/java/com/exasol/sql/expression/rendering/ExasolUdfFunctionRenderingTest.java index a36a4fed..fe506bd9 100644 --- a/src/test/java/com/exasol/sql/expression/rendering/ExasolUdfFunctionRenderingTest.java +++ b/src/test/java/com/exasol/sql/expression/rendering/ExasolUdfFunctionRenderingTest.java @@ -21,12 +21,23 @@ void testUdfFunction() { @Test void testUdfFunctionWithEmits() { - final ColumnsDefinition columnsDefinition = ColumnsDefinition.builder().decimalColumn("id", 18, 0) - .varcharColumn("user_name", 100).decimalColumn("PAGE_VISITS", 18, 0).build(); + final ColumnsDefinition columnsDefinition = ColumnsDefinition.builder() + .decimalColumn("id", 18, 0) + .varcharColumn("user_name", 100) + .decimalColumn("PAGE_VISITS", 18, 0) + .timestampColumn("TS_DEFAULT") + .timestampColumn("TS_NANOS", 9) + .timestampWithLocalTimeZoneColumn("TS_TZ_DEFAULT") + .timestampWithLocalTimeZoneColumn("TS_TZ_NANOS", 9) + .build(); final Select select = StatementFactory.getInstance().select().udf("sample_simple", columnsDefinition, - column("id"), column("user_name"), column("page_visits"), integerLiteral(20)); + column("id"), column("user_name"), column("page_visits"), column("ts_default"), + column("ts_nanos"), column("ts_tz_default"), column("ts_tz_nanos"), integerLiteral(20)); select.from().table("people"); - assertThat(select, rendersTo("SELECT sample_simple(id, user_name, page_visits, 20)" - + " EMITS (id DECIMAL(18,0), user_name VARCHAR(100), PAGE_VISITS DECIMAL(18,0)) FROM people")); + assertThat(select, rendersTo("SELECT sample_simple(id, user_name, page_visits, ts_default, ts_nanos," + + " ts_tz_default, ts_tz_nanos, 20)" + + " EMITS (id DECIMAL(18,0), user_name VARCHAR(100), PAGE_VISITS DECIMAL(18,0), TS_DEFAULT TIMESTAMP," + + " TS_NANOS TIMESTAMP(9), TS_TZ_DEFAULT TIMESTAMP WITH LOCAL TIME ZONE," + + " TS_TZ_NANOS TIMESTAMP(9) WITH LOCAL TIME ZONE) FROM people")); } } \ No newline at end of file diff --git a/src/test/resources/logging.properties b/src/test/resources/logging.properties index 8c97abe9..8d41bf25 100644 --- a/src/test/resources/logging.properties +++ b/src/test/resources/logging.properties @@ -2,5 +2,5 @@ handlers=java.util.logging.ConsoleHandler .level=INFO java.util.logging.ConsoleHandler.level=ALL java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter -java.util.logging.SimpleFormatter.format=%1$tF %1$tT.%1$tL [%4$-7s] %5$s %n +java.util.logging.SimpleFormatter.format=%1$tF %1$tT.%1$tL [%4$-7s] %5$s %6$s%n com.exasol.level=ALL