diff --git a/.github/workflows/npm_release.yml b/.github/workflows/npm_release.yml new file mode 100644 index 000000000..43a4c76b7 --- /dev/null +++ b/.github/workflows/npm_release.yml @@ -0,0 +1,196 @@ +on: + push: + branches: + - main + tags: + - "v*" + +env: + NPM_TAG: "next" + EMULATOR_NAME: "runtime-emu" + NDK_VERSION: r27 + ANDROID_API: 33 + ANDROID_ABI: x86_64 + NDK_ARCH: darwin + +jobs: + build: + name: Build + runs-on: macos-13 + outputs: + npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }} + npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: 22 + registry-url: "https://registry.npmjs.org" + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "21" + cache: gradle + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + - name: Homebrew dependencies + run: | + brew install wget + - name: Setup NDK + run: | + echo "y" | sdkmanager "cmake;3.6.4111459" + wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip + chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip + unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip + rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip + export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION + echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV + echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV + echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH + - name: Install Dependencies + run: | + npm install + npm install --prefix ./test-app/tools + - name: Get Current Version + run: | + NPM_VERSION=$(node -e "console.log(require('./package.json').version);") + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV + - name: Bump version for dev release + if: ${{ !contains(github.ref, 'refs/tags/') }} + run: | + NPM_VERSION=$(node ./scripts/get-next-version.js) + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV + npm version $NPM_VERSION --no-git-tag-version + - name: Output NPM Version and tag + id: npm_version_output + run: | + NPM_TAG=$(node ./scripts/get-npm-tag.js) + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT + echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT + - name: Build npm package + run: ./gradlew -PgitCommitVersion=${{ github.sha }} -PnoCCache --stacktrace + - name: Upload npm package artifact + uses: actions/upload-artifact@v4 + with: + name: npm-package + path: dist/nativescript-android-${{steps.npm_version_output.outputs.NPM_VERSION}}.tgz + - name: Upload debug symbols + uses: actions/upload-artifact@v4 + with: + name: debug-symbols + path: test-app/runtime/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/* + + test: + name: Test + runs-on: macos-13 + needs: build + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: 22 + registry-url: "https://registry.npmjs.org" + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "21" + cache: gradle + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + - name: Homebrew dependencies + run: | + brew install wget + - name: Setup NDK + run: | + echo "y" | sdkmanager "cmake;3.6.4111459" + wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip + chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip + unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip + rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip + export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION + echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV + echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV + echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH + - name: Install Dependencies + run: | + npm install + npm install --prefix ./test-app/tools + - name: SBG tests + run: ./gradlew runSbgTests --stacktrace + - name: Run unit tests + uses: ReactiveCircus/android-emulator-runner@v2 + with: + api-level: ${{env.ANDROID_API}} + # this is needed on API 30+ + #target: google_apis + arch: ${{env.ANDROID_ABI}} + script: ./gradlew runtestsAndVerifyResults --stacktrace + publish: + runs-on: ubuntu-latest + needs: + - build + - test + permissions: + contents: read + id-token: write + env: + NPM_VERSION: ${{needs.build.outputs.npm_version}} + NPM_TAG: ${{needs.build.outputs.npm_tag}} + steps: + - uses: actions/setup-node@v3 + with: + node-version: 22 + registry-url: "https://registry.npmjs.org" + - uses: actions/download-artifact@v4 + with: + name: npm-package + path: dist + - name: Publish package + run: | + echo "Publishing @nativescript/android@$NPM_VERSION to NPM with tag $NPM_TAG..." + npm publish ./dist/nativescript-android-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + github-release: + runs-on: ubuntu-latest + # only runs on tagged commits + if: ${{ contains(github.ref, 'refs/tags/') }} + permissions: + contents: write + needs: + - build + - test + env: + NPM_VERSION: ${{needs.build.outputs.npm_version}} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: 22 + - name: Setup + run: npm install + - uses: actions/download-artifact@v4 + with: + name: npm-package + path: dist + - uses: actions/download-artifact@v4 + with: + name: debug-symbols + path: dist/debug-symbols + - name: Zip debug symbols + working-directory: dist/debug-symbols + run: zip -r debug-symbols.zip . + - name: Partial Changelog + run: npx conventional-changelog -p angular -r2 > body.md + - uses: ncipollo/release-action@v1 + with: + artifacts: "dist/nativescript-android-*.tgz,dist/debug-symbols/debug-symbols.zip" + bodyFile: "body.md" + prerelease: ${{needs.build.outputs.npm_tag != 'latest'}} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 000000000..de0f75728 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,128 @@ +on: + pull_request: + +env: + NPM_TAG: "pr" + EMULATOR_NAME: "runtime-emu" + NDK_VERSION: r27 + ANDROID_API: 33 + ANDROID_ABI: x86_64 + NDK_ARCH: darwin + + +jobs: + build: + name: Build + runs-on: macos-13 + outputs: + npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }} + npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: 22 + registry-url: "https://registry.npmjs.org" + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "21" + cache: gradle + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + - name: Homebrew dependencies + run: | + brew install wget + - name: Setup NDK + run: | + echo "y" | sdkmanager "cmake;3.6.4111459" + wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip + chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip + unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip + rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip + export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION + echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV + echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV + echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH + - name: Install Dependencies + run: | + npm install + npm install --prefix ./test-app/tools + - name: Get Current Version + run: | + NPM_VERSION=$(node -e "console.log(require('./package.json').version);") + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV + - name: Bump version for dev release + if: ${{ !contains(github.ref, 'refs/tags/') }} + run: | + NPM_VERSION=$(node ./scripts/get-next-version.js) + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV + npm version $NPM_VERSION --no-git-tag-version + - name: Output NPM Version and tag + id: npm_version_output + run: | + NPM_TAG=$(node ./scripts/get-npm-tag.js) + echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT + echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT + - name: Build npm package + run: ./gradlew -PgitCommitVersion=${{ github.sha }} -PnoCCache --stacktrace + - name: Upload npm package artifact + uses: actions/upload-artifact@v4 + with: + name: npm-package + path: dist/nativescript-android-${{steps.npm_version_output.outputs.NPM_VERSION}}.tgz + - name: Upload debug symbols + uses: actions/upload-artifact@v4 + with: + name: debug-symbols + path: test-app/runtime/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/* + test: + name: Test + runs-on: macos-13 + needs: build + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - uses: actions/setup-node@v3 + with: + node-version: 22 + registry-url: "https://registry.npmjs.org" + - uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "21" + cache: gradle + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + - name: Homebrew dependencies + run: | + brew install wget + - name: Setup NDK + run: | + echo "y" | sdkmanager "cmake;3.6.4111459" + wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip + chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip + unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip + rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip + export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION + echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV + echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV + echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH + - name: Install Dependencies + run: | + npm install + npm install --prefix ./test-app/tools + - name: SBG tests + run: ./gradlew runSbgTests --stacktrace + - name: Run unit tests + uses: ReactiveCircus/android-emulator-runner@v2 + with: + api-level: ${{env.ANDROID_API}} + # this is needed on API 30+ + #target: google_apis + arch: ${{env.ANDROID_ABI}} + script: ./gradlew runtestsAndVerifyResults --stacktrace \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..98a8e8a4f --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +message="release: %s" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 469925bf5..4b6700151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,433 @@ +# [8.9.0](https://github.com/NativeScript/android/compare/v8.8.6...v8.9.0) (2025-02-26) + + +### Bug Fixes + +* inner type should net be set when companion object is defined as function ([#1831](https://github.com/NativeScript/android/issues/1831)) ([e293636](https://github.com/NativeScript/android/commit/e293636ed1e9277d608e3102b404f94539404fdf)) + + +### Features + +* Ada 3.1.1 ([3633aed](https://github.com/NativeScript/android/commit/3633aed8913c7b93757909a569bfb8ab225add13)) +* ada v3 ([#1830](https://github.com/NativeScript/android/issues/1830)) ([b31fc5f](https://github.com/NativeScript/android/commit/b31fc5f7144b873981b8c7201d72baf26a6e79bc)) +* NDK 27 and Support for Java 21 ([#1819](https://github.com/NativeScript/android/issues/1819)) ([bec401c](https://github.com/NativeScript/android/commit/bec401c918942443bccab4e697cea2ccb843e603)) +* support 16 KB page sizes, gradle 8.5 ([#1818](https://github.com/NativeScript/android/issues/1818)) ([3423e6f](https://github.com/NativeScript/android/commit/3423e6ff05c5340f92eec46f8c8e996d78403860)) + + +### Performance Improvements + +* optimizations around generating JS classes from Metadata ([#1824](https://github.com/NativeScript/android/issues/1824)) ([f290ed2](https://github.com/NativeScript/android/commit/f290ed26da315ddefb56fa1acd212c6242ab976b)) + + + +## [8.8.6](https://github.com/NativeScript/android/compare/v8.8.5...v8.8.6) (2024-10-28) + + +### Bug Fixes + +* `exit(0)` causes ANR due to destroyed mutex ([#1820](https://github.com/NativeScript/android/issues/1820)) ([94ddb15](https://github.com/NativeScript/android/commit/94ddb159ccf368edebce76a8aa01d141d7297b1a)) +* gradle error when compileSdk or targetSdk is provided ([#1825](https://github.com/NativeScript/android/issues/1825)) ([a983931](https://github.com/NativeScript/android/commit/a983931cf5e9fcc7966a98a2f0ec4e24e040af5e)) +* **URL:** allow undefined 2nd args ([#1826](https://github.com/NativeScript/android/issues/1826)) ([2bab8f5](https://github.com/NativeScript/android/commit/2bab8f5be85c8764faafef4d6374dc8cfd257613)) + + + +## [8.8.5](https://github.com/NativeScript/android/compare/v8.8.4...v8.8.5) (2024-09-30) + + +### Bug Fixes + +* prevent metadata offset overflow into array space and convert shorts to uints before addition ([9cfc349](https://github.com/NativeScript/android/commit/9cfc3493017243948b043a51f68b7c7bcab1e6b9)) + + + +## [8.8.4](https://github.com/NativeScript/android/compare/v8.8.3...v8.8.4) (2024-09-06) + + +### Bug Fixes + +* ensure same mtime for js and code cache to prevent loading old code caches ([#1822](https://github.com/NativeScript/android/issues/1822)) ([3d6e101](https://github.com/NativeScript/android/commit/3d6e10115227ad556e5bbe1764217716ab5bdac7)) + + + +## [8.8.3](https://github.com/NativeScript/android/compare/v8.8.2...v8.8.3) (2024-09-02) + + +### Bug Fixes + +* generate correct metadata when overflowing signed short values ([#1821](https://github.com/NativeScript/android/issues/1821)) ([c9fac4b](https://github.com/NativeScript/android/commit/c9fac4b19a952d4df651d3d6a8b0fa9c50f7c7db)) + + + +## [8.8.2](https://github.com/NativeScript/android/compare/v8.8.1...v8.8.2) (2024-07-22) + + +### Bug Fixes + +* config with multiple bundle ids ([#1816](https://github.com/NativeScript/android/issues/1816)) ([cdcfee2](https://github.com/NativeScript/android/commit/cdcfee266617472ac7f3ac59742b858ad093e46b)) + + + +## [8.8.1](https://github.com/NativeScript/android/compare/v8.8.0...v8.8.1) (2024-07-10) + + +### Features + +* Ada 2.9 ([#1814](https://github.com/NativeScript/android/issues/1814)) ([91accf9](https://github.com/NativeScript/android/commit/91accf9be1caf9ad2accb80bf9aca18efe4dd75a)) + + + +# [8.8.0](https://github.com/NativeScript/android/compare/v8.7.0...v8.8.0) (2024-07-09) + + +### Bug Fixes + +* correctly load ts_helpers.js in workers ([#1798](https://github.com/NativeScript/android/issues/1798)) ([31f8501](https://github.com/NativeScript/android/commit/31f8501bb902815cfed8e1cd123fe8b6de2cb757)) + + +### Features + +* Kotlin 2 + Gradle 8+ ([#1812](https://github.com/NativeScript/android/issues/1812)) ([d4b7164](https://github.com/NativeScript/android/commit/d4b716427934ebb4387a04842561d5b5d0e1fa3d)) + + + +# [8.7.0](https://github.com/NativeScript/android/compare/v8.7.0-rc.3...v8.7.0) (2024-04-08) + + + +# [8.7.0-rc.3](https://github.com/NativeScript/android/compare/v8.6.2...v8.7.0-rc.3) (2024-04-08) + + +### Bug Fixes + +* devtools namespace usage ([#1810](https://github.com/NativeScript/android/issues/1810)) ([5aaac57](https://github.com/NativeScript/android/commit/5aaac5788ff9abf1c043817e87c8e03eb61907c0)) +* dts-generator.jar path ([1120a32](https://github.com/NativeScript/android/commit/1120a3258d53f83b7b4dfe7e505234e2b0d6cd2b)) +* inspector and globals ([#1811](https://github.com/NativeScript/android/issues/1811)) ([79ebd18](https://github.com/NativeScript/android/commit/79ebd18f308cd86fa98784f14b5c3f5ac39d8c5f)) + + +### Features + +* bump ndk to r23c ([#1803](https://github.com/NativeScript/android/issues/1803)) ([3894959](https://github.com/NativeScript/android/commit/3894959e0b4fe31f61cfd9fa70d5e2b04a0f36ac)) +* devtools element/network inspectors ([#1808](https://github.com/NativeScript/android/issues/1808)) ([1470796](https://github.com/NativeScript/android/commit/1470796dc506f0d01e94fe117119dc217ff8c909)) +* migrate to faster maps and use runtime context ([#1793](https://github.com/NativeScript/android/issues/1793)) ([b248dc4](https://github.com/NativeScript/android/commit/b248dc4038d0c1a6af420447c713bc968431f97e)) +* update libzip to 1.10.1 ([#1805](https://github.com/NativeScript/android/issues/1805)) ([ee2e3e0](https://github.com/NativeScript/android/commit/ee2e3e0b87caf3cff4784f1464dd51b2923c6861)) +* use node module bindings like the iOS runtime ([#1795](https://github.com/NativeScript/android/issues/1795)) ([643958b](https://github.com/NativeScript/android/commit/643958b6a4c3698567edde3fd03052873b2644dc)) +* **WinterCG:** URL & URLSearchParams ([#1801](https://github.com/NativeScript/android/issues/1801)) ([4f3a0d7](https://github.com/NativeScript/android/commit/4f3a0d7f2de5f899779bd0fe9081390e6c4d24b2)) + + +### Reverts + +* Version.h changes ([9faa25d](https://github.com/NativeScript/android/commit/9faa25dda197d3da4f694ea59208309bb02e529c)) + + + +## [8.6.2](https://github.com/NativeScript/android/compare/v8.6.1...v8.6.2) (2023-10-10) + + + +## [8.6.1](https://github.com/NativeScript/android/compare/v8.6.0...v8.6.1) (2023-10-10) + + +### Bug Fixes + +* copy drawables ([4ff92cb](https://github.com/NativeScript/android/commit/4ff92cb32a954be4c3d32c302e301cef0a4b72a6)) + + + +# [8.6.0](https://github.com/NativeScript/android/compare/v8.5.3...v8.6.0) (2023-10-06) + + +### Bug Fixes + +* make jar files readonly prior to loading ([#1790](https://github.com/NativeScript/android/issues/1790)) ([2bcdaf0](https://github.com/NativeScript/android/commit/2bcdaf01fb850db4a982c22c2d792f9493a2a7fa)) +* only use project jar files if they are linked ([d23ca94](https://github.com/NativeScript/android/commit/d23ca94ba7c660b26224c57ba6f22085aa99f95c)) +* revert namespace change as to not break existing projects ([8b7b59d](https://github.com/NativeScript/android/commit/8b7b59d23d926b696bde3c1031cf3a842a24133d)) + + +### Features + +* improved error activity ui ([#1776](https://github.com/NativeScript/android/issues/1776)) ([ee3e354](https://github.com/NativeScript/android/commit/ee3e354f1bec89268daf93086aa6dd24898677b9)) +* upgrade client gradle version ([c778c0d](https://github.com/NativeScript/android/commit/c778c0d238c4ba44390f786ba06ab8e51ffb2c97)) + +## [8.5.4](https://github.com/NativeScript/android/compare/v8.5.3...v8.5.4) (2023-09-27) + + +### Bug Fixes + +* make jar files readonly prior to loading ([#1790](https://github.com/NativeScript/android/issues/1790)) ([14a932a](https://github.com/NativeScript/android/commit/14a932ad2d62c94f2f4e139125835da760dcdd58)) + + +## [8.5.3](https://github.com/NativeScript/android/compare/v8.5.2...v8.5.3) (2023-09-22) + + +### Bug Fixes + +* resolve __postFrameCallback crash on re-scheduling ([6a533ce](https://github.com/NativeScript/android/commit/6a533ce58b22b163d888c51f203be2ef3aa98347)) + + + +## [8.5.2](https://github.com/NativeScript/android/compare/v8.5.1...v8.5.2) (2023-08-31) + + +### Bug Fixes + +* __runOnMainThread erase iterator before it can be invalidated ([e811484](https://github.com/NativeScript/android/commit/e81148409046957fceb07b14394baa5bc055286d)) +* pull js stack trace from wrapped NativeScriptExceptions ([#1774](https://github.com/NativeScript/android/issues/1774)) ([52b7fa2](https://github.com/NativeScript/android/commit/52b7fa242cb4582701dcebf97aa0f6e0400bcb1a)) + + + +## [8.5.1](https://github.com/NativeScript/android/compare/v8.5.0...v8.5.1) (2023-07-24) + + +### Bug Fixes + +* Avoid setting the same property on an ObjectTemplate twice ([9e610c8](https://github.com/NativeScript/android/commit/9e610c8b61a721c04b0a7b8f5167f5b070c5419f)) +* Don't access `super` property on implementation object ([d8b8bc0](https://github.com/NativeScript/android/commit/d8b8bc02cf51de021855bb6a39ccd39ce1287304)) +* Don't iterate properties in GetImplementedInterfaces ([9dfae65](https://github.com/NativeScript/android/commit/9dfae6589caad31ee50a5946e7369f12505cd955)) +* intermediary fix for https://github.com/NativeScript/android/pull/1771 ([32c7abb](https://github.com/NativeScript/android/commit/32c7abb3418b20d1ac2d80c18c5e25a402937628)) +* Leave context after Runtime::PrepareV8Runtime() ([cd1d285](https://github.com/NativeScript/android/commit/cd1d2850e5c28d89339a90d783db1f1623957be7)) +* memory leak on accessing static interface methods ([88ce2d8](https://github.com/NativeScript/android/commit/88ce2d8b2c2ccf5568d1b95f0bf9df47179f658a)) +* memory leak on saving code cache ([6d416a1](https://github.com/NativeScript/android/commit/6d416a11e5b304d8ac2bfb4c48931a22e353df72)) +* Update common-runtime-tests-app ([c8db3ca](https://github.com/NativeScript/android/commit/c8db3cab6b3e3ddd41ab94adb8edac46a704cbe9)) +* update legacy android version in package.json ([#1744](https://github.com/NativeScript/android/issues/1744)) ([b4ad8e5](https://github.com/NativeScript/android/commit/b4ad8e541ff211055dc5197c7e0b350b6666771f)) +* Use Isolate::TryGetCurrent() ([afe026a](https://github.com/NativeScript/android/commit/afe026a29f3e9a1a5e533e4c66fd013f5f7f163c)) + + +* Remove weak callback from __postFrameCallback cache (#1755) ([ff1b979](https://github.com/NativeScript/android/commit/ff1b97975c7fdcd6b2acfb6153ba635d4f420eff)), closes [#1755](https://github.com/NativeScript/android/issues/1755) + + +### Features + +* add support for kotlin 1.8 ([#1765](https://github.com/NativeScript/android/issues/1765)) ([1a928e4](https://github.com/NativeScript/android/commit/1a928e47e733b1d4ba2bb83b4f541e1cac835155)) + + +### Performance Improvements + +* avoid unnecessary string copying when calling static properties of interfaces ([8b53d02](https://github.com/NativeScript/android/commit/8b53d022315d4a7fa9d617f431e0364030942d24)) + + +### BREAKING CHANGES + +* __startNDKProfiler() and __stopNDKProfiler() global +bindings no longer available. + +The NDK profiler was not functional, since nothing in the build process +defined the NDK_PROFILER_ENABLED preprocessor symbol. The start and stop +functions were already no-ops. + +* chore: Remove outdated comment + +RunMicrotasks no longer exists, it's already been replaced in the code +with PerformMicrotaskCheckpoint. + +* chore: Use unique_ptr for NewBackingStore in byte buffers + +V8 doc: https://docs.google.com/document/d/1sTc_jRL87Fu175Holm5SV0kajkseGl2r8ifGY76G35k/edit + +The V8 usage examples show unique_ptr here; it probably doesn't matter +much, but we don't need the backing store after creating the ArrayBuffer, +and I believe shared_ptr is slightly more overhead than unique_ptr. + +For convenience, replace the manual empty deleter for direct buffers with +v8::BackingStore::EmptyDeleter. + +* chore: Remove weak finalizer callback from __postFrameCallback() + +Weak finalizer callbacks are going away in V8 11.x, so we have to remove +this one. Luckily, a finalizer callback is not necessary - it's never +needed to prevent the frame callback from being collected. + +However, a weak callback is not necessary in the first place. We can just +clean up the cache entry after the callback is executed, since it is only +executed once. + +Note that the call to erase() destructs the FrameCallbackCacheEntry +instance, making `entry` a dangling pointer, so don't use it after the +erase(). There's probably a safer way to do this, although the way that +first occurred to me (pass the key to the callback instead of the entry, +and then use std::unordered_map::extract()) is not available on +robin_hood::unordered_map. + +* fix: Make sure frame callbacks are not ignored + +There was a bug where __postFrameCallback() would not always cause the +callback to be called. Without initializing `removed`, sometimes it would +have a nonzero value, so the callback would be ignored. + +* chore: Clear callback caches' persistent handles in destructor + +Clearing the persistent handles in the destructor makes it a bit easier to +deal with the cache entry's lifetime: they are cleared whenever the entry +is removed from the cache. + +We do this for both the main thread callback cache and the frame callback +cache. + +Adding a destructor makes the cache entries non-movable. But the only +place where they were moved was when inserting them into the cache anyway. +We can use C++17's try_emplace() method to insert them without having to +move them. + +* chore: Construct FrameCallbackCacheEntry with ID + +This avoids the situation of forgetting to add an ID to the cache entry. + +* chore: Improve usage of unordered_map APIs in CallbackHandlers + +This fixes a few places where we can avoid double lookups: + +- In RunOnMainThreadFdCallback, we already have a valid iterator, so no + need to look up the same key again in RemoveKey (this is the only usage + of RemoveKey, so we can remove it.) (Additionally, we probably want to + remove the cache entry before throwing a NativeScript exception.) + +- In PostFrameCallback and RemoveFrameCallback, we should not do + contains() immediately followed by find(). + +* chore: Fix runtime typo + +* chore: Ignore main thread and frame callback return values + +We don't do anything with the return value from these callbacks, so it's +OK to ignore them and not convert them to a local handle. + + + +# [8.5.0](https://github.com/NativeScript/android/compare/v8.4.0...v8.5.0) (2023-06-27) + + +### Bug Fixes + +* add semicolon after console type ([32259a9](https://github.com/NativeScript/android/commit/32259a90607bdd282d855c3701c7b7c2b203439d)) +* always log console messages and uncomment live sync ([c0f5514](https://github.com/NativeScript/android/commit/c0f5514686decc111d8b2e2f93c434141788f298)) +* Compile as C++17 ([221a9c2](https://github.com/NativeScript/android/commit/221a9c2c3747c2698238841ea56cf4d837206c20)) +* Correctly initialize context in inspector client init() ([0bc0480](https://github.com/NativeScript/android/commit/0bc0480035d01c681765a01b794b48db003be050)) +* drain microtasks after devtools message ([4834a2b](https://github.com/NativeScript/android/commit/4834a2b8e3d979323753d1da265ad1faaabbd655)) +* Implement console.log inspector with Runtime protocol ([2c4337b](https://github.com/NativeScript/android/commit/2c4337bf5b7c2c00bbcd5b34da1e8c08478fd37a)) +* memcpy array data for non-direct java bytebuffers ([#1740](https://github.com/NativeScript/android/issues/1740)) ([1c0214a](https://github.com/NativeScript/android/commit/1c0214a4785d425dc83f9612169fad7f70a28d41)) +* multi threading on MethodResolver ([bc8bc52](https://github.com/NativeScript/android/commit/bc8bc5253ff8abecf97bf98462d21fda15757a6a)) +* possible infinite loop and memory leak in metadata reader ([#1749](https://github.com/NativeScript/android/issues/1749)) ([c2c8aa8](https://github.com/NativeScript/android/commit/c2c8aa8a5f81c10aee293e14af797e5d1e3fbb4c)) +* Re-enable inspector code ([f357ce6](https://github.com/NativeScript/android/commit/f357ce6b9836be109ea5717ba0c09ee01a3f9876)) +* refactor console.log implementation a bit ([#1741](https://github.com/NativeScript/android/issues/1741)) ([d3c52cb](https://github.com/NativeScript/android/commit/d3c52cbaae8620d1ba1ed43d61da6df6f9df0f9c)) +* remove free of non-owned jni buffer ([81806b3](https://github.com/NativeScript/android/commit/81806b399f42a981a0cf54ab8a4be5712333e938)) +* Remove use of DISALLOW_COPY_AND_ASSIGN macro in inspector ([6da1a6b](https://github.com/NativeScript/android/commit/6da1a6bba0d9808568e8d6ae68fb0c71c6271ff1)) +* Remove use of V8InspectorPlatform ([1f2b202](https://github.com/NativeScript/android/commit/1f2b202263207de2045bafad5afedf786da788e1)) +* Restore DOM and Network callback handlers ([35689a7](https://github.com/NativeScript/android/commit/35689a7462ea86a760705c949dea6f4de4192cf8)) +* uncomment abifilters ([f5a5434](https://github.com/NativeScript/android/commit/f5a5434f41d764352de89133d2068b109bd3a54c)) +* update js arg conversions ([0640fce](https://github.com/NativeScript/android/commit/0640fcee3bd5429a637f3811fd7f8b4dc8ddf508)) +* use min sdk 17 ([2f2358c](https://github.com/NativeScript/android/commit/2f2358c0daf4c476110367432889740c18b49694)) + + +### Features + +* add console message type prefixes ([9a10e2b](https://github.com/NativeScript/android/commit/9a10e2b89410c6757bceba705a902060f37d97a1)) +* initial support for __inspectorSendEvent ([233b7c3](https://github.com/NativeScript/android/commit/233b7c39c2910e01adc261c4d0d3ddc1d92ef9d6)) +* native timer polyfills ([#1733](https://github.com/NativeScript/android/issues/1733)) ([3415e5c](https://github.com/NativeScript/android/commit/3415e5c515b3d73360a87f4f7aec03c44bd2c63c)) +* remove old WeakRef polyfill ([97d7465](https://github.com/NativeScript/android/commit/97d7465ca46df7240c4887fffb3167e469179a7a)) +* update all archs to use v8 10.3.22 ([a68b057](https://github.com/NativeScript/android/commit/a68b057da208338a83a620e64c0f4fecd90cff59)) +* use v8 static ([ee8a521](https://github.com/NativeScript/android/commit/ee8a5213a54d40046993ee61ac652842ccacfbe4)) + + +### Performance Improvements + +* refactor arrays marshaling ([84e7ddb](https://github.com/NativeScript/android/commit/84e7ddbe7fd503a3a5f11eed55246138068ca28f)) +* remove instantiations and cache runtime in isolate ([f23c1bb](https://github.com/NativeScript/android/commit/f23c1bb5b61c2fcaf7c6961450055bfd4fa4d385)) +* update old args converter with array marshaling optimizations and use this converter again tempporarily ([b5218c9](https://github.com/NativeScript/android/commit/b5218c9f5dce1e7c603887f4c9b65f3bd5284aa8)) +* use vector pointers for passing parsed method signatures ([aa623b7](https://github.com/NativeScript/android/commit/aa623b795ef38fb023cdef60d15641b8d8bf0338)) + + + +# [8.4.0](https://github.com/NativeScript/android/compare/v8.3.0...v8.4.0) (2022-11-30) + + +### Bug Fixes + +* don't assert for sub projects ([b5efdbc](https://github.com/NativeScript/android/commit/b5efdbc5ea11a7f5c73703ddae7485c4782bd8d7)) +* handle missing child classes when querying native classes ([#1718](https://github.com/NativeScript/android/issues/1718)) ([c238166](https://github.com/NativeScript/android/commit/c238166af3ce5205b65f2d79a23cfb963c3d60f9)) +* JvmField annotated fields ([#1726](https://github.com/NativeScript/android/issues/1726)) ([59da1cb](https://github.com/NativeScript/android/commit/59da1cbc8db888833fc24ea207b7d2f9195985b8)), closes [#1604](https://github.com/NativeScript/android/issues/1604) +* JvmName annotation & Kotlin building from App Resources ([1ba30be](https://github.com/NativeScript/android/commit/1ba30becfed7ba775412d722912a5e4db8c51e51)), closes [#1682](https://github.com/NativeScript/android/issues/1682) +* null data ([3b4a56d](https://github.com/NativeScript/android/commit/3b4a56df86f36a7738cc0089195d20239ce67273)) +* RunOnMainThreadCallback & PostFrameCallback ([#1721](https://github.com/NativeScript/android/issues/1721)) ([1ccd033](https://github.com/NativeScript/android/commit/1ccd033194d498b7614f16cc5d9cdcfb6a414f44)) +* typed array handling ([#1738](https://github.com/NativeScript/android/issues/1738)) ([00509ee](https://github.com/NativeScript/android/commit/00509eec6b929353a313530932f00757a3ccadb6)) +* typedarray & raf ([#1729](https://github.com/NativeScript/android/issues/1729)) ([796b9b1](https://github.com/NativeScript/android/commit/796b9b1fbba1e4cc81cb2098035ea38b3620a983)) + + +### Features + +* add class name to native objects ([#1723](https://github.com/NativeScript/android/issues/1723)) ([0c601ae](https://github.com/NativeScript/android/commit/0c601ae4680dcb6bea95f3292f6b0c3b9c1baeb1)) +* settings.gradle plugin ([#1731](https://github.com/NativeScript/android/issues/1731)) ([1759ecd](https://github.com/NativeScript/android/commit/1759ecd4071ccbeb60ea129af46e7f019c7523fe)) +* upgrade libzip to 1.9.2 ([#1724](https://github.com/NativeScript/android/issues/1724)) ([1dfd38f](https://github.com/NativeScript/android/commit/1dfd38ff0ea3a98b6d35f6f7c53f10ac1a788770)) + + + +# [8.3.0](https://github.com/NativeScript/android/compare/v8.2.4...v8.3.0) (2022-07-14) + + +### Bug Fixes + +* apply before-plugins before checking versions ([0df7362](https://github.com/NativeScript/android/commit/0df73625b72adb2fd654091f74e527dd61e3029b)) +* Set package version before preReleaseBuild ([12acd7f](https://github.com/NativeScript/android/commit/12acd7f3c1a265c0d8cddef8cb936825d2af7877)) + + +### Features + +* runOnMain, postFrameCallback & removeFrameCallback ([#1713](https://github.com/NativeScript/android/issues/1713)) ([bdd0313](https://github.com/NativeScript/android/commit/bdd031317c15d5e7eaa0dfeab2ef599b4eeddc4c)) + + + +## [8.2.3](https://github.com/NativeScript/android/compare/v8.2.2...v8.2.3) (2022-06-01) + + +### Bug Fixes + +* direct boot should not crash/ANR ([d2b18d7](https://github.com/NativeScript/android/commit/d2b18d7a8e23af6b27a8e2281e43bf72d715af66)) + + + +## [8.2.2](https://github.com/NativeScript/android/compare/v8.2.1...v8.2.2) (2022-03-09) + + +### Bug Fixes + +* app freezing on splash screen ([a61d3c1](https://github.com/NativeScript/android/commit/a61d3c1932ca11b67c88bc1b9a0eb97c9847ee19)) + + + +## [8.2.1](https://github.com/NativeScript/android/compare/v8.2.0...v8.2.1) (2022-03-08) + + +### Bug Fixes + +* add back gradle key in package json for the time being ([af925d5](https://github.com/NativeScript/android/commit/af925d50990820c9ca92a9a1a869518dbfd43fad)) + + + +# [8.2.0](https://github.com/NativeScript/android/compare/v7.0.1...v8.2.0) (2022-03-08) + + +### Bug Fixes + +* **chrome-devtools:** Elements tab ([e935a61](https://github.com/NativeScript/android/commit/e935a61de5043ae2febd76b34963bcaba7049791)), closes [#1641](https://github.com/NativeScript/android/issues/1641) [#1640](https://github.com/NativeScript/android/issues/1640) +* ensure buildMetadata is done before R8 ([01ad92e](https://github.com/NativeScript/android/commit/01ad92e53d6fcd6448b89004e1d49a66dd2b3254)) +* js -> buffer handling ([b49801c](https://github.com/NativeScript/android/commit/b49801cb7df3acd65ecb0a7e688afe2a25be908e)) +* load `before-plugins.gradle` in build.gradle to allow to override `androidBuildToolsVersion` and other vars ([d926dd4](https://github.com/NativeScript/android/commit/d926dd4340539ee9223ab9090ab20dd3c253af2a)) +* loop ([95ba9f5](https://github.com/NativeScript/android/commit/95ba9f5bd382cbffef2469fca632b69729c5837c)) +* material lib as debugImplementation ([c6946fe](https://github.com/NativeScript/android/commit/c6946fe6633ebb851fec35c19c2a64632628396e)) +* pending intent api31 flags ([d8781fd](https://github.com/NativeScript/android/commit/d8781fdcbffcf44d49d2df1055421eeecf8316ea)) +* update to jsparser ([ea1517c](https://github.com/NativeScript/android/commit/ea1517cbcd3b62037440c42fdcedf54eb2bee035)) +* **workers:** invalidate cached isolates on dispose ([#1704](https://github.com/NativeScript/android/issues/1704)) ([67e9daf](https://github.com/NativeScript/android/commit/67e9daf709722b608ef1fb6110d5b708f1819c41)) + + +### Features + +* commonGradleProperties ([77585ad](https://github.com/NativeScript/android/commit/77585ad58cceba74d8df69e5838b9f80dc947b49)) +* expose `PerformMicrotaskCheckpoint` ([4b58570](https://github.com/NativeScript/android/commit/4b58570fa3c43fc0a0ab73790030a414412f7c19)) +* log used androidX lib versions ([#1651](https://github.com/NativeScript/android/issues/1651)) ([528c46f](https://github.com/NativeScript/android/commit/528c46f99dd00859ba38c2671b7a5372d34f6a63)) +* make console.time use 3 decimals ([7d9f90b](https://github.com/NativeScript/android/commit/7d9f90bd6c45c9f1fd94904e6b17dd028fff1a11)) +* support passing typedArrays as nio buffers ([38230e5](https://github.com/NativeScript/android/commit/38230e5b282cf5ad04d3d655cf0671bc7e576a19)) +* working gradle7 ([501f884](https://github.com/NativeScript/android/commit/501f884120d6a884a4e2bb6d4d60312aa7efacff)) + + + 7.0.1 == diff --git a/README.md b/README.md index 3d3ac13fa..d5f86cafe 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,18 @@ Note: You might need to run the Android Studio from the command line in order to ## How to Build +* Install dependencies from NPM: + + ```Shell + cd test-app/build-tools/jsparser + npm install + ``` + +* Set environment variables: + - `JAVA_HOME` such that `$JAVA_HOME/bin/java` points to your Java executable + - `ANDROID_HOME` pointing to where you have installed the Android SDK + - `ANDROID_NDK_HOME` pointing to the version of the Android NDK needed for this version of NativeScript + * Run command Windows: @@ -87,8 +99,27 @@ Note: You might need to run the Android Studio from the command line in order to ``Note: Keep in mind the device or emulator needs to have an sdcard mounted.`` * Run command ```Shell -gradlew runtest +gradlew runtests ``` + +## How to Connect the Inspector + +* Install dependencies: run command +```Shell +cd test-app +npm install +``` +* Run the test app in Android Studio, or manually in the emulator. +* Run command +```Shell +npx ns debug android --start +``` + (If you instead have the `nativescript` NPM module installed globally, + you can omit the `npm install` and the `npx` prefix.) +* This will print out a URL, such as + `devtools://devtools/bundled/inspector.html?ws=localhost:40000`. + Open this URL in Chrome or Chromium. + ## Contribute We love PRs! Check out the [contributing guidelines](CONTRIBUTING.md). If you want to contribute, but you are not sure where to start - look for [issues labeled `help wanted`](https://github.com/NativeScript/android-runtime/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). diff --git a/build.dev.sh b/build.dev.sh new file mode 100755 index 000000000..46e29bf0c --- /dev/null +++ b/build.dev.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# smaller version of build.sh that sets the commit hash to the current git commit hash and uses the package.json version + +echo "Ensure adb is in PATH" +export PATH="$ANDROID_HOME/platform-tools:$PATH" +adb version + +echo "Update submodule" +git submodule update --init + +echo "Cleanup old build and test artefacts" +rm -rf consoleLog.txt +rm -rf test-app/dist/*.xml + +./gradlew cleanRuntime + +./gradlew -PgitCommitVersion=$(git rev-parse HEAD) +cp dist/nativescript-android-*.tgz dist/nativescript-android.tgz + diff --git a/build.gradle b/build.gradle index 24182cc94..93be4ace6 100644 --- a/build.gradle +++ b/build.gradle @@ -261,11 +261,11 @@ task copyFilesToProjectTemeplate { into "$DIST_FRAMEWORK_PATH/app/src/main/java/com/tns/internal" } copy { - from "$BUILD_TOOLS_PATH/static-binding-generator.jar" + from "$BUILD_TOOLS_PATH/static-binding-generator/build/libs/static-binding-generator.jar" into "$DIST_FRAMEWORK_PATH/build-tools" } copy { - from "$BUILD_TOOLS_PATH/dts-generator.jar" + from "$BUILD_TOOLS_PATH/android-dts-generator/dts-generator/build/libs/dts-generator.jar" into "$DIST_FRAMEWORK_PATH/build-tools" } copy { @@ -273,7 +273,7 @@ task copyFilesToProjectTemeplate { into "$DIST_FRAMEWORK_PATH/build-tools/jsparser" } copy { - from "$BUILD_TOOLS_PATH/android-metadata-generator.jar" + from "$BUILD_TOOLS_PATH/android-metadata-generator/build/libs/android-metadata-generator.jar" into "$DIST_FRAMEWORK_PATH/build-tools" } copy { diff --git a/build.sh b/build.sh index b176b1195..2f42b49c9 100755 --- a/build.sh +++ b/build.sh @@ -50,33 +50,34 @@ fi ./gradlew runSbgTests for emulator in $listOfEmulators; do - echo "Start emulator $emulator" - $ANDROID_HOME/emulator/emulator -avd ${emulator} -verbose -wipe-data -gpu on& - find ~/.android/avd/${emulator}.avd -type f -name 'config.ini' -exec cat {} + + echo "Start emulator $emulator" + $ANDROID_HOME/emulator/emulator -avd ${emulator} -verbose -wipe-data -gpu on& + find ~/.android/avd/${emulator}.avd -type f -name 'config.ini' -exec cat {} + - echo "Run Android Runtime unit tests for $emulator" - $ANDROID_HOME/platform-tools/adb wait-for-device - $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat -c - $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat > consoleLog.txt& - $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat > consoleLog$emulator.txt& + echo "Run Android Runtime unit tests for $emulator" + $ANDROID_HOME/platform-tools/adb wait-for-device + $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat -c + $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat > consoleLog.txt& + $ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat > consoleLog$emulator.txt& - if [ "$1" != 'unit_tests_only' ]; then - ./gradlew runtests - else - ./gradlew runtests -PonlyX86 - fi + if [ "$1" != 'unit_tests_only' ]; then + ./gradlew runtests + else + ./gradlew runtests -PonlyX86 + fi - echo "Rename unit test result" - ( - cd ./test-app/dist - mv android_unit_test_results.xml $emulator.xml - ) + echo "Rename unit test result" + ( + cd ./test-app/dist + mv android_unit_test_results.xml $emulator.xml + ) - echo "Stopping running emulators" - for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done - for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done - for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done + echo "Stopping running emulators" + for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done + for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done + for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done done echo $cwd cd $cwd + diff --git a/docs/extending-inspector.md b/docs/extending-inspector.md index 39cd0adbb..583b56301 100644 --- a/docs/extending-inspector.md +++ b/docs/extending-inspector.md @@ -12,7 +12,7 @@ This step involves fetching and building the V8 projectory, explanation for whic > Note: When passing arguments to gn to have a project generate, make sure to include the inspector sources. For an overview of all available gn arguments run `gn args project-dir --list` -1. Modify `v8/src/inspector/js_protocol.json` to only contain the domains that will be used in the runtime project. The right way to go about this is to copy-paste the `js_protocol` from the runtime project, and add on top of it. For a complete list of all protocol domains supported by the Chrome browser refer to [browser_protocol.json](https://chromium.googlesource.com/chromium/src/+log/master/third_party/WebKit/Source/core/inspector/browser_protocol.json) in the Chromium project. Example browser_protocol.json file can be found [here](https://chromedevtools.github.io/devtools-protocol/tot/). +1. Modify `v8/include/js_protocol.pdl` to only contain the domains that will be used in the runtime project. The right way to go about this is to copy-paste the `js_protocol` from the runtime project, and add on top of it. For a complete list of all protocol domains supported by the Chrome browser refer to [browser_protocol.json](https://chromium.googlesource.com/chromium/src/+log/master/third_party/WebKit/Source/core/inspector/browser_protocol.json) in the Chromium project. Example browser_protocol.json file can be found [here](https://chromedevtools.github.io/devtools-protocol/tot/). 2. Modify `v8/src/inspector/inspector_protocol_config.json` and include the names for the additional protocol domain definitions that would need to be generated. ```json { @@ -47,9 +47,9 @@ This step involves fetching and building the V8 projectory, explanation for whic ``` 3. Figure out which parts of the big `js_inspector.json` protocol you will want to keep for the inspector implementation. It is likely that a lot of it will be browser-specific, so you don't need to spend extra time doing stub implementations for methods and events the application will not be making notifications for. -4. Run the ninja build. Upon completion, the inspector protocol files would be at `project-dir/arch.release/gen/src/inspector/protocol`. +4. Run the ninja build. Upon completion, the inspector protocol files would be at `outgn/$ARCH-release/gen/src/inspector/protocol`. -5. Copy-Paste all `.cpp` and `.h` files in the runtime project at `runtime/src/main/cpp/v8_inspector/src/inspector/protocol` +5. Copy-Paste all `.cpp` and `.h` files in the runtime project at `test-app/runtime/src/main/cpp/v8_inspector/src/inspector/protocol` 6. Create a new C++ class extending the desired Domain (e.g. DOM). Name it according to the convention already established by the V8 team - `v8--agent-impl.h/cpp` - See [v8-dom-agent-impl.h](https://github.com/NativeScript/android-runtime/blob/5a04e09439e2bc6a201577895b9ac6538441e758/test-app/runtime/src/main/cpp/v8_inspector/src/inspector/v8-dom-agent-impl.h#L18). Implement the Backend::'s methods in the `.cpp` file. diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265ee9..2c3521197 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 69bc70d1f..09523c0e5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Tue May 12 20:24:09 CEST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip \ No newline at end of file diff --git a/gradlew b/gradlew index cccdd3d51..f5feea6d6 100755 --- a/gradlew +++ b/gradlew @@ -1,78 +1,130 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; 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 # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; 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 - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f9553162f..9d21a2183 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,22 @@ -@if "%DEBUG%" == "" @echo off +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -9,25 +27,29 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused 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= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -35,48 +57,36 @@ 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% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 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 -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/package.json b/package.json index c82534e11..60a7bd8fa 100644 --- a/package.json +++ b/package.json @@ -1,28 +1,37 @@ { "name": "@nativescript/android", - "description": "NativeScript Runtime for Android", - "version": "8.4.0-alpha.6", + "description": "NativeScript for Android using v8", + "version": "8.9.1", "repository": { "type": "git", - "url": "https://github.com/NativeScript/android-runtime.git" + "url": "https://github.com/NativeScript/android.git" }, "files": [ "**/*" ], "version_info": { - "v8": "8.3.110.9", - "gradle": "7.5", - "gradleAndroid": "7.3.0", - "ndk": "r21", - "ndkApiLevel": "22", - "minSdk": "17", - "compileSdk": "32", - "buildTools": "32.0.0", - "kotlin": "1.7.10" + "v8": "10.3.22.0", + "gradle": "8.7", + "gradleAndroid": "8.5.0", + "ndk": "r27", + "ndkApiLevel": "21", + "minSdk": "21", + "compileSdk": "35", + "buildTools": "35.0.0", + "kotlin": "2.0.0" }, "// this gradle key is here for backwards compatibility - we'll phase it out slowly...": "", "gradle": { - "version": "7.5", - "android": "7.3." + "version": "8.7", + "android": "8.5.0" + }, + "scripts": { + "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", + "version": "npm run changelog && git add CHANGELOG.md" + }, + "devDependencies": { + "conventional-changelog-cli": "^2.1.1", + "dayjs": "^1.11.7", + "semver": "^7.5.0" } } diff --git a/scripts/get-next-version.js b/scripts/get-next-version.js new file mode 100644 index 000000000..ac3912888 --- /dev/null +++ b/scripts/get-next-version.js @@ -0,0 +1,64 @@ +const semver = require("semver"); +const child_process = require("child_process"); +const dayjs = require("dayjs"); +const fs = require("fs"); + +const currentVersion = + process.env.NPM_VERSION || require("../package.json").version; + +if (!currentVersion) { + throw new Error("Invalid current version"); +} +const currentTag = process.env.NPM_TAG || "next"; +const runID = process.env.GITHUB_RUN_ID || 0; + +let prPrerelease = ""; + +if (currentTag === "pr" && process.env.GITHUB_EVENT_PATH) { + try { + const ev = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")); + const prNum = ev.pull_request.number; + // add extra PR number to version-pr.PRNUM-.... + prPrerelease = `${prNum}-`; + } catch (e) { + // don't add pr prerelease + } +} + +const preRelease = `${currentTag}.${prPrerelease}${dayjs().format("YYYY-MM-DD")}-${runID}`; + +let lastTagVersion = ( + process.env.LAST_TAGGED_VERSION || + child_process + .spawnSync("git", ["describe", "--tags", "--abbrev=0", "--match=v*"]) + .stdout.toString() +) + .trim() + .substring(1); +if (!semver.parse(lastTagVersion)) { + throw new Error("Invalid last tag version"); +} + +function setPreRelease(version) { + const parsed = semver.parse(version); + return semver.parse( + `${parsed.major}.${parsed.minor}.${parsed.patch}-${preRelease}` + ); +} + +let nextVersion = setPreRelease(currentVersion); + +if (!nextVersion) { + throw new Error("Invalid next version"); +} + +if (semver.compare(currentVersion, lastTagVersion) <= 0) { + // next version is older than current version + nextVersion = setPreRelease(semver.parse(lastTagVersion).inc("patch")); +} + +if (!nextVersion) { + throw new Error("Invalid next version"); +} + +console.log(nextVersion.format()); diff --git a/scripts/get-npm-tag.js b/scripts/get-npm-tag.js new file mode 100644 index 000000000..68cd158cd --- /dev/null +++ b/scripts/get-npm-tag.js @@ -0,0 +1,19 @@ +const semver = require("semver"); + +const currentVersion = + process.env.NPM_VERSION || require("../package.json").version; + +function validateNpmTag(version) { + const parsed = semver.parse(version); + return ( + parsed.prerelease.length === 0 || /^[a-zA-Z]+$/.test(parsed.prerelease[0]) + ); +} + +function getNpmTag(version) { + if (!validateNpmTag(version)) throw new Error("Invalid npm tag"); + const parsed = semver.parse(version); + return parsed.prerelease[0] || "latest"; +} + +console.log(getNpmTag(currentVersion)); diff --git a/test-app/app/build.gradle b/test-app/app/build.gradle index d7bfd787b..ec5aea981 100644 --- a/test-app/app/build.gradle +++ b/test-app/app/build.gradle @@ -20,9 +20,8 @@ * -PappResourcesPath=[app_resources_path] */ - -import groovy.io.FileType import groovy.json.JsonSlurper +import groovy.xml.XmlSlurper import org.apache.commons.io.FileUtils import javax.inject.Inject @@ -30,26 +29,17 @@ import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption import java.security.MessageDigest - import java.util.jar.JarEntry import java.util.jar.JarFile import static org.gradle.internal.logging.text.StyledTextOutput.Style -import java.util.stream.Collectors; -import java.util.stream.Stream; - apply plugin: "com.android.application" apply from: "gradle-helpers/BuildToolTask.gradle" apply from: "gradle-helpers/CustomExecutionLogger.gradle" apply from: "gradle-helpers/AnalyticsCollector.gradle" - -def enableKotlin = (project.hasProperty("useKotlin") && project.useKotlin == "true") - -if (enableKotlin) { - apply plugin: 'kotlin-android' - apply plugin: 'kotlin-parcelize' -} +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-parcelize' def onlyX86 = project.hasProperty("onlyX86") if (onlyX86) { @@ -75,6 +65,7 @@ def SBG_BINDINGS_NAME = "sbg-bindings.txt" def SBG_INTERFACE_NAMES = "sbg-interface-names.txt" def INPUT_JS_DIR = "$projectDir/src/main/assets/app" def OUTPUT_JAVA_DIR = "$projectDir/src/main/java" +def APP_DIR = "$projectDir/src/main/assets/app" //metadata generator def MDG_OUTPUT_DIR = "mdg-output-dir.txt" @@ -86,9 +77,9 @@ def METADATA_JAVA_OUT = "mdg-java-out.txt" def pluginsJarLibraries = new LinkedList() def allJarLibraries = new LinkedList() -def computeKotlinVersion = { -> project.hasProperty("kotlinVersion") ? kotlinVersion : "${ns_default_kotlin_version}" } -def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk : NS_DEFAULT_COMPILE_SDK_VERSION as int } -def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk : NS_DEFAULT_COMPILE_SDK_VERSION as int } +def computeCompileSdkVersion = { -> project.hasProperty("compileSdk") ? compileSdk as int : NS_DEFAULT_COMPILE_SDK_VERSION as int } +def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk as int : NS_DEFAULT_COMPILE_SDK_VERSION as int } +def computeMinSdkVersion = { -> project.hasProperty("minSdk") ? minSdk : NS_DEFAULT_MIN_SDK_VERSION as int } def computeBuildToolsVersion = { -> project.hasProperty("buildToolsVersion") ? buildToolsVersion : NS_DEFAULT_BUILD_TOOLS_VERSION as String } @@ -98,7 +89,7 @@ def enableVerboseMDG = project.gradle.startParameter.logLevel.name() == 'DEBUG' def analyticsFilePath = "$rootDir/analytics/build-statistics.json" def analyticsCollector = project.ext.AnalyticsCollector.withOutputPath(analyticsFilePath) if (enableAnalytics) { - analyticsCollector.markUseKotlinPropertyInApp(enableKotlin) + analyticsCollector.markUseKotlinPropertyInApp(true) analyticsCollector.writeAnalyticsFile() } @@ -185,25 +176,52 @@ def setAppIdentifier = { -> if (appIdentifier) { project.ext.nsApplicationIdentifier = appIdentifier android.defaultConfig.applicationId = appIdentifier + android.namespace = appIdentifier + } + } +} + +def computeNamespace = { -> + def appPackageJsonFile = file("${APP_DIR}/$PACKAGE_JSON") + + if (appPackageJsonFile.exists()) { + def content = appPackageJsonFile.getText("UTF-8") + + def jsonSlurper = new JsonSlurper() + def packageJsonMap = jsonSlurper.parseText(content) + + def appIdentifier = "" + + if (packageJsonMap) { + if (packageJsonMap.android && packageJsonMap.android.id) { + appIdentifier = packageJsonMap.android.id + } else if (packageJsonMap.id) { + appIdentifier = packageJsonMap.id + } + } + + if (appIdentifier) { + return appIdentifier } } + return "com.tns.testapplication" } android { + namespace computeNamespace() + applyBeforePluginGradleConfiguration() - if (enableKotlin) { - kotlinOptions { - jvmTarget = '1.8' - } + kotlinOptions { + jvmTarget = '17' } - compileSdkVersion computeCompileSdkVersion() - buildToolsVersion computeBuildToolsVersion() + compileSdk computeCompileSdkVersion() + buildToolsVersion = computeBuildToolsVersion() defaultConfig { def manifest = new XmlSlurper().parse(file(android.sourceSets.main.manifest.srcFile)) - def minSdkVer = manifest."uses-sdk"."@android:minSdkVersion".text() ?: NS_DEFAULT_MIN_SDK_VERSION + def minSdkVer = manifest."uses-sdk"."@android:minSdkVersion".text() ?: computeMinSdkVersion() minSdkVersion minSdkVer targetSdkVersion computeTargetSdkVersion() ndk { @@ -216,8 +234,8 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } sourceSets.main { @@ -251,12 +269,12 @@ android { applyAppGradleConfiguration() def initializeMergedAssetsOutputPath = { -> - android.applicationVariants.all { variant -> + android.applicationVariants.configureEach { variant -> if (variant.buildType.name == project.selectedBuildType) { def task if (variant.metaClass.respondsTo(variant, "getMergeAssetsProvider")) { def provider = variant.getMergeAssetsProvider() - task = provider.get(); + task = provider.get() } else { // fallback for older android gradle plugin versions task = variant.getMergeAssets() @@ -264,7 +282,7 @@ android { for (File file : task.getOutputs().getFiles()) { if (!file.getPath().contains("${File.separator}incremental${File.separator}")) { project.ext.mergedAssetsOutputPath = file.getPath() - break; + break } } } @@ -394,18 +412,13 @@ dependencies { implementation project(':runtime') } - def kotlinVersion = computeKotlinVersion() - if (enableKotlin) { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" - } - } //////////////////////////////////////////////////////////////////////////////////// ///////////////////////////// CONFIGURATION PHASE ////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// -task addDependenciesFromNativeScriptPlugins { +task 'addDependenciesFromNativeScriptPlugins' { nativescriptDependencies.each { dep -> def aarFiles = fileTree(dir: file("$rootDir/${dep.directory}/$PLATFORMS_ANDROID"), include: ["**/*.aar"]) aarFiles.each { aarFile -> @@ -426,7 +439,7 @@ task addDependenciesFromNativeScriptPlugins { } } -task addDependenciesFromAppResourcesLibraries { +task 'addDependenciesFromAppResourcesLibraries' { def appResourcesPath = getAppResourcesPath() def appResourcesLibraries = file("$appResourcesPath/Android/libs") if (appResourcesLibraries.exists()) { @@ -450,47 +463,22 @@ task addDependenciesFromAppResourcesLibraries { } if (failOnCompilationWarningsEnabled()) { - tasks.withType(JavaCompile) { + tasks.withType(JavaCompile).configureEach { options.compilerArgs << '-Xlint:all' << "-Werror" options.deprecation = true } } -tasks.whenTaskAdded({ DefaultTask currentTask -> - if (currentTask =~ /generate.+BuildConfig/) { - currentTask.finalizedBy(extractAllJars) - extractAllJars.finalizedBy(collectAllJars) - } - if (currentTask =~ /compile.+JavaWithJavac/) { - currentTask.dependsOn(runSbg) - currentTask.finalizedBy(buildMetadata) - } - - - if (currentTask =~ /compile.+Kotlin.+/) { - currentTask.dependsOn(runSbg) - currentTask.finalizedBy(buildMetadata) - } - - if (currentTask =~ /merge.*Assets/) { - currentTask.dependsOn(buildMetadata) - } - // ensure buildMetadata is done before R8 to allow custom proguard from metadata - if (currentTask =~ /minify.*WithR8/) { - currentTask.dependsOn(buildMetadata) - } - if (currentTask =~ /assemble.*Debug/ || currentTask =~ /assemble.*Release/) { - currentTask.finalizedBy("validateAppIdMatch") - } -}) //////////////////////////////////////////////////////////////////////////////////// -///////////////////////////// EXECUTUION PHASE ///////////////////////////////////// +///////////////////////////// EXECUTION PHASE ///////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// task runSbg(type: BuildToolTask) { dependsOn "collectAllJars" + def rootPath = "" if (!findProject(':static-binding-generator').is(null)) { + rootPath = Paths.get(project(':static-binding-generator').projectDir.path, "build/libs").toString() dependsOn ':static-binding-generator:jar' } @@ -499,10 +487,10 @@ task runSbg(type: BuildToolTask) { inputs.dir(extractedDependenciesDir) workingDir "$BUILD_TOOLS_PATH" - main "-jar" + mainClass = "-jar" def paramz = new ArrayList() - paramz.add("static-binding-generator.jar") + paramz.add(Paths.get(rootPath, "static-binding-generator.jar")) if (failOnCompilationWarningsEnabled()) { paramz.add("-show-deprecation-warnings") @@ -548,7 +536,7 @@ def explodeAar(File compileDependency, File outputDir) { } } -def md5(String string) { +static def md5(String string) { MessageDigest digest = MessageDigest.getInstance("MD5") digest.update(string.bytes) return new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') @@ -581,9 +569,9 @@ allprojects { def buildType = project.selectedBuildType def jars = [] def artifactType = Attribute.of('artifactType', String) - android.applicationVariants.all { variant -> + android.applicationVariants.configureEach { variant -> if (variant.buildType.name == buildType) { - variant.getCompileClasspath().each { fileDependency -> + variant.getCompileClasspath(null).each { fileDependency -> processJar(fileDependency, jars) } } @@ -601,7 +589,7 @@ def processJar(File jar, jars) { logger.debug("Creating dynamic task ${taskName}") // Add discovered jars as dependencies of cleanupAllJars. - // This is cruicial for cloud builds because they are different + // This is crucial for cloud builds because they are different // on each incremental build (as each time the gradle user home // directory is a randomly generated string) cleanupAllJars.inputs.files jar @@ -631,7 +619,7 @@ def processJar(File jar, jars) { } } -task cleanupAllJars { +task 'cleanupAllJars' { // We depend on the list of libs directories that might contain aar or jar files // and on the list of all discovered jars inputs.files(pluginDependencies) @@ -656,7 +644,7 @@ task cleanupAllJars { // Placeholder task which depends on all dynamically generated extraction tasks -task extractAllJars { +task 'extractAllJars' { dependsOn cleanupAllJars outputs.files extractAllJarsTimestamp @@ -665,7 +653,7 @@ task extractAllJars { } } -task collectAllJars { +task 'collectAllJars' { dependsOn extractAllJars description "gathers all paths to jar dependencies before building metadata with them" @@ -703,27 +691,31 @@ task collectAllJars { } } -task copyMetadataFilters(type: Copy) { - from "$rootDir/whitelist.mdg", "$rootDir/blacklist.mdg" - into "$BUILD_TOOLS_PATH" +task copyMetadataFilters { + outputs.files("$BUILD_TOOLS_PATH/whitelist.mdg", "$BUILD_TOOLS_PATH/blacklist.mdg") + // use an explicit copy task here because the copy task itselfs marks the whole built-tools as an output! + copy { + from file("$rootDir/whitelist.mdg"), file("$rootDir/blacklist.mdg") + into "$BUILD_TOOLS_PATH" + } } -task copyMetadata { +task 'copyMetadata' { doLast { copy { - from "$projectDir/src/main/assets/metadata" - into getMergedAssetsOutputPath() + "/metadata" + from "$projectDir/src/main/assets/metadata" + into getMergedAssetsOutputPath() + "/metadata" } } } def listf(String directoryName, ArrayList store) { - def directory = new File(directoryName); + def directory = new File(directoryName) - def resultList = new ArrayList(); + def resultList = new ArrayList() - def fList = directory.listFiles(); - resultList.addAll(Arrays.asList(fList)); + def fList = directory.listFiles() + resultList.addAll(Arrays.asList(fList)) for (File file : fList) { if (file.isFile()) { store.add(file) @@ -735,10 +727,173 @@ def listf(String directoryName, ArrayList store) { } task buildMetadata(type: BuildToolTask) { + def rootPath = "" if (!findProject(':android-metadata-generator').is(null)) { + rootPath = Paths.get(project(':android-metadata-generator').projectDir.path, "build/libs").toString() dependsOn ':android-metadata-generator:jar' } + + + android.applicationVariants.all { variant -> + def buildTypeName = variant.buildType.name.capitalize() + def mergeShadersTaskName = "merge${buildTypeName}Shaders" + def mergeShadersTask = tasks.findByName(mergeShadersTaskName) + + if (mergeShadersTask) { + dependsOn mergeShadersTask + } + + def compileJavaWithJavacTaskName = "compile${buildTypeName}JavaWithJavac" + def compileJavaWithJavacTask = tasks.findByName(compileJavaWithJavacTaskName) + + + if (compileJavaWithJavacTask) { + dependsOn compileJavaWithJavacTask + } + + def compileKotlinTaskName = "compile${buildTypeName}Kotlin" + def compileKotlinTask = tasks.findByName(compileKotlinTaskName) + + + if (compileKotlinTask) { + dependsOn compileKotlinTask + } + + + def mergeDexTaskName = "mergeDex${buildTypeName}" + def mergeDexTask = tasks.findByName(mergeDexTaskName) + + if (mergeDexTask) { + dependsOn mergeDexTask + } + + def checkDuplicateClassesTaskName = "check${buildTypeName}DuplicateClasses" + def checkDuplicateClassesTask = tasks.findByName(checkDuplicateClassesTaskName) + + if (checkDuplicateClassesTask) { + dependsOn checkDuplicateClassesTask + } + + def generateBuildConfigTaskName = "generate${buildTypeName}BuildConfig" + def generateBuildConfigTask = tasks.findByName(generateBuildConfigTaskName) + + if (generateBuildConfigTask) { + dependsOn generateBuildConfigTask + } + + def dexBuilderTaskName = "dexBuilder${buildTypeName}" + def dexBuilderTask = tasks.findByName(dexBuilderTaskName) + + if (dexBuilderTask) { + dependsOn dexBuilderTask + } + + + def mergeExtDexTaskName = "mergeExtDex${buildTypeName}" + def mergeExtDexTask = tasks.findByName(mergeExtDexTaskName) + + if (mergeExtDexTask) { + dependsOn mergeExtDexTask + } + + def mergeLibDexTaskName = "mergeLibDex${buildTypeName}" + def mergeLibDexTask = tasks.findByName(mergeLibDexTaskName) + + if (mergeLibDexTask) { + dependsOn mergeLibDexTask + } + + def mergeProjectDexTaskName = "mergeProjectDex${buildTypeName}" + def mergeProjectDexTask = tasks.findByName(mergeProjectDexTaskName) + + if (mergeProjectDexTask) { + dependsOn mergeProjectDexTask + } + + def syncLibJarsTaskName = "sync${buildTypeName}LibJars" + def syncLibJarsTask = tasks.findByName(syncLibJarsTaskName) + + if (syncLibJarsTask) { + dependsOn syncLibJarsTask + } + + def mergeJavaResourceTaskName = "merge${buildTypeName}JavaResource" + def mergeJavaResourceTask = tasks.findByName(mergeJavaResourceTaskName) + + if (mergeJavaResourceTask) { + dependsOn mergeJavaResourceTask + } + + def mergeJniLibFoldersTaskName = "merge${buildTypeName}JniLibFolders" + def mergeJniLibFoldersTask = tasks.findByName(mergeJniLibFoldersTaskName) + + if (mergeJniLibFoldersTask) { + dependsOn mergeJniLibFoldersTask + } + + def mergeNativeLibsTaskName = "merge${buildTypeName}NativeLibs" + def mergeNativeLibsTask = tasks.findByName(mergeNativeLibsTaskName) + + if (mergeNativeLibsTask) { + dependsOn mergeNativeLibsTask + } + + def stripDebugSymbolsTaskName = "strip${buildTypeName}DebugSymbols" + def stripDebugSymbolsTask = tasks.findByName(stripDebugSymbolsTaskName) + + if (stripDebugSymbolsTask) { + dependsOn stripDebugSymbolsTask + } + + def validateSigningTaskName = "validateSigning${buildTypeName}" + def validateSigningTask = tasks.findByName(validateSigningTaskName) + + if (validateSigningTask) { + dependsOn validateSigningTask + } + + + def extractProguardFilesTaskName = "extractProguardFiles" + def extractProguardFilesTask = tasks.findByName(extractProguardFilesTaskName) + + if (extractProguardFilesTask) { + dependsOn extractProguardFilesTask + } + + + def compileArtProfileTaskName = "compile${buildTypeName}ArtProfile" + def compileArtProfileTask = tasks.findByName(compileArtProfileTaskName) + + if (compileArtProfileTask) { + dependsOn compileArtProfileTask + } + + + def extractNativeSymbolTablesTaskName = "extract${buildTypeName}NativeSymbolTables" + def extractNativeSymbolTablesTask = tasks.findByName(extractNativeSymbolTablesTaskName) + + if (extractNativeSymbolTablesTask) { + dependsOn extractNativeSymbolTablesTask + } + + + def optimizeResourcesTaskName = "optimize${buildTypeName}Resources" + def optimizeResourcesTask = tasks.findByName(optimizeResourcesTaskName) + + if (optimizeResourcesTask) { + dependsOn optimizeResourcesTask + } + + def bundleResourcesTaskName = "bundle${buildTypeName}Resources" + def bundleResourcesTask = tasks.findByName(bundleResourcesTaskName) + + if (bundleResourcesTask) { + dependsOn bundleResourcesTask + } + + } + dependsOn copyMetadataFilters // As some external gradle plugins can reorder the execution order of the tasks it may happen that buildMetadata is executed after merge{Debug/Release}Assets @@ -754,20 +909,24 @@ task buildMetadata(type: BuildToolTask) { inputs.files("$MDG_JAVA_DEPENDENCIES") // make MDG aware of whitelist.mdg and blacklist.mdg files - inputs.files(project.fileTree(dir: "$rootDir", include: "**/*.mdg")) + // inputs.files(project.fileTree(dir: "$rootDir", include: "**/*.mdg")) + // use explicit inputs as the above makes the whole build-tools directory an input! + inputs.files("$BUILD_TOOLS_PATH/whitelist.mdg", "$BUILD_TOOLS_PATH/blacklist.mdg") - def classesDir = "$buildDir/intermediates/javac" - inputs.dir(classesDir) + def classesDir = layout.buildDirectory.dir("intermediates/javac").get().asFile + if (classesDir.exists()) { + inputs.dir(classesDir) + } - def kotlinClassesDir = "$buildDir/tmp/kotlin-classes" - if (file(kotlinClassesDir).exists()) { + def kotlinClassesDir = layout.buildDirectory.dir("tmp/kotlin-classes").get().asFile + if (kotlinClassesDir.exists()) { inputs.dir(kotlinClassesDir) } outputs.files("$METADATA_OUT_PATH/treeNodeStream.dat", "$METADATA_OUT_PATH/treeStringsStream.dat", "$METADATA_OUT_PATH/treeValueStream.dat") workingDir "$BUILD_TOOLS_PATH" - main "-jar" + mainClass = "-jar" doFirst { // get compiled classes to pass to metadata generator @@ -780,8 +939,8 @@ task buildMetadata(type: BuildToolTask) { rootProject.subprojects { - def projectClassesDir = new File("$it.buildDir/intermediates/javac") - def projectKotlinClassesDir = new File("$it.buildDir/tmp/kotlin-classes") + def projectClassesDir = it.layout.buildDirectory.dir("intermediates/javac").get().asFile + def projectKotlinClassesDir = it.layout.buildDirectory.dir("tmp/kotlin-classes").get().asFile if (projectClassesDir.exists()) { def projectClassesSubDirs = projectClassesDir.listFiles() @@ -792,14 +951,14 @@ task buildMetadata(type: BuildToolTask) { } } - if (projectKotlinClassesDir.exists()) { - def projectKotlinClassesSubDirs = projectKotlinClassesDir.listFiles(); - for (File subDir : projectKotlinClassesSubDirs) { - if (!kotlinClassesSubDirs.contains(subDir)) { - kotlinClassesSubDirs.add(subDir) - } + if (projectKotlinClassesDir.exists()) { + def projectKotlinClassesSubDirs = projectKotlinClassesDir.listFiles() + for (File subDir : projectKotlinClassesSubDirs) { + if (!kotlinClassesSubDirs.contains(subDir)) { + kotlinClassesSubDirs.add(subDir) + } + } } - } } def generatedClasses = new LinkedList() @@ -816,7 +975,7 @@ task buildMetadata(type: BuildToolTask) { } def store = new ArrayList() - for (String dir: generatedClasses){ + for (String dir : generatedClasses) { listf(dir, store) } @@ -839,13 +998,13 @@ task buildMetadata(type: BuildToolTask) { setOutputs outLogger def paramz = new ArrayList() - paramz.add("android-metadata-generator.jar") + paramz.add(Paths.get(rootPath, "android-metadata-generator.jar")) - if(enableAnalytics){ + if (enableAnalytics) { paramz.add("analyticsFilePath=$analyticsFilePath") } - if(enableVerboseMDG){ + if (enableVerboseMDG) { paramz.add("verbose") } @@ -862,7 +1021,7 @@ task generateTypescriptDefinitions(type: BuildToolTask) { def includeDirs = ["com.android.support", "/platforms/" + android.compileSdkVersion] workingDir "$BUILD_TOOLS_PATH" - main "-jar" + mainClass = "-jar" doFirst { delete "$TYPINGS_PATH" @@ -907,7 +1066,7 @@ static def shouldIncludeDirForTypings(path, includeDirs) { return false } -task copyTypings { +task 'copyTypings' { doLast { outLogger.withStyle(Style.Info).println "Copied generated typings to application root level. Make sure to import android.d.ts in reference.d.ts" @@ -921,12 +1080,12 @@ task copyTypings { copyTypings.onlyIf { generateTypescriptDefinitions.didWork } generateTypescriptDefinitions.finalizedBy(copyTypings) -task validateAppIdMatch { +task 'validateAppIdMatch' { doLast { def lineSeparator = System.getProperty("line.separator") if (project.hasProperty("nsApplicationIdentifier") && !project.hasProperty("release")) { - if (project.nsApplicationIdentifier != android.defaultConfig.applicationId) { + if (project.nsApplicationIdentifier != android.defaultConfig.applicationId && android.namespace != appIdentifier) { def errorMessage = "${lineSeparator}WARNING: The Application identifier is different from the one inside \"package.json\" file.$lineSeparator" + "NativeScript CLI might not work properly.$lineSeparator" + "Remove applicationId from app.gradle and update the \"nativescript.id\" in package.json.$lineSeparator" + @@ -965,3 +1124,186 @@ task cleanMdg(type: Delete) { cleanSbg.dependsOn(cleanMdg) clean.dependsOn(cleanSbg) + + +//dependsOn { +// pattern { +// include "merge*.Shaders" // Matches tasks starting with "merge" and ending with "Shaders" +// } +//} + + +tasks.configureEach({ DefaultTask currentTask -> + // println "\t ~ [DEBUG][app] build.gradle - currentTask = ${currentTask.name} ..." + + if (currentTask =~ /compile.+JavaWithJavac/) { + currentTask.dependsOn(runSbg) + } + + if (currentTask =~ /mergeDex.+/) { + currentTask.dependsOn(runSbg) + } + + if (currentTask =~ /compile.+Kotlin.+/) { + currentTask.dependsOn(runSbg) + } + + if (currentTask =~ /merge.*Assets/) { + currentTask.dependsOn(buildMetadata) + } + +// // ensure buildMetadata is done before R8 to allow custom proguard from metadata + if (currentTask =~ /minify.*WithR8/) { + buildMetadata.finalizedBy(currentTask) + } + if (currentTask =~ /assemble.*Debug/ || currentTask =~ /assemble.*Release/) { + currentTask.finalizedBy("validateAppIdMatch") + } + + if (currentTask =~ /process.+Resources/) { + cleanupAllJars.dependsOn(currentTask) + } + +// if (currentTask.name == "extractProguardFiles") { +// currentTask.finalizedBy(buildMetadata) +// } +// + if (currentTask =~ /generate.+LintVitalReportModel/) { + currentTask.dependsOn(buildMetadata) + } + + if (currentTask =~ /lintVitalAnalyze.+/) { + currentTask.dependsOn(buildMetadata) + } +// +// if (currentTask =~ /merge.+GlobalSynthetics/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /optimize.+Resources/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /buildCMake.*/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /configureCMake.*/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /validateSigning.*/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /generate.*LintReportModel/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /generate.*AndroidTestResValues/) { +// // buildMetadata.dependsOn(currentTask) +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /generate.*AndroidTestLintModel/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /generate.*UnitTestLintModel/) { +// buildMetadata.mustRunAfter(currentTask) +// } +// +// if (currentTask =~ /generate.*UnitTestLintModel/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// +// if (currentTask =~ /lintAnalyze.*UnitTest/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /process.*JavaRes/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /strip.*DebugSymbols/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /merge.*JavaResource/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /lintAnalyze.*/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /lintAnalyze.*AndroidTest/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /bundle.*Resources/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /compile.*ArtProfile/) { +// currentTask.mustRunAfter(buildMetadata) +// } +// +// if (currentTask =~ /check.*DuplicateClasses/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /check.*AarMetadata/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /create.*CompatibleScreenManifests/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /process.*Manifest/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /generate.*ResValues/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /merge.*Resources/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /package.*Resources/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /process.*Resources/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /desugar.*Dependencies/) { +// currentTask.finalizedBy(buildMetadata) +// } +// +// if (currentTask =~ /merge.*JniLibFolders/) { +// currentTask.finalizedBy(buildMetadata) +// } + +}) + +rootProject.subprojects.forEach { + it.tasks.configureEach({ DefaultTask currentTask -> + if (currentTask =~ /.+bundleLibCompileToJar.*/) { + currentTask.finalizedBy(cleanupAllJars) + } + + if (currentTask =~ /bundleLibRuntimeToDir.*/) { + currentTask.finalizedBy(buildMetadata) + } + + if (currentTask =~ /compile.*LibraryResources/) { + currentTask.finalizedBy(buildMetadata) + } + }) +} diff --git a/test-app/app/src/debug/java/com/tns/ErrorReport.java b/test-app/app/src/debug/java/com/tns/ErrorReport.java index 83e7f3751..d2b5cf2d6 100644 --- a/test-app/app/src/debug/java/com/tns/ErrorReport.java +++ b/test-app/app/src/debug/java/com/tns/ErrorReport.java @@ -19,13 +19,17 @@ import android.app.PendingIntent.CanceledException; import android.content.ClipData; import android.content.ClipboardManager; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; +import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.os.Environment; import com.google.android.material.tabs.TabLayout; + +import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -33,7 +37,15 @@ import androidx.viewpager.widget.ViewPager; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; + +import android.text.SpannableString; +import android.text.SpannableStringBuilder; +import android.text.method.LinkMovementMethod; import android.text.method.ScrollingMovementMethod; +import android.text.style.AbsoluteSizeSpan; +import android.text.style.ClickableSpan; +import android.text.style.ForegroundColorSpan; +import android.text.style.StyleSpan; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -42,7 +54,6 @@ import android.widget.TextView; import android.widget.Toast; - class ErrorReport implements TabLayout.OnTabSelectedListener { public static final String ERROR_FILE_NAME = "hasError"; private static AppCompatActivity activity; @@ -349,26 +360,96 @@ public int getCount() { } } - public static class ExceptionTab extends Fragment { + + public static class ExceptionTab extends Fragment { + + public SpannableStringBuilder getStyledStacktrace(String trace) { + if (trace == null) return null; + String[] traceLines = trace.trim().split("\n"); + SpannableStringBuilder builder = new SpannableStringBuilder(); + boolean firstLine = true; + for (String line: traceLines) { + if (firstLine) { + firstLine = false; + } else { + builder.append("\n"); + builder.append("\n"); + } + + String[] nameAndPath = line.trim().split("\\("); + SpannableString nameSpan = new SpannableString(nameAndPath[0]); + nameSpan.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, nameAndPath[0].length(), 0); + builder.append(nameSpan); + + builder.append(" "); + if (nameAndPath.length > 1) { + SpannableString pathSpan = new SpannableString("(" + nameAndPath[1]); + pathSpan.setSpan(new AbsoluteSizeSpan(13, true),0, nameAndPath[1].length() + 1, 0); + pathSpan.setSpan(new ClickableSpan() { + @Override + public void onClick(@NonNull View widget) { + Log.d("JS", line.trim()); + } + }, 0,nameAndPath[1].length() + 1, 0); + pathSpan.setSpan(new ForegroundColorSpan(Color.GRAY),0, nameAndPath[1].length() + 1, 0); + + builder.append(pathSpan); + } + } + return builder; + } + + public static void restartApp(Context context) { + PackageManager packageManager = context.getPackageManager(); + Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName()); + ComponentName componentName = intent.getComponent(); + Intent mainIntent = Intent.makeRestartActivityTask(componentName); + context.startActivity(mainIntent); + java.lang.Runtime.getRuntime().exit(0); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int exceptionTabId = container.getContext().getResources().getIdentifier("exception_tab", "layout", container.getContext().getPackageName()); View view = inflater.inflate(exceptionTabId, container, false); - int txtViewId = container.getContext().getResources().getIdentifier("txtErrorMsg", "id", container.getContext().getPackageName()); - TextView txtErrorMsg = (TextView) view.findViewById(txtViewId); - txtErrorMsg.setText(exceptionMsg); - txtErrorMsg.setMovementMethod(new ScrollingMovementMethod()); + int errorExceptionViewId = activity.getResources().getIdentifier("errorException", "id", activity.getPackageName()); + TextView errorExceptionView = (TextView) activity.findViewById(errorExceptionViewId); + errorExceptionView.setMovementMethod(new ScrollingMovementMethod()); + + int errorStackTraceViewId = container.getContext().getResources().getIdentifier("errorStacktrace", "id", container.getContext().getPackageName()); + TextView errorStackTraceView = (TextView) view.findViewById(errorStackTraceViewId); + + String[] exceptionParts = exceptionMsg.split("StackTrace:"); + String error = exceptionParts[0]; + String trace = ""; + + if (exceptionParts.length > 1) { + for (int i=0;i < exceptionParts.length;i++) { + if (i == 0) continue; + trace += exceptionParts[i]; + } + } + + errorExceptionView.setText(error.trim()); + + errorStackTraceView.setText(trace != null ? getStyledStacktrace(trace) : "", TextView.BufferType.SPANNABLE); + errorStackTraceView.setMovementMethod(new ScrollingMovementMethod()); + errorStackTraceView.setMovementMethod(LinkMovementMethod.getInstance()); + errorStackTraceView.setEnabled(true); int btnCopyExceptionId = container.getContext().getResources().getIdentifier("btnCopyException", "id", container.getContext().getPackageName()); Button copyToClipboard = (Button) view.findViewById(btnCopyExceptionId); - copyToClipboard.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); - ClipData clip = ClipData.newPlainText("nsError", exceptionMsg); - clipboard.setPrimaryClip(clip); - } + + int btnRestartAppId = container.getContext().getResources().getIdentifier("btnRestartApp", "id", container.getContext().getPackageName()); + Button restartApp = (Button) view.findViewById(btnRestartAppId); + restartApp.setOnClickListener(v -> { + restartApp(getContext().getApplicationContext()); + }); + copyToClipboard.setOnClickListener(v -> { + ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("nsError", exceptionMsg); + clipboard.setPrimaryClip(clip); }); return view; diff --git a/test-app/app/src/debug/res/drawable/button.xml b/test-app/app/src/debug/res/drawable/button.xml new file mode 100644 index 000000000..ec005653c --- /dev/null +++ b/test-app/app/src/debug/res/drawable/button.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/test-app/app/src/debug/res/drawable/button_accented.xml b/test-app/app/src/debug/res/drawable/button_accented.xml new file mode 100644 index 000000000..2d5065498 --- /dev/null +++ b/test-app/app/src/debug/res/drawable/button_accented.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/test-app/app/src/debug/res/layout/error_activity.xml b/test-app/app/src/debug/res/layout/error_activity.xml index d00b3695a..9e614f6f3 100644 --- a/test-app/app/src/debug/res/layout/error_activity.xml +++ b/test-app/app/src/debug/res/layout/error_activity.xml @@ -1,39 +1,62 @@ - - + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:background="@color/gray" + tools:context="com.tns.ErrorReportActivity" + android:theme="@style/Widget.AppCompat.Light.ActionBar"> - - - - - \ No newline at end of file + android:textColor="@color/white" + android:paddingVertical="10dp" + android:paddingRight="16dp" /> + + + + + + + + + + + + + diff --git a/test-app/app/src/debug/res/layout/exception_tab.xml b/test-app/app/src/debug/res/layout/exception_tab.xml index 4e9bca2bb..4d3a545f4 100644 --- a/test-app/app/src/debug/res/layout/exception_tab.xml +++ b/test-app/app/src/debug/res/layout/exception_tab.xml @@ -1,52 +1,71 @@ - -