Skip to content

fix(main/gradle): build bundled JNI libraries for Android - #33813

Open
GeneralKaos666 wants to merge 3 commits into
termux:masterfrom
GeneralKaos666:fix/gradle-native-libs
Open

GeneralKaos666 wants to merge 3 commits into
termux:masterfrom
GeneralKaos666:fix/gradle-native-libs

Conversation

@GeneralKaos666

Copy link
Copy Markdown
Contributor

gradle bundles native-platform, gradle-fileevents and jansi as glibc builds, so their JNI libraries fail to load on bionic. gradle then falls back to UnsupportedEnvironment, which cannot set environment variables or the process directory: a reused daemon keeps the environment and working directory of the command that started it, file watching and the rich console stay off, and every build prints Unable to set daemon's environment variables to match the client.

This builds the three libraries for Android in the recipe and repacks them into the bundled jars. The glibc ncurses5 library is removed, and the native-platform, gradle-fileevents and jansi extraction keys are suffixed with -termux so libraries extracted by earlier installs are not reused. 32-bit ARM is unchanged: native-platform has no platform for it.

Fixes #32089. Ported from the closed PR #32756.

Verified with the CI-built aarch64 package, fresh and over a ~${GRADLE_USER_HOME}/native populated by the current package: environment changes reach a reused daemon, user.dir is the project directory, file watching is active, the rich console works and the warning is gone. CI builds pass on aarch64, arm, i686 and x86_64.

native-platform, gradle-fileevents and jansi are bundled as glibc builds, so
dlopen fails on bionic and gradle falls back to UnsupportedEnvironment. The
daemon then ignores the client environment and working directory, and file
watching and the rich console stay off.

Build the three libraries against bionic in the recipe, repack them into the
bundled jars and bump the extraction keys so copies extracted by earlier
installs are not reused.

Ported from the closed PR termux#32756, based on gradle 9.9.3.
Comment thread packages/gradle/build.sh Resolved
Comment thread packages/gradle/build.sh Resolved
Use printf with the expanded glob to join the jar paths and strip the
trailing separator, since ls output is not machine readable.
The native-platform, gradle-fileevents and jansi versions are pinned
separately from the gradle version, so they drift from the versions that
the new release bundles.

Override termux_pkg_auto_update() to read the three pins from
gradle/dependency-management/distribution.versions.toml at the latest
gradle tag, rewrite the _*_VERSION variables and hand the rest of the
bump to termux_pkg_upgrade_version().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: gradle daemon ignores the client's environment variables and working directory

2 participants