You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project contains multiple builds, living side by side together.
64
64
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:
66
104
67
105
```bash
68
106
> swift test
69
107
```
70
108
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
73
113
74
114
```bash
75
115
> ./gradlew test
76
116
```
77
117
78
-
Currently it is suggested to use Swift 6.0 and a Java 24+.
118
+
> Tip: A lot of the **runtime tests**forcode relying on `jextract` are **locatedin 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).
79
122
80
-
### Sample Apps
123
+
### Sample apps & tests
81
124
82
125
Sample apps are located in the `Samples/` directory, and they showcase full "roundtrip" usage of the library and/or tools.
83
126
@@ -101,19 +144,27 @@ To run a simple example app showcasing the jextract (Java calling Swift) approac
101
144
This will also generate the necessary sources (by invoking jextract, extracting the `Sources/ExampleSwiftLibrary`)
102
145
and generating Java sources in`src/generated/java`.
103
146
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
+
104
151
## Benchmarks
105
152
106
153
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.
107
154
108
155
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.
109
156
157
+
### Swift benchmarks
158
+
110
159
To run **Swift benchmarks** you can:
111
160
112
161
```bash
113
162
cd Benchmarks
114
163
swift package benchmark
115
164
```
116
165
166
+
### Java benchmarks
167
+
117
168
In order to run JMH benchmarks you can:
118
169
119
170
```bash
@@ -125,4 +176,20 @@ Please read documentation of both performance testing tools and understand that
125
176
126
177
## User Guide
127
178
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:
0 commit comments