blob: 12b0c8100bc990236f2be3ae1df814d328ce2b64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
## JAR Resources
The ability to add resources to a JAR has been added. Use the `java_resources`
keyword argument. It takes a `sturctured_src` object.
```meson
jar(
meson.project_name(),
sources,
main_class: 'com.mesonbuild.Resources',
java_resources: structured_sources(
files('resources/resource1.txt'),
{
'subdir': files('resources/subdir/resource2.txt'),
}
)
)
```
To access these resources in your Java application:
```java
try (InputStreamReader reader = new InputStreamReader(
Resources.class.getResourceAsStream("/resource1.txt"),
StandardCharsets.UTF_8)) {
// ...
}
try (InputStreamReader reader = new InputStreamReader(
Resources.class.getResourceAsStream("/subdir/resource2.txt"),
StandardCharsets.UTF_8)) {
// ...
}
```
|