Skip to content

Commit de35c0a

Browse files
authored
Merge pull request #7 from swiftlang/wip-simplify-swiftjavaexample
Simplify hashing example setup, update readme
2 parents 72e2a21 + 5ea5da3 commit de35c0a

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sat Aug 09 13:51:11 EEST 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

hello-swift-library/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The project consists of:
1313

1414
Before you can build and run this project, you need to have the following installed:
1515

16-
* **Java Development Kit (JDK)**: We recommend using JDK 21. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path.
16+
* **Java Development Kit (JDK)**: We recommend using JDK 25. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path.
1717
* **Swiftly**: You need to install [Swiftly](https://www.swift.org/install/)
1818
* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://swift.org/install)
1919

hello-swift/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The project consists of:
1515

1616
Before you can build and run this project, you need to have the following installed:
1717

18-
* **Java Development Kit (JDK)**: We recommend using JDK 21. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path.
18+
* **Java Development Kit (JDK)**: We recommend using JDK 25. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path.
1919
* **Swiftly**: You need to install [Swiftly](https://www.swift.org/install/)
2020
* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://swift.org/install)
2121

native-activity/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The project consists of:
1515

1616
Before you can build and run this project, you need to have the following installed:
1717

18-
* **Java Development Kit (JDK)**: We recommend using JDK 21. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path.
18+
* **Java Development Kit (JDK)**: We recommend using JDK 25. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path.
1919
* **Swiftly**: You need to install [Swiftly](https://www.swift.org/install/)
2020
* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://swift.org/install)
2121
* **Device/emulator with OpenGL ES support**

swift-java-hashing-example/README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,40 @@ The project is structured into two main parts:
1919

2020
Before you can build and run this project, you need to have the following installed:
2121

22-
* **Java Development Kit (JDK)**: We recommend using JDK 21. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path.
22+
* **Java Development Kit (JDK)**: This example requires the use of JDK 25. This is only necessary to locally publish the swift-java dependencies, and will not be required in the future. To simplify the build steps, we recommend installing JDK 25 and following all the steps below using the same JDK. Ensure the `JAVA_HOME` environment variable is set to your JDK installation path.
2323
* **Swiftly**: You need to install [Swiftly](https://www.swift.org/install/)
2424
* **Swift SDK for Android**: You need to install the [Swift SDK for Android](https://swift.org/install)
2525

2626
## Setup and Configuration
2727

28+
### Prepare Swift Android SDK and matching Swift
29+
30+
Currently these examples utilize very recent nightly Swift Android SDK versions. In order to install these, you can use Swiftly (the Swift toolchain installer):
31+
32+
You can follow [these instructions](https://www.swift.org/documentation/articles/swift-sdk-for-android-getting-started.html) to install an appropriate Swift SDK for Android.
33+
2834
### Publish `swift-java` packages locally
29-
As the `swift-java` project does not yet publish the neccessary Java packages needed at runtime, we need to do it ourself, by performing the following steps:
35+
As the `swift-java` project does not yet publish the necessary Java packages needed at runtime, we need to do it ourselves, by performing the following steps:
36+
37+
> Note: This step will not be necessary once swift-java publishes releases.
38+
39+
In order to publish all artifacts from this library, you must use JDK 25, because some parts of swift-java are built for the most recent Java versions. You will not have to use JDK 25 for the rest of the development process.
40+
A simple way to install and manage local Java installations is [sdkman](https://sdkman.io):
41+
42+
> Note: You will _not_ have to use most recent Java versions for your Android app, and the example currently targets Java language version 11.
43+
44+
Here's how to install `sdkman`:
45+
```bash
46+
curl -s "https://get.sdkman.io" | bash
47+
```
48+
Now restart the terminal so that the `sdk` utility is added to your path, and then set JDK 25 as your current Java install.
49+
50+
```bash
51+
sdk install java 25.0.1-amzn --use # only in order to publish swift-java artifacts locally
52+
export JAVA_HOME="${HOME}//.sdkman/candidates/java/current"
53+
```
54+
55+
Next, let's prepare and publish the swift-java support libraries:
3056

3157
1. Enter the `hashing-lib` directory
3258
```bash

swift-java-hashing-example/hashing-lib/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ android {
1717
}
1818

1919
java {
20-
toolchain {
21-
languageVersion = JavaLanguageVersion.of(11)
22-
}
20+
sourceCompatibility = JavaVersion.VERSION_11
21+
targetCompatibility = JavaVersion.VERSION_11
2322
}
2423

2524
dependencies {

0 commit comments

Comments
 (0)