Skip to content

Commit 4495da6

Browse files
authored
more readme updates, installation instruction for all (#331)
1 parent cbbe172 commit 4495da6

File tree

1 file changed

+73
-6
lines changed

1 file changed

+73
-6
lines changed

README.md

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,65 @@ Required language/runtime versions:
6262

6363
This project contains multiple builds, living side by side together.
6464

65-
Depending on which part you are developing, you may want to run just the swift tests:
65+
You will need to have:
66+
- Swift (6.1.x+)
67+
- Java (24+ for FFM, even though we support lower JDK targets)
68+
- Gradle (installed by "Gradle wrapper" automatically when you run gradle through `./gradlew`)
69+
70+
### Preparing your environment
71+
72+
Install **Swift**, the easiest way to do this is to use **Swiftly**: [swift.org/install/](https://www.swift.org/install/).
73+
This should automatically install a recent Swift, but you can always make sure by running:
74+
75+
```bash
76+
swiftly install 6.1.2 --use
77+
```
78+
79+
Install a recent enough Java distribution. We validate this project using Corretto so you can choose to use that as well,
80+
however any recent enough Java distribution should work correctly. You can use sdkman to install Java:
81+
82+
```bash
83+
# Install sdkman from: https://sdkman.io
84+
curl -s "https://get.sdkman.io" | bash
85+
sdk install java 17.0.15-amzn
86+
sdk install java 24.0.1-amzn
87+
88+
sdk use java 24.0.1-amzn
89+
```
90+
91+
The use of JDK 24 is required to build the project, even though the libraries being published may target lower Java versions.
92+
93+
❗️ Please make sure to `export JAVA_HOME` such that swift-java can find the necessary java libraries!
94+
When using sdkman the easiest way to export JAVA_HOME is to export the "current" used JDK's home, like this:
95+
96+
```bash
97+
export JAVA_HOME="$(sdk home java current)
98+
```
99+
100+
### Testing your changes
101+
102+
Many tests, including source generation tests, are written in Swift and you can execute them all by running the
103+
swift package manager test command:
66104
67105
```bash
68106
> swift test
69107
```
70108
71-
or the Java tests through the Gradle build. The Gradle build may also trigger some Swift compilation because of
72-
interlinked dependencies of the two parts of Swift-Java. To run the Java build and tests use the Gradle wrapper script:
109+
When adding tests in `Tests/...` targets, you can run these tests (or filter a specific test using `swift test --filter type-or-method-name`).
110+
111+
Some tests are implemented in Java and therefore need to be executed using Gradle.
112+
Please always use the gradle wrapper (`./gradlew`) to make sure to use the appropriate Gradle version
73113
74114
```bash
75115
> ./gradlew test
76116
```
77117
78-
Currently it is suggested to use Swift 6.0 and a Java 24+.
118+
> Tip: A lot of the **runtime tests** for code relying on `jextract` are **located in sample apps**,
119+
> so if you need to runtime test any code relying on source generation steps of jextract, consider adding the tests
120+
> to an appropriate Sample. These tests are also executed in CI (which you can check in the `ci-validate.sh` script
121+
> contained in every sample repository).
79122
80-
### Sample Apps
123+
### Sample apps & tests
81124
82125
Sample apps are located in the `Samples/` directory, and they showcase full "roundtrip" usage of the library and/or tools.
83126
@@ -101,19 +144,27 @@ To run a simple example app showcasing the jextract (Java calling Swift) approac
101144
This will also generate the necessary sources (by invoking jextract, extracting the `Sources/ExampleSwiftLibrary`)
102145
and generating Java sources in `src/generated/java`.
103146
147+
#### Other sample apps
148+
149+
Please refer to the [Samples](Samples) directory for more sample apps which showcase the various usage modes of swift-java.
150+
104151
## Benchmarks
105152
106153
You can run Swift [ordo-one/package-benchmark](https://github.com/ordo-one/package-benchmark) and OpenJDK [JMH](https://github.com/openjdk/jmh) benchmarks in this project.
107154
108155
Swift benchmarks are located under `Benchmarks/` and JMH benchmarks are currently part of the SwiftKit sample project: `Samples/SwiftKitSampleApp/src/jmh` because they depend on generated sources from the sample.
109156
157+
### Swift benchmarks
158+
110159
To run **Swift benchmarks** you can:
111160
112161
```bash
113162
cd Benchmarks
114163
swift package benchmark
115164
```
116165
166+
### Java benchmarks
167+
117168
In order to run JMH benchmarks you can:
118169
119170
```bash
@@ -125,4 +176,20 @@ Please read documentation of both performance testing tools and understand that
125176
126177
## User Guide
127178
128-
More details about the project and how it can be used are available in [USER_GUIDE.md](USER_GUIDE.md)
179+
More details about the project can be found in [docc](https://www.swift.org/documentation/docc/) documentation.
180+
181+
To view the rendered docc documentation you can use the docc preview command:
182+
183+
```bash
184+
xcrun docc preview Sources/SwiftJavaDocumentation/Documentation.docc
185+
186+
# OR JavaKit to view JavaKit documentation:
187+
# xcrun docc preview Sources/JavaKit/Documentation.docc
188+
189+
# ========================================
190+
# Starting Local Preview Server
191+
# Address: http://localhost:8080/documentation/documentation
192+
# ========================================
193+
# Monitoring /Users/ktoso/code/swift-java/Sources/SwiftJavaDocumentation/Documentation.docc for changes...
194+
195+
```

0 commit comments

Comments
 (0)