-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop Java builds with Gradle #633
Commits on Apr 30, 2020
-
Move Android build.gradle file from root
Introduce a subproject ":android" for AndroidThemis builds. We can't continue using top-level build.gradle for everything if we are going to use Gradle for Desktop Java too. This changes the invocation strings for targets which now need to be qualified (by prefixing ":android:..."). Leave the top-level file with some common definitions. This allows to not write them in each subproject and to use "./gradlew" right from the repository root.
Configuration menu - View commit details
-
Copy full SHA for 2299322 - Browse repository at this point
Copy the full SHA 2299322View commit details -
Basic desktop Java build with Gradle
Add a subproject ":desktop" for 'Desktop Java' builds of JavaThemis. This will produce a JAR with Java bytecode only, suitable for use by desktop Java projects. You can build it with ./gradlew :desktop:build and collect artifacts from "src/wrappers/themis/java/build/jar". The resulting JAR file is named "java-themis" because the name "themis" is already taked by AndroidThemis.
Configuration menu - View commit details
-
Copy full SHA for 2a56ec9 - Browse repository at this point
Copy the full SHA 2a56ec9View commit details -
Debian stable has upgraded its default Java version to 11. Gradle 4.X does not support Java 11. This version is supported only since 5.0. Upgrade to latest Gradle 5.X version. Note that *the latest* version branch is Gradle 6.X. We won't jump versions that fast. Gradle 5.X requires Java 8 (previously it required Java 7). This cuts some older systems that ship with only Java 7: - Debian 8 "Jessie" - oldoldstable, no security support since June 2018, LTS support lapses in July 2020 (Only for JavaThemis, obviously.)
Configuration menu - View commit details
-
Copy full SHA for b317a23 - Browse repository at this point
Copy the full SHA b317a23View commit details -
Enable Gradle's "configure on demand"
By default Gradle will configure all subprojects of a top-level project. For us that means that we'll force AndroidThemis configuration even if the user is trying to build JavaThemis for desktop. That will require a properly installed and configured Android SDK, completely unnecessary. Thankfully, Gradle also have an experimental "configure on demand" mode which will configure only the projects actually requested and needed for the build. Enable this feature. It is 'experimental' but this means that it might not work for some projects, but Gradle team plans to make this mode the default one. It works for us, so it's okay.
Configuration menu - View commit details
-
Copy full SHA for b3ed417 - Browse repository at this point
Copy the full SHA b3ed417View commit details -
Suppress deprecations on finalizers
We build JavaThemis with deprecation warnings enabled. Object finalizers are deprecated since Java 9. In our case we genuienly need finalizers to prevent native memory leaks so suppress these warnings.
Configuration menu - View commit details
-
Copy full SHA for 23c9eb2 - Browse repository at this point
Copy the full SHA 23c9eb2View commit details
Commits on May 1, 2020
-
Run JUnit tests during Gradle builds
The "build" target already runs tests if they are set up. Configure JUnit test compilation and runner. Note that JavaThemis requires JNI library to be loaded. By default it is installed into a location that is not present in the Java library search path. We need to explicitly add "/usr/local/lib" to "java.library.path" property. Also note that Gradle will run JUnit stuff in a separate JVM so we need to pass the system property to that JVM from the main one.
Configuration menu - View commit details
-
Copy full SHA for 760a108 - Browse repository at this point
Copy the full SHA 760a108View commit details -
Load JNI library from each class
Every class having native methods should have a System.loadLibrary() call so that if only that class is loaded by JVM, the native library is also loaded correctly. It kinda worked before because typically users and tests load other classes, but if *only* SymmetricKey is loaded then it failed to locate the native method. (For example, JUnit might run each test in separate JVMs which load only necessary classes.)
Configuration menu - View commit details
-
Copy full SHA for 5496669 - Browse repository at this point
Copy the full SHA 5496669View commit details -
Set package version via gradle.properties
Use common properties to have a single place we need to update when doing a release.
Configuration menu - View commit details
-
Copy full SHA for 3df5139 - Browse repository at this point
Copy the full SHA 3df5139View commit details -
More version updates suggested by Android Studio
Update Gradle support library to the latest stable version. Update Gradle wrapper to the latest patch version too (required for some of others updates). And update the Android test runners as well. New test runners require AndroidX property to be enabled in the properties file so add that as well.
Configuration menu - View commit details
-
Copy full SHA for c075645 - Browse repository at this point
Copy the full SHA c075645View commit details -
Configuration menu - View commit details
-
Copy full SHA for f80269a - Browse repository at this point
Copy the full SHA f80269aView commit details -
Downgrade Gradle library to 3.5.3
Android Studio recommends using current latest stable version 3.6.3, but it seems to have some issues with NDK version detection. Since we have different NDK versions in our CI environments, we can't use the version which fails to work with them. Gradle tools v3.6.3 fail the build and require a particular version of NDK, for example: * What went wrong: A problem occurred configuring project ':android'. > No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669 Version 3.5.X does not seem to have such issues, so let's use it then.
Configuration menu - View commit details
-
Copy full SHA for 3165bc8 - Browse repository at this point
Copy the full SHA 3165bc8View commit details -
Revert to using Gradle tools 3.2.1
It seems that 3.5.3 does not work either. I don't want to spend more time on this discretionary upgrade, so just revert to the version which is known to work and let's keep it pinned that way until we need to upgrade to have some new features or bug fixes.
Configuration menu - View commit details
-
Copy full SHA for f2671dc - Browse repository at this point
Copy the full SHA f2671dcView commit details -
Configuration menu - View commit details
-
Copy full SHA for ed3b5c5 - Browse repository at this point
Copy the full SHA ed3b5c5View commit details