From 71265bd14e0aa676412f84fab1e0107998e69834 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 25 Oct 2024 06:15:29 +0800 Subject: [PATCH 01/52] Comment out the Maven local repositories for Gradle `buildSrc` and projects so the build is always reproducible by others --- buildSrc/build.gradle.kts | 2 +- buildSrc/src/main/kotlin/common-conventions.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5af5195f..5f62dd70 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } repositories { - mavenLocal() // TODO comment out when not needed + //mavenLocal() // comment out when not needed gradlePluginPortal() google() mavenCentral() diff --git a/buildSrc/src/main/kotlin/common-conventions.gradle.kts b/buildSrc/src/main/kotlin/common-conventions.gradle.kts index e525ae45..de8d1d92 100644 --- a/buildSrc/src/main/kotlin/common-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/common-conventions.gradle.kts @@ -8,7 +8,7 @@ plugins { } repositories { - mavenLocal() + //mavenLocal() // commented out so the build is always reproducible by others // put back if needed when depending on a snapshot mavenCentral() google() maven("https://us-central1-maven.pkg.dev/varabyte-repos/public") // for Kobweb From 755a2593006cfd9f117793a11efd23f83eecc851 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 25 Oct 2024 06:15:55 +0800 Subject: [PATCH 02/52] Bump the project version --- buildSrc/src/main/kotlin/VersionsAndDependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt index 1dabdf34..43563b5e 100644 --- a/buildSrc/src/main/kotlin/VersionsAndDependencies.kt +++ b/buildSrc/src/main/kotlin/VersionsAndDependencies.kt @@ -1,7 +1,7 @@ import com.huanshankeji.CommonDependencies import org.jetbrains.compose.ComposeBuildConfig -val projectVersion = "0.4.0-SNAPSHOT" +val projectVersion = "0.4.1-SNAPSHOT" val commonDependencies = CommonDependencies() From 2f09b5be8f5db83ed8b3f5d08948e7cfa397b8ab Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 2 Nov 2024 16:03:29 +0800 Subject: [PATCH 03/52] Add the "Java with Gradle" GitHub Actions template without editing it yet --- .github/workflows/gradle.yml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 00000000..87d5ecb5 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,67 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + + - name: Build with Gradle Wrapper + run: ./gradlew build + + # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). + # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. + # + # - name: Setup Gradle + # uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + # with: + # gradle-version: '8.9' + # + # - name: Build with Gradle 8.9 + # run: gradle build + + dependency-submission: + + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. + # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 From a57a6080f5bb0e300a82c7d639d0bc18b69be409 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 2 Nov 2024 16:33:11 +0800 Subject: [PATCH 04/52] Update the workflow file to run on all branches, all OSs, use JDK 21, run "check" instead of "build", and use gradle/actions of a the latest release version --- .github/workflows/gradle.yml | 39 ++++++++++++------------------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 87d5ecb5..f51890d0 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -9,59 +9,46 @@ name: Java CI with Gradle on: push: - branches: [ "main" ] + branches: [ "*" ] pull_request: - branches: [ "main" ] + branches: [ "*" ] jobs: - build: + check: - runs-on: ubuntu-latest + runs-on: ubuntu-latest, macos-latest, windows-latest permissions: contents: read steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. - # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md - name: Setup Gradle - uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + uses: gradle/actions/setup-gradle@v4 - - name: Build with Gradle Wrapper - run: ./gradlew build - - # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). - # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. - # - # - name: Setup Gradle - # uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - # with: - # gradle-version: '8.9' - # - # - name: Build with Gradle 8.9 - # run: gradle build + - name: Check with Gradle Wrapper + run: ./gradlew check dependency-submission: - runs-on: ubuntu-latest + runs-on: ubuntu-latest, macos-latest, windows-latest permissions: contents: write steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md - name: Generate and submit dependency graph - uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + uses: gradle/actions/dependency-submission@v4 From 31dd23d82d14738d80cd2d416666375e09e2e839 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 2 Nov 2024 16:43:38 +0800 Subject: [PATCH 05/52] Remove comments in the workflow and rename it --- .github/workflows/{gradle.yml => ci.yml} | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) rename .github/workflows/{gradle.yml => ci.yml} (57%) diff --git a/.github/workflows/gradle.yml b/.github/workflows/ci.yml similarity index 57% rename from .github/workflows/gradle.yml rename to .github/workflows/ci.yml index f51890d0..a351b905 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,4 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: Java CI with Gradle +name: CI on: push: @@ -48,7 +41,5 @@ jobs: java-version: '21' distribution: 'temurin' - # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. - # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md - name: Generate and submit dependency graph uses: gradle/actions/dependency-submission@v4 From f1de59ab1fbb30256bda4b446d9353476eaec275 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 2 Nov 2024 17:17:33 +0800 Subject: [PATCH 06/52] Add the GitHub Actions "GitHub Pages Jekyll" workflow template without editing it first From https://github.com/huanshankeji/compose-multiplatform-material/settings/pages. --- .github/workflows/jekyll-gh-pages.yml | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/jekyll-gh-pages.yml diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml new file mode 100644 index 00000000..e31d81c5 --- /dev/null +++ b/.github/workflows/jekyll-gh-pages.yml @@ -0,0 +1,51 @@ +# Sample workflow for building and deploying a Jekyll site to GitHub Pages +name: Deploy Jekyll with GitHub Pages dependencies preinstalled + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./ + destination: ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From bd53c1da29694032de5ebee4cb5a9cd2caa637bc Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 2 Nov 2024 17:40:00 +0800 Subject: [PATCH 07/52] Update "jekyll-gh-pages.yml" partially and rename it --- .../workflows/{jekyll-gh-pages.yml => demo-gh-pages.yml} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename .github/workflows/{jekyll-gh-pages.yml => demo-gh-pages.yml} (85%) diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/demo-gh-pages.yml similarity index 85% rename from .github/workflows/jekyll-gh-pages.yml rename to .github/workflows/demo-gh-pages.yml index e31d81c5..4a58f0fc 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/demo-gh-pages.yml @@ -1,10 +1,10 @@ -# Sample workflow for building and deploying a Jekyll site to GitHub Pages -name: Deploy Jekyll with GitHub Pages dependencies preinstalled +name: Deploy the demo to GitHub Pages on: - # Runs on pushes targeting the default branch push: - branches: ["main"] + branches: [ "*" ] # TODO for testing purposes now, change to "release" + pull_request: + branches: [ "*" ] # TODO for testing purposes now, change to "release" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From fdb1ae74dce473829accd241441fcbad47ca9d50 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 2 Nov 2024 17:51:25 +0800 Subject: [PATCH 08/52] Fix the runner list format in the workflow file --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a351b905..64479e65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: jobs: check: - runs-on: ubuntu-latest, macos-latest, windows-latest + runs-on: [ubuntu-latest, macos-latest, windows-latest] permissions: contents: read From 38a04f033cd048ba580967e3060e76771975f633 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 2 Nov 2024 19:03:13 +0800 Subject: [PATCH 09/52] Fix the multiple runner format The fix in the previous commit doesn't work. --- .github/workflows/ci.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64479e65..eef29adc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,10 @@ on: jobs: check: - runs-on: [ubuntu-latest, macos-latest, windows-latest] + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} permissions: contents: read @@ -29,7 +32,10 @@ jobs: dependency-submission: - runs-on: ubuntu-latest, macos-latest, windows-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} permissions: contents: write From 2d6e8c5b77328d4f149db44af5b036b6b08d59e3 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 2 Nov 2024 19:12:45 +0800 Subject: [PATCH 10/52] Downgrade the JDK to 8 to be consistent with the JVM toolchain version and fix the Gradle build failure --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eef29adc..aec0f842 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 21 + - name: Set up JDK 8 uses: actions/setup-java@v4 with: - java-version: '21' + java-version: '8' distribution: 'temurin' - name: Setup Gradle @@ -41,10 +41,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 21 + - name: Set up JDK 8 uses: actions/setup-java@v4 with: - java-version: '21' + java-version: '8' distribution: 'temurin' - name: Generate and submit dependency graph From 1e4a7112979a88d776161107e9eb148523661a17 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 4 Nov 2024 04:44:33 +0800 Subject: [PATCH 11/52] Add a "side by side" site distribution to the demo and publish it to GitHub Pages A corresponding commit: https://github.com/huanshankeji/gradle-common/commit/642cdead586a475c63c24975341783d2ef6ae9f8 --- .github/workflows/demo-gh-pages.yml | 18 +++++++--- demo/build.gradle.kts | 16 +++++++++ demo/side-by-side-site/index.html | 45 ++++++++++++++++++++++++ demo/src/jsMain/resources/index.html | 2 +- demo/src/wasmJsMain/resources/index.html | 2 +- 5 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 demo/side-by-side-site/index.html diff --git a/.github/workflows/demo-gh-pages.yml b/.github/workflows/demo-gh-pages.yml index 4a58f0fc..5eabfece 100644 --- a/.github/workflows/demo-gh-pages.yml +++ b/.github/workflows/demo-gh-pages.yml @@ -30,13 +30,23 @@ jobs: uses: actions/checkout@v4 - name: Setup Pages uses: actions/configure-pages@v5 - - name: Build with Jekyll - uses: actions/jekyll-build-pages@v1 + + - name: Set up JDK 8 + uses: actions/setup-java@v4 with: - source: ./ - destination: ./_site + java-version: "8" + distribution: "temurin" + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build the distribution with Gradle Wrapper + run: ./gradlew :demo:sideBySideBrowserDistribution + - name: Upload artifact uses: actions/upload-pages-artifact@v3 + with: + path: demo/build/dist/sideBySide/productionExecutable/ # Deployment job deploy: diff --git a/demo/build.gradle.kts b/demo/build.gradle.kts index 227ec7e9..df384517 100644 --- a/demo/build.gradle.kts +++ b/demo/build.gradle.kts @@ -119,3 +119,19 @@ android { debugImplementation(compose.uiTooling) } } + +val jsBrowserDistribution by tasks.getting(Copy::class) +val wasmJsBrowserDistribution by tasks.getting(Copy::class) + +tasks.register("sideBySideBrowserDistribution") { + group = "kotlin browser" + + into(layout.buildDirectory.dir("dist/sideBySide/productionExecutable")) + from(jsBrowserDistribution) { + into("js-dom") + } + from(wasmJsBrowserDistribution) { + into("wasm-js-canvas") + } + from(projectDir.resolve("side-by-side-site")) +} diff --git a/demo/side-by-side-site/index.html b/demo/side-by-side-site/index.html new file mode 100644 index 00000000..2d8e6940 --- /dev/null +++ b/demo/side-by-side-site/index.html @@ -0,0 +1,45 @@ + + + + + + + Side by side - Compose Multiplatform Material demo + + + + + +
+
+

JS DOM / Compose HTML

+ +
+
+

Wasm JS canvas / androidx.compose

+ +
+
+ + + \ No newline at end of file diff --git a/demo/src/jsMain/resources/index.html b/demo/src/jsMain/resources/index.html index 4687f55c..989921be 100644 --- a/demo/src/jsMain/resources/index.html +++ b/demo/src/jsMain/resources/index.html @@ -4,7 +4,7 @@ - Compose Multiplatform Material demo + JS DOM - Compose Multiplatform Material demo