Skip to content

Commit ecd021c

Browse files
committed
more readme updates, installation instruction for all
1 parent 11dcbed commit ecd021c

File tree

1 file changed

+67
-6
lines changed

1 file changed

+67
-6
lines changed

README.md

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,59 @@ 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+
```
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+
```
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 21.0.7-amzn
87+
sdk install java 24.0.1-amzn
88+
89+
sdk use java 21.0.7-amzn
90+
```
91+
92+
Make sure to use Java 21 because Gradle 8.10 isn't quite ready for JDK 24 as time of writing this readme (if this changes, please update the readme).
93+
94+
### Testing your changes
95+
96+
Many tests, including source generation tests, are written in Swift and you can execute them all by running the
97+
swift package manager test command:
6698

6799
```bash
68100
> swift test
69101
```
70102

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:
103+
When adding tests in `Tests/...` targets, you can run these tests (or filter a specific test using `swift test --filter type-or-method-name`).
104+
105+
Some tests are implemented in Java and therefore need to be executed using Gradle.
106+
Please always use the gradle wrapper (`./gradlew`) to make sure to use the appropriate Gradle version
73107

74108
```bash
75109
> ./gradlew test
76110
```
77111

78-
Currently it is suggested to use Swift 6.0 and a Java 24+.
112+
> Tip: A lot of the **runtime tests** for code relying on `jextract` are **located in sample apps**,
113+
> so if you need to runtime test any code relying on source generation steps of jextract, consider adding the tests
114+
> to an appropriate Sample. These tests are also executed in CI (which you can check in the `ci-validate.sh` script
115+
> contained in every sample repository).
79116
80-
### Sample Apps
117+
### Sample apps & tests
81118

82119
Sample apps are located in the `Samples/` directory, and they showcase full "roundtrip" usage of the library and/or tools.
83120

@@ -101,19 +138,27 @@ To run a simple example app showcasing the jextract (Java calling Swift) approac
101138
This will also generate the necessary sources (by invoking jextract, extracting the `Sources/ExampleSwiftLibrary`)
102139
and generating Java sources in `src/generated/java`.
103140

141+
#### Other sample apps
142+
143+
Please refer to the [Samples](Samples) directory for more sample apps which showcase the various usage modes of swift-java.
144+
104145
## Benchmarks
105146

106147
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.
107148

108149
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.
109150

151+
### Swift benchmarks
152+
110153
To run **Swift benchmarks** you can:
111154

112155
```bash
113156
cd Benchmarks
114157
swift package benchmark
115158
```
116159

160+
### Java benchmarks
161+
117162
In order to run JMH benchmarks you can:
118163

119164
```bash
@@ -125,4 +170,20 @@ Please read documentation of both performance testing tools and understand that
125170

126171
## User Guide
127172

128-
More details about the project and how it can be used are available in [USER_GUIDE.md](USER_GUIDE.md)
173+
More details about the project can be found in [docc](https://www.swift.org/documentation/docc/) documentation.
174+
175+
To view the rendered docc documentation you can use the docc preview command:
176+
177+
```bash
178+
xcrun docc preview Sources/SwiftJavaDocumentation/Documentation.docc
179+
180+
# OR JavaKit to view JavaKit documentation:
181+
# xcrun docc preview Sources/JavaKit/Documentation.docc
182+
183+
# ========================================
184+
# Starting Local Preview Server
185+
# Address: http://localhost:8080/documentation/documentation
186+
# ========================================
187+
# Monitoring /Users/ktoso/code/swift-java/Sources/SwiftJavaDocumentation/Documentation.docc for changes...
188+
189+
```

0 commit comments

Comments
 (0)