diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ca7de5b103..982b1b7432 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,11 +1,38 @@ name: CI +run-name: "${{ github.event_name == 'workflow_dispatch' && format('Dispatch : Run integration test with JDK {0} ({1})', inputs.INT_TEST_JAVA_RUNTIME_VERSION, inputs.INT_TEST_JAVA_RUNTIME_VENDOR) || '' }}" on: pull_request: workflow_dispatch: + inputs: + INT_TEST_JAVA_RUNTIME_VERSION: + description: JDK version used to run the integration test + type: choice + required: false + default: '8' + options: + - '8' + - '11' + - '17' + - '21' + INT_TEST_JAVA_RUNTIME_VENDOR: + description: Vendor of the JDK used to run the integration test + type: choice + required: false + default: 'temurin' + options: + - 'corretto' + - 'microsoft' + - 'oracle' + - 'temurin' env: TERM: dumb + JAVA_VERSION: '8' + JAVA_VENDOR: 'temurin' + INT_TEST_JAVA_RUNTIME_VERSION: "${{ github.event_name != 'workflow_dispatch' && '8' || inputs.INT_TEST_JAVA_RUNTIME_VERSION }}" + INT_TEST_JAVA_RUNTIME_VENDOR: "${{ github.event_name != 'workflow_dispatch' && 'temurin' || inputs.INT_TEST_JAVA_RUNTIME_VENDOR }}" + jobs: check: name: Gradle check @@ -13,16 +40,16 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} - name: Setup and execute Gradle 'check' task uses: gradle/gradle-build-action@v2 with: - arguments: check + arguments: check buildSrc:check -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} - name: Save Gradle test reports if: always() @@ -67,11 +94,11 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} - name: Dockerfile Lint for ScalarDB Server uses: gradle/gradle-build-action@v2 @@ -100,16 +127,23 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestCassandra' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestCassandra + arguments: integrationTestCassandra -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -134,16 +168,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestCassandra' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestCassandra + arguments: integrationTestCassandra -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -159,11 +200,18 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Generate unique prefix using the epoch run: | @@ -172,7 +220,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestCosmos' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestCosmos -Dscalardb.cosmos.uri=${{ secrets.COSMOS_URI }} -Dscalardb.cosmos.password=${{ secrets.COSMOS_PASSWORD }} -Dscalardb.cosmos.database_prefix=${{ env.db_prefix }}_ + arguments: integrationTestCosmos -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.cosmos.uri=${{ secrets.COSMOS_URI }} -Dscalardb.cosmos.password=${{ secrets.COSMOS_PASSWORD }} -Dscalardb.cosmos.database_prefix=${{ env.db_prefix }}_ - name : Delete gradle daemon log files if: always() @@ -200,16 +248,23 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestDynamo' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestDynamo + arguments: integrationTestDynamo -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -233,16 +288,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -266,16 +328,24 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} + - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -299,16 +369,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -333,16 +410,23 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres - name: Upload Gradle test reports if: always() @@ -367,16 +451,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres - name: Upload Gradle test reports if: always() @@ -401,16 +492,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres - name: Upload Gradle test reports if: always() @@ -435,16 +533,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:postgresql://localhost:5432/ -Dscalardb.jdbc.username=postgres -Dscalardb.jdbc.password=postgres - name: Upload Gradle test reports if: always() @@ -475,16 +580,23 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle - name: Upload Gradle test reports if: always() @@ -515,16 +627,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/XEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle - name: Upload Gradle test reports if: always() @@ -569,16 +688,23 @@ jobs: - uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/FREEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:oracle:thin:@//localhost:1521/FREEPDB1 -Dscalardb.jdbc.username=SYSTEM -Dscalardb.jdbc.password=Oracle - name: Stop Oracle 23 container if: always() @@ -609,11 +735,18 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Create no superuser run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver17 SqlServer17 10 3 @@ -622,7 +755,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password - name: Upload Gradle test reports if: always() @@ -649,11 +782,18 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Create no superuser run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver19 SqlServer19 10 3 @@ -662,7 +802,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password - name: Upload Gradle test reports if: always() @@ -689,11 +829,18 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Create no superuser run: ./ci/no-superuser/create-no-superuser-sqlserver.sh sqlserver22 SqlServer22 10 3 @@ -702,7 +849,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test_db;encrypt=true;trustServerCertificate=true -Dscalardb.jdbc.username=no_superuser -Dscalardb.jdbc.password=no_superuser_password - name: Upload Gradle test reports if: always() @@ -718,11 +865,18 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Set up SQLite3 run: sudo apt-get install -y sqlite3 @@ -730,7 +884,7 @@ jobs: - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc -Dscalardb.jdbc.url=jdbc:sqlite:integration.sqlite3?busy_timeout=50000 + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} -Dscalardb.jdbc.url=jdbc:sqlite:integration.sqlite3?busy_timeout=50000 - name: Upload Gradle test reports if: always() @@ -754,16 +908,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestJdbc' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestJdbc + arguments: integrationTestJdbc -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports if: always() @@ -794,16 +955,23 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestMultiStorage' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestMultiStorage + arguments: integrationTestMultiStorage -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports uses: actions/upload-artifact@v3 @@ -827,16 +995,23 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 8 + - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) uses: actions/setup-java@v3 with: - java-version: '8' - distribution: 'temurin' + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_VENDOR }} + + - name: Set up JDK ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} (${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }}) to run integration test + uses: actions/setup-java@v4 + if: ${{ !(env.INT_TEST_JAVA_RUNTIME_VERSION == env.JAVA_VERSION && env.INT_TEST_JAVA_RUNTIME_VENDOR == env.JAVA_VENDOR) }} + with: + java-version: ${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} + distribution: ${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Setup and execute Gradle 'integrationTestScalarDbServer' task uses: gradle/gradle-build-action@v2 with: - arguments: integrationTestScalarDbServer + arguments: integrationTestScalarDbServer -PjavaVersion=${{ env.JAVA_VERSION }} -PjavaVendor=${{ env.JAVA_VENDOR }} -PintegrationTestJavaRuntimeVersion=${{ env.INT_TEST_JAVA_RUNTIME_VERSION }} -PintegrationTestJavaRuntimeVendor=${{ env.INT_TEST_JAVA_RUNTIME_VENDOR }} - name: Upload Gradle test reports uses: actions/upload-artifact@v3 diff --git a/build.gradle b/build.gradle index 23dffdd8d6..e44b272bcb 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ subprojects { // apply plugin: 'jacoco' apply plugin: 'java-library-distribution' apply plugin: 'com.diffplug.spotless' + apply plugin: 'com.scalar.db.jdk-configuration' project.version = '3.9.6-SNAPSHOT' @@ -53,10 +54,9 @@ subprojects { log4jVersion = '2.20.0' stefanbirknerSystemLambdaVersion = '1.2.1' spotbugsPluginVersion = '5.0.14' - errorpronePluginVersion = '2.0.2' + errorpronePluginVersion = '3.1.0' protobufPluginVersion = '0.8.19' shadowPluginVersion = '7.1.2' - dockerPluginVersion = '0.34.0' // Make JDK11+ use the same version as JDK8 uses googleJavaFormatVersion = '1.7' } @@ -70,9 +70,6 @@ subprojects { testLogging.showStandardStreams = true } - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - group = "com.scalar-labs" java { @@ -98,3 +95,4 @@ subprojects { duplicatesStrategy DuplicatesStrategy.EXCLUDE } } + diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000000..756d4b74ee --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,26 @@ +plugins { + id 'java-gradle-plugin' + id 'com.diffplug.spotless' version '6.13.0' +} + +repositories { + mavenCentral() +} + +gradlePlugin { + plugins { + jdkConfiguration { + id = 'com.scalar.db.jdk-configuration' + implementationClass = 'com.scalar.db.JdkConfigurationPlugin' + } + } +} + +spotless { + java { + target 'src/*/java/**/*.java' + importOrder() + removeUnusedImports() + googleJavaFormat("1.7") + } +} diff --git a/buildSrc/src/main/java/com/scalar/db/JdkConfigurationPlugin.java b/buildSrc/src/main/java/com/scalar/db/JdkConfigurationPlugin.java new file mode 100644 index 0000000000..3d46261c6a --- /dev/null +++ b/buildSrc/src/main/java/com/scalar/db/JdkConfigurationPlugin.java @@ -0,0 +1,152 @@ +package com.scalar.db; + +import java.util.Objects; +import java.util.function.Consumer; +import javax.annotation.Nullable; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.plugins.JavaPluginExtension; +import org.gradle.api.tasks.testing.Test; +import org.gradle.jvm.toolchain.JavaLanguageVersion; +import org.gradle.jvm.toolchain.JavaToolchainService; +import org.gradle.jvm.toolchain.JvmVendorSpec; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Plugin configuring all tasks and integration test tasks to use a given JDK defined by the + * following Gradle properties: + * + * + * + *

Usage example using the CLI: + * + *

1. To use JDK 11 (amazon) for all Java tasks including integration tests + * + *


+ *   gradle integrationTestJdbc -PjavaVersion=11 -PjavaVendor=amazon
+ * 
+ * + * 2. To use JDK 11 (amazon) for all Java tasks while having integration test use JDK 17 (microsoft) + * + *

+ *   gradle integrationTestJdbc -PjavaVersion=11 -PjavaVendor=amazon -PintegrationTestJavaRuntimeVersion=17 -PintegrationTestJavaRuntimeVendor=microsoft
+ * 
+ */ +public class JdkConfigurationPlugin implements Plugin { + + private static final Logger logger = LoggerFactory.getLogger(JdkConfigurationPlugin.class); + // JDK 8 (temurin) is used as default for all tasks (compilation, tests, etc.) + private static final JavaLanguageVersion DEFAULT_JAVA_VERSION = JavaLanguageVersion.of(8); + private static final JvmVendorSpec DEFAULT_JAVA_VENDOR = JvmVendorSpec.ADOPTIUM; + + private static final String JAVA_VERSION_PROP = "javaVersion"; + private static final String JAVA_VENDOR_PROP = "javaVendor"; + private static final String INTEGRATION_TEST_JAVA_RUNTIME_VERSION_PROP = + "integrationTestJavaRuntimeVersion"; + private static final String INTEGRATION_TEST_JAVA_RUNTIME_VENDOR_PROP = + "integrationTestJavaRuntimeVendor"; + + private JavaLanguageVersion javaVersion = DEFAULT_JAVA_VERSION; + private JvmVendorSpec javaVendor = DEFAULT_JAVA_VENDOR; + @Nullable private JavaLanguageVersion integrationTestJavaVersion; + @Nullable private JvmVendorSpec integrationTestJavaVendor; + + @Override + public void apply(@NotNull Project project) { + parseIntegrationTestInputProperties(project); + configureJdkForAllJavaTasks(project); + configureJdkForIntegrationTestTasks(project); + } + + private void configureJdkForAllJavaTasks(Project project) { + JavaPluginExtension javaPlugin = project.getExtensions().getByType(JavaPluginExtension.class); + javaPlugin.getToolchain().getLanguageVersion().set(javaVersion); + javaPlugin.getToolchain().getVendor().set(javaVendor); + logger.debug("Configure JDK {} ({}) for Java tasks", javaVersion, javaVendor); + } + + private void configureJdkForIntegrationTestTasks(Project project) { + if (integrationTestJavaVersion == null) { + return; + } + project + .getTasks() + .withType(Test.class) + .matching(testTask -> testTask.getName().startsWith("integrationTest")) + .configureEach( + integrationTestTask -> + integrationTestTask + .getJavaLauncher() + .set( + getJavaToolchainService(project) + .launcherFor( + config -> { + config.getLanguageVersion().set(integrationTestJavaVersion); + logger.debug( + "Configure task '{}' to use JDK version {}", + integrationTestTask.getName(), + integrationTestJavaVersion); + if (integrationTestJavaVendor != null) { + config.getVendor().set(integrationTestJavaVendor); + logger.debug( + "Configure task '{}' to use {} JDK vendor", + integrationTestTask.getName(), + integrationTestJavaVendor); + } + }))); + } + + private void parseIntegrationTestInputProperties(Project project) { + parseVersionInputProperty(project, JAVA_VERSION_PROP, (version) -> javaVersion = version); + parseVendorInputProperty(project, JAVA_VENDOR_PROP, (vendor) -> javaVendor = vendor); + parseVersionInputProperty( + project, + INTEGRATION_TEST_JAVA_RUNTIME_VERSION_PROP, + (version) -> integrationTestJavaVersion = version); + parseVendorInputProperty( + project, + INTEGRATION_TEST_JAVA_RUNTIME_VENDOR_PROP, + (vendor) -> integrationTestJavaVendor = vendor); + } + + private void parseVersionInputProperty( + Project project, String property, Consumer attributeSetter) { + if (project.hasProperty(property)) { + attributeSetter.accept(JavaLanguageVersion.of(Objects.toString(project.property(property)))); + } + } + + private void parseVendorInputProperty( + Project project, String property, Consumer attributeSetter) { + if (!project.getRootProject().hasProperty(property)) { + return; + } + String propertyValue = Objects.toString(project.property(property)); + switch (propertyValue) { + case "corretto": + attributeSetter.accept(JvmVendorSpec.AMAZON); + break; + case "temurin": + attributeSetter.accept(JvmVendorSpec.ADOPTIUM); + break; + default: + attributeSetter.accept(JvmVendorSpec.matching(propertyValue)); + } + } + + private @NotNull JavaToolchainService getJavaToolchainService(Project project) { + return project.getExtensions().getByType(JavaToolchainService.class); + } +} diff --git a/core/build.gradle b/core/build.gradle index 494cd07a88..699a6143c1 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -3,6 +3,7 @@ plugins { id 'net.ltgt.errorprone' version "${errorpronePluginVersion}" id 'maven-publish' id 'signing' + id 'base' } sourceSets { @@ -125,7 +126,6 @@ javadoc { title = "ScalarDB" } - task integrationTestCassandra(type: Test) { description = 'Runs the integration tests for Cassandra.' group = 'verification' @@ -133,7 +133,7 @@ task integrationTestCassandra(type: Test) { classpath = sourceSets.integrationTestCassandra.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } } @@ -144,7 +144,7 @@ task integrationTestCosmos(type: Test) { classpath = sourceSets.integrationTestCosmos.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } maxParallelForks = 3 jvmArgs '-XX:MaxDirectMemorySize=2g', '-Xmx4g' @@ -157,7 +157,7 @@ task integrationTestDynamo(type: Test) { classpath = sourceSets.integrationTestDynamo.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } maxParallelForks = 10 } @@ -169,7 +169,7 @@ task integrationTestJdbc(type: Test) { classpath = sourceSets.integrationTestJdbc.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } } @@ -180,7 +180,7 @@ task integrationTestMultiStorage(type: Test) { classpath = sourceSets.integrationTestMultiStorage.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } } @@ -226,7 +226,9 @@ check.dependsOn += spotbugsMain check.dependsOn += spotbugsTest check.dependsOn += spotbugsIntegrationTest -archivesBaseName = "scalardb" +base { + archivesName = "scalardb" +} // for archiving and uploading to maven central publishing { diff --git a/docs/getting-started/build.gradle b/docs/getting-started/build.gradle index 1e966214fe..28dc3a47ba 100644 --- a/docs/getting-started/build.gradle +++ b/docs/getting-started/build.gradle @@ -6,7 +6,7 @@ repositories { mavenCentral() } -mainClassName = "sample.ElectronicMoneyMain" +mainClass = "sample.ElectronicMoneyMain" dependencies { implementation 'com.scalar-labs:scalardb:3.9.5' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index cc4fdc293d..e708b1c023 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0f80bbf516..48c0a02ca4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 2fe81a7d95..4f906e0c81 100755 --- a/gradlew +++ b/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -129,6 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index 24467a141f..ac1b06f938 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/integration-test/build.gradle b/integration-test/build.gradle index 6a35293198..ab78e491d2 100644 --- a/integration-test/build.gradle +++ b/integration-test/build.gradle @@ -3,6 +3,7 @@ plugins { id 'net.ltgt.errorprone' version "${errorpronePluginVersion}" id 'maven-publish' id 'signing' + id 'base' } dependencies { @@ -50,7 +51,9 @@ spotbugsTest.reports { } spotbugsTest.excludeFilter = file("${project.rootDir}/gradle/spotbugs-exclude.xml") -archivesBaseName = "scalardb-integration-test" +base { + archivesName = "scalardb-integration-test" +} // for archiving and uploading to maven central publishing { diff --git a/rpc/build.gradle b/rpc/build.gradle index f80193e89f..b1fba2e1e7 100644 --- a/rpc/build.gradle +++ b/rpc/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.google.protobuf' version "${protobufPluginVersion}" id 'maven-publish' id 'signing' + id 'base' } dependencies { @@ -27,7 +28,9 @@ protobuf { generatedFilesBaseDir = "$projectDir/src" } -archivesBaseName = "scalardb-rpc" +base { + archivesName = "scalardb-rpc" +} // plugin com.google.protobuf generates tasks in runtime so that we have do declare dependencies dynamically tasks.whenTaskAdded { t -> diff --git a/schema-loader/build.gradle b/schema-loader/build.gradle index a673b15da5..97523de479 100644 --- a/schema-loader/build.gradle +++ b/schema-loader/build.gradle @@ -1,13 +1,16 @@ plugins { - id 'com.palantir.docker' version "${dockerPluginVersion}" id 'net.ltgt.errorprone' version "${errorpronePluginVersion}" id 'com.github.johnrengelman.shadow' version "${shadowPluginVersion}" id 'com.github.spotbugs' version "${spotbugsPluginVersion}" id 'maven-publish' id 'signing' + id 'base' +} + +base { + archivesName = "scalardb-schema-loader" } -archivesBaseName = "scalardb-schema-loader" dependencies { implementation project(':core') @@ -34,17 +37,26 @@ javadoc { title = "ScalarDB Schema Loader" } -docker { - dependsOn shadowJar - name "ghcr.io/scalar-labs/scalardb-schema-loader:${project.version}" - files tasks.shadowJar.outputs -} - task dockerfileLint(type: Exec) { description 'Lint the Dockerfile' commandLine "${project.rootDir}/ci/dockerfile_lint.sh" } +task copyFilesToDockerBuildContextDir(type: Copy) { + description 'Copy files to a temporary folder to build the Docker image' + dependsOn shadowJar + from("Dockerfile") + from(tasks.shadowJar.archiveFile) + into('build/docker') +} + +task docker(type: Exec) { + description 'Build ScalarDB Schema Loader Docker image' + dependsOn copyFilesToDockerBuildContextDir + workingDir 'build/docker' + commandLine 'docker', 'build', "--tag=ghcr.io/scalar-labs/scalardb-schema-loader:${project.version}", "." +} + // Build a fat jar shadowJar { archiveClassifier.set("") diff --git a/server/build.gradle b/server/build.gradle index 75a5e012d4..e260034930 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -1,10 +1,10 @@ plugins { id 'application' - id 'com.palantir.docker' version "${dockerPluginVersion}" id 'com.github.spotbugs' version "${spotbugsPluginVersion}" id 'net.ltgt.errorprone' version "${errorpronePluginVersion}" id 'maven-publish' id 'signing' + id 'base' } sourceSets { @@ -65,20 +65,35 @@ javadoc { } application { - mainClassName = 'com.scalar.db.server.ScalarDbServer' + mainClass = 'com.scalar.db.server.ScalarDbServer' startScripts.applicationName = 'scalardb-server' } -docker { - name "ghcr.io/scalar-labs/scalardb-server:${project.version}" - files tasks.distTar.outputs, 'conf/log4j2.properties.tmpl', 'conf/database.properties.tmpl', 'docker-entrypoint.sh' -} - task dockerfileLint(type: Exec) { description 'Lint the Dockerfile' commandLine "${project.rootDir}/ci/dockerfile_lint.sh" } +task copyFilesToDockerBuildContextDir(type: Copy) { + description 'Copy files to a temporary folder to build the Docker image' + dependsOn distTar + from('Dockerfile') + from('conf') { + include 'log4j2.properties.tmpl' + include 'database.properties.tmpl' + } + from('docker-entrypoint.sh') + from(tasks.distTar.archiveFile) + into('build/docker') +} + +task docker(type: Exec) { + description 'Build ScalarDB Server Docker image' + dependsOn copyFilesToDockerBuildContextDir + workingDir 'build/docker' + commandLine 'docker', 'build', "--tag=ghcr.io/scalar-labs/scalardb-server:${project.version}", "." +} + task integrationTestScalarDbServer(type: Test) { useJUnitPlatform() description = 'Runs the integration tests for the ScalarDB Server.' @@ -87,7 +102,7 @@ task integrationTestScalarDbServer(type: Test) { classpath = sourceSets.integrationTestScalarDbServer.runtimeClasspath outputs.upToDateWhen { false } // ensures integration tests are run every time when called options { - systemProperties(System.getProperties()) + systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) } } @@ -115,11 +130,13 @@ spotbugsIntegrationTestScalarDbServer.reports { } spotbugsIntegrationTestScalarDbServer.excludeFilter = file("${project.rootDir}/gradle/spotbugs-exclude.xml") -archivesBaseName = "scalardb-server" +base { + archivesName = "scalardb-server" +} // for release distZip { - archiveFileName = "${archivesBaseName}-${project.version}.zip" + archiveFileName = "${base.archivesName.get()}-${project.version}.zip" } // for docker