From dd773e3b1633cd89218e4ec45133512a6f5c53e6 Mon Sep 17 00:00:00 2001 From: Adrian Kuta Date: Thu, 15 Dec 2022 15:34:36 +0100 Subject: [PATCH] 10 Convert into multiplatform library (#13) * 10: Convert library into Kotlin Multiplatform library * 10: Setup CI * 10: Setup CI * 10: Test CI * 10: Test CI * 10: Test CI * 10: Test CI * 10: Test CI * 10: Test CI * 10: Test CI --- .circleci_turned_off/config.yml | 86 - .github/workflows/build.yml | 24 - .../{publish.yml => publishRelease.yml} | 13 +- .github/workflows/publishSnapshot.yml | 34 + .github/workflows/test.yml | 7 +- .idea/.gitignore | 4 + .idea/codeStyles/Project.xml | 115 - .idea/gradle.xml | 6 +- .idea/inspectionProfiles/Project_Default.xml | 6 + .idea/kotlinScripting.xml | 9 + .idea/misc.xml | 6 +- .idea/vcs.xml | 2 +- _config.yml | 3 - app/.gitignore | 1 - app/build.gradle | 34 - app/proguard-rules.pro | 21 - .../ExampleInstrumentedTest.kt | 24 - app/src/main/AndroidManifest.xml | 21 - .../treedatastructure/MainActivity.kt | 29 - .../drawable-v24/ic_launcher_foreground.xml | 34 - .../res/drawable/ic_launcher_background.xml | 170 -- app/src/main/res/layout/activity_main.xml | 18 - .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 - .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 - app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 2963 -> 0 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 4905 -> 0 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2060 -> 0 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 2783 -> 0 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4490 -> 0 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 6895 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 6387 -> 0 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 10413 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 9128 -> 0 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 15132 -> 0 bytes app/src/main/res/values/colors.xml | 6 - app/src/main/res/values/strings.xml | 3 - app/src/main/res/values/styles.xml | 11 - build.gradle | 32 - build.gradle.kts | 136 ++ gradle.properties | 21 +- gradle/wrapper/gradle-wrapper.jar | Bin 54329 -> 59821 bytes gradle/wrapper/gradle-wrapper.properties | 3 +- gradlew | 286 ++- gradlew.bat | 43 +- images/console_output.png | Bin 73141 -> 0 bytes kotlin-js-store/yarn.lock | 2020 +++++++++++++++++ scripts/publish-module.gradle | 86 - scripts/publish-root.gradle | 43 - settings.gradle | 2 - settings.gradle.kts | 3 + .../ChildDeclarationInterface.kt | 4 +- .../PreOrderTreeIterator.kt | 14 +- .../kotlin/com.github.adriankuta}/TreeNode.kt | 4 +- .../com.github.adriankuta}/TreeNodeExt.kt | 4 +- .../com.github.adriankuta}/ExampleUnitTest.kt | 7 +- .../com.github.adriankuta}/TreeNodeTest.kt | 56 +- treedatastructure/.gitignore | 1 - treedatastructure/build.gradle | 46 - treedatastructure/consumer-rules.pro | 0 treedatastructure/proguard-rules.pro | 21 - .../tree/ExampleInstrumentedTest.kt | 24 - .../src/main/AndroidManifest.xml | 1 - .../datastructure/tree/ExampleUnitTest.kt | 17 - 63 files changed, 2467 insertions(+), 1104 deletions(-) delete mode 100644 .circleci_turned_off/config.yml delete mode 100644 .github/workflows/build.yml rename .github/workflows/{publish.yml => publishRelease.yml} (65%) create mode 100644 .github/workflows/publishSnapshot.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/kotlinScripting.xml delete mode 100644 _config.yml delete mode 100644 app/.gitignore delete mode 100644 app/build.gradle delete mode 100644 app/proguard-rules.pro delete mode 100644 app/src/androidTest/java/com/github/adriankuta/treedatastructure/ExampleInstrumentedTest.kt delete mode 100644 app/src/main/AndroidManifest.xml delete mode 100644 app/src/main/java/com/github/adriankuta/treedatastructure/MainActivity.kt delete mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml delete mode 100644 app/src/main/res/drawable/ic_launcher_background.xml delete mode 100644 app/src/main/res/layout/activity_main.xml delete mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml delete mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml delete mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png delete mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png delete mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png delete mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png delete mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png delete mode 100644 app/src/main/res/values/colors.xml delete mode 100644 app/src/main/res/values/strings.xml delete mode 100644 app/src/main/res/values/styles.xml delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 images/console_output.png create mode 100644 kotlin-js-store/yarn.lock delete mode 100644 scripts/publish-module.gradle delete mode 100644 scripts/publish-root.gradle delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts rename {treedatastructure/src/main/java/com/github/adriankuta/datastructure/tree => src/commonMain/kotlin/com.github.adriankuta}/ChildDeclarationInterface.kt (89%) rename {treedatastructure/src/main/java/com/github/adriankuta/datastructure/tree => src/commonMain/kotlin/com.github.adriankuta}/PreOrderTreeIterator.kt (76%) rename {treedatastructure/src/main/java/com/github/adriankuta/datastructure/tree => src/commonMain/kotlin/com.github.adriankuta}/TreeNode.kt (98%) rename {treedatastructure/src/main/java/com/github/adriankuta/datastructure/tree => src/commonMain/kotlin/com.github.adriankuta}/TreeNodeExt.kt (88%) rename {app/src/test/java/com/github/adriankuta/treedatastructure => src/commonTest/kotlin/com.github.adriankuta}/ExampleUnitTest.kt (73%) rename {treedatastructure/src/test/java/com/github/adriankuta/datastructure/tree => src/commonTest/kotlin/com.github.adriankuta}/TreeNodeTest.kt (70%) delete mode 100644 treedatastructure/.gitignore delete mode 100644 treedatastructure/build.gradle delete mode 100644 treedatastructure/consumer-rules.pro delete mode 100644 treedatastructure/proguard-rules.pro delete mode 100644 treedatastructure/src/androidTest/java/com/github/adriankuta/datastructure/tree/ExampleInstrumentedTest.kt delete mode 100644 treedatastructure/src/main/AndroidManifest.xml delete mode 100644 treedatastructure/src/test/java/com/github/adriankuta/datastructure/tree/ExampleUnitTest.kt diff --git a/.circleci_turned_off/config.yml b/.circleci_turned_off/config.yml deleted file mode 100644 index 12ca4c0..0000000 --- a/.circleci_turned_off/config.yml +++ /dev/null @@ -1,86 +0,0 @@ -version: 2.1 -jobs: - build: - working_directory: ~/code - docker: - - image: circleci/android:api-29 - environment: - JVM_OPTS: -Xmx3200m - steps: - - checkout - - restore_cache: - key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - - run: - name: Download Dependencies - command: ./gradlew androidDependencies - - save_cache: - paths: - - ~/.gradle - key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - - tests: - working_directory: ~/code - docker: - - image: circleci/android:api-29 - environment: - JVM_OPTS: -Xmx3200m - steps: - - checkout - - restore_cache: - key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - - store_artifacts: - path: app/build/reports - destination: reports - - run: - name: Run Lint Test - command: ./gradlew lint - - run: - name: Run Tests - command: ./gradlew lint test - - store_artifacts: - path: app/build/reports - destination: reports - - store_test_results: - path: app/build/test-results - - deploy: - working_directory: ~/code - docker: - - image: circleci/android:api-29 - environment: - JVM_OPTS: -Xmx3200m - steps: - - checkout - - restore_cache: - key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - - run: - name: Build Library - command: ./gradlew :treedatastructure:assembleRelease - - run: - name: Export key - command: | - mkdir treedatastructure/maven - echo ${GPG_KEY_CONTENTS} | base64 -d --ignore-garbage > treedatastructure/maven/secret.gpg - - run: - name: Staging - command: ./gradlew :treedatastructure:publishReleasePublicationToSonatypeRepository - - run: - name: Release Library - command: ./gradlew closeAndReleaseRepository - -workflows: - version: 2.1 - build-and-deploy: - jobs: - - build: - filters: # required since `deploy` has tag filters AND requires `build` - tags: - only: /.*/ - - deploy: - requires: - - build - filters: - tags: - only: /v[0-9]{1,3}\.[0-9]{1,3}\.?[0-9]{0,3}/ - branches: - ignore: /.*/ \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 660df3d..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Build - -on: pull_request - -jobs: - build: - name: Check project build - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - distribution: adopt - java-version: 11 - - # Builds the release artifacts of the library - - name: Build - run: ./gradlew assemble - - # Generates other artifacts (javadocJar is optional) - - name: Source jar and dokka - run: ./gradlew androidSourcesJar javadocJar diff --git a/.github/workflows/publish.yml b/.github/workflows/publishRelease.yml similarity index 65% rename from .github/workflows/publish.yml rename to .github/workflows/publishRelease.yml index 3c5fa22..73c762a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publishRelease.yml @@ -7,7 +7,7 @@ on: jobs: publish: - name: Release build and publish + name: Publish Production runs-on: ubuntu-latest steps: - name: Check out code @@ -18,17 +18,9 @@ jobs: distribution: adopt java-version: 11 - # Builds the release artifacts of the library - - name: Release build - run: ./gradlew :treedatastructure:assembleRelease - - # Generates other artifacts (javadocJar is optional) - - name: Source jar and dokka - run: ./gradlew androidSourcesJar javadocJar - # Runs upload, and then closes & releases the repository - name: Publish to MavenCentral - run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + run: ./gradlew publish --max-workers 1 env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} @@ -36,3 +28,4 @@ jobs: SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + SNAPSHOT: false \ No newline at end of file diff --git a/.github/workflows/publishSnapshot.yml b/.github/workflows/publishSnapshot.yml new file mode 100644 index 0000000..2b5213a --- /dev/null +++ b/.github/workflows/publishSnapshot.yml @@ -0,0 +1,34 @@ +name: Publish Snapshot + +on: + workflow_run: + workflows: [Test] + branches-ignore: [main] + types: + - completed + +jobs: + publish: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + name: Publish Snapshot + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + + # Runs upload, and then closes & releases the repository + - name: Publish to snapshot to Sonatype + run: ./gradlew publish --max-workers 1 + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + SNAPSHOT: false \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48d4f91..8776712 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,6 @@ name: Test -on: - pull_request: - branches: - - master +on: [push] jobs: build: @@ -20,4 +17,4 @@ jobs: # Builds the release artifacts of the library - name: Test - run: ./gradlew test + run: ./gradlew test \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..a39e569 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,4 @@ +# Default ignored files +/shelf/ +/workspace.xml +artifacts diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 43fd926..1bec35e 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -3,121 +3,6 @@ - - - - - - - -
- - - - xmlns:android - - ^$ - - - -
-
- - - - xmlns:.* - - ^$ - - - BY_NAME - -
-
- - - - .*:id - - http://schemas.android.com/apk/res/android - - - -
-
- - - - .*:name - - http://schemas.android.com/apk/res/android - - - -
-
- - - - name - - ^$ - - - -
-
- - - - style - - ^$ - - - -
-
- - - - .* - - ^$ - - - BY_NAME - -
-
- - - - .* - - http://schemas.android.com/apk/res/android - - - ANDROID_ATTRIBUTE_ORDER - -
-
- - - - .* - - .* - - - BY_NAME - -
-
-
-
diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 46b6df2..5404067 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,15 +4,11 @@