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
+
```
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:
66
98
67
99
```bash
68
100
> swift test
69
101
```
70
102
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
73
107
74
108
```bash
75
109
> ./gradlew test
76
110
```
77
111
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).
79
116
80
-
### Sample Apps
117
+
### Sample apps & tests
81
118
82
119
Sample apps are located in the `Samples/` directory, and they showcase full "roundtrip" usage of the library and/or tools.
83
120
@@ -101,19 +138,27 @@ To run a simple example app showcasing the jextract (Java calling Swift) approac
101
138
This will also generate the necessary sources (by invoking jextract, extracting the `Sources/ExampleSwiftLibrary`)
102
139
and generating Java sources in `src/generated/java`.
103
140
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
+
104
145
## Benchmarks
105
146
106
147
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
148
108
149
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
150
151
+
### Swift benchmarks
152
+
110
153
To run **Swift benchmarks** you can:
111
154
112
155
```bash
113
156
cd Benchmarks
114
157
swift package benchmark
115
158
```
116
159
160
+
### Java benchmarks
161
+
117
162
In order to run JMH benchmarks you can:
118
163
119
164
```bash
@@ -125,4 +170,20 @@ Please read documentation of both performance testing tools and understand that
125
170
126
171
## User Guide
127
172
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:
0 commit comments