Skip to content

Commit f6ca65c

Browse files
committed
JNI/JSSE: add initial Maven build support, update README.md with instructions
1 parent 5f8e2f5 commit f6ca65c

File tree

3 files changed

+180
-14
lines changed

3 files changed

+180
-14
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ rpm/spec
3434
# infer RacerD
3535
infer-out/
3636

37+
# Maven output directory
38+
target/

Diff for: README.md

+114-14
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,6 @@ the manual.
3333

3434
## Building
3535

36-
***Note 1)***
37-
The `java.sh` script uses a common location for the Java install location. If
38-
your Java install location is different, this could lead to an error when
39-
running `java.sh`. In this case, you should modify `java.sh` to match your
40-
environment.
41-
42-
Build targets for ant are :
43-
* **ant build** (only builds the jar necessary for an app to use)
44-
* **ant test** (builds the jar and tests then runs the tests, requires JUNIT setup)
45-
* **ant examples** (builds the jar and example cases)
46-
* **ant clean** (cleans all Java artifacts)
47-
* **ant cleanjni** (cleans native artifacts)
48-
4936
wolfJSSE currently supports compilation on the following platforms:
5037
- Linux/Unix
5138
- Mac OSX
@@ -56,6 +43,11 @@ wolfJSSE currently supports compilation on the following platforms:
5643
To build wolfJSSE on Windows using Visual Studio, please reference the
5744
Windows [README.md](./IDE/WIN/README.md).
5845

46+
## Building Native wolfSSL (Dependency)
47+
48+
To compile the wolfSSL JNI wrapper and JSSE provider, first the native (C)
49+
wolfSSL library must be compiled and installed.
50+
5951
To build wolfJSSE in Linux/Unix environments, first download, compile, and
6052
install wolfSSL. wolfSSL can be downloaded from the wolfSSL
6153
[download page](https://www.wolfssl.com/download/) or cloned from
@@ -69,7 +61,30 @@ $ make check
6961
$ sudo make install
7062
```
7163

72-
Then, to build wolfJSSE:
64+
If building a wolfSSL FIPS or FIPS Ready release bundle, additional
65+
configure options may be required. Reference the wolfSSL Manual and build
66+
documentation for exact build instructions.
67+
68+
## Building with ant
69+
70+
wolfSSL JNI/JSSE's ant build is the most stable and well-tested. Newer support
71+
for building with Maven has also been added. See section below for instructions
72+
on building with Maven.
73+
74+
***Note 1)***
75+
The `java.sh` script uses a common location for the Java install location. If
76+
your Java install location is different, this could lead to an error when
77+
running `java.sh`. In this case, you should modify `java.sh` to match your
78+
environment.
79+
80+
Build targets for ant are :
81+
* **ant build (ant)** (only builds the jar necessary for an app to use)
82+
* **ant test** (builds the jar and tests then runs the tests, requires JUNIT setup)
83+
* **ant examples** (builds the jar and example cases)
84+
* **ant clean** (cleans all Java artifacts)
85+
* **ant cleanjni** (cleans native artifacts)
86+
87+
To build wolfJSSE:
7388

7489
```
7590
$ cd wolfssljni
@@ -93,6 +108,91 @@ $ ./examples/provider/ServerJSSE.sh
93108
$ ./examples/provider/ClientJSSE.sh
94109
```
95110

111+
## Building with Maven
112+
113+
wolfJSSE supports building and packaging with Maven, for those projects that
114+
are already set up to use and consume Maven packages.
115+
116+
wolfJSSE's Maven build configuration is defined in the included `pom.xml`.
117+
118+
First, compile the native JNI shared library (libwolfssljni.so/dylib) same
119+
as above. This will create the native JNI shared library under the `./lib`
120+
directory:
121+
122+
```
123+
$ ./java.sh
124+
```
125+
126+
Compile the Java sources, where Maven will place the compiled `.class` files
127+
under the `./target/classes` directory:
128+
129+
```
130+
$ mvn compile
131+
```
132+
133+
Compile and run JUnit tests using:
134+
135+
```
136+
$ mvn test
137+
```
138+
139+
Package up the wolfSSL JNI/JSSE JAR file using the following command. This will
140+
run the JUnit tests then create a `.jar` file located under the `./target`
141+
directory, similar to `target/wolfssl-jsse-X.X.X-SNAPSHOT.jar`:
142+
143+
```
144+
$ mvn package
145+
```
146+
147+
To build the Javadoc API reference for wolfSSL JNI/JSSE run the following. This
148+
will generate Javadoc HTML under the `./docs/apidocs` directory:
149+
150+
```
151+
$ mvn javadoc:javadoc
152+
```
153+
154+
To install the wolfSSL JNI/JSSE JAR file, run the following. This will install
155+
the JAR into the local Maven repository:
156+
157+
```
158+
$ mvn install
159+
```
160+
161+
The local Maven repository installation location will be similar to:
162+
163+
```
164+
~/.m2/repository/com/wolfssl/wolfssl-jsse/X.X.X-SNAPSHOT/wolfssl-jsse-X.X.X-SNAPSHOT.jar
165+
```
166+
167+
The wolfSSL JNI shared library (`libwolfssljni.so/dylib`) created with the
168+
`java.sh` script will need to be "installed" by being placed on your native
169+
library search path. For example, copied into `/usr/local/lib`, `/usr/lib`,
170+
or other location. Alternatively, append the `./libs` directory to your native
171+
library search path by exporting `LD_LIBRARY_PATH` (Linux) or
172+
`DYLD_LIBRARY_PATH` (OSX):
173+
174+
```
175+
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/wolfssljni/lib
176+
```
177+
178+
After wolfSSL JNI/JSSE has been installed into the local Maven repository,
179+
an application can include this as a dependency in the application's
180+
`pom.xml` file, similar to:
181+
182+
```
183+
<project ...>
184+
...
185+
<dependencies>
186+
<dependency>
187+
<groupId>com.wolfssl</groupId>
188+
<artifactId>wolfssl-jsse</artifactId>
189+
<version>1.12.0-SNAPSHOT</version>
190+
</dependency>
191+
</dependencies>
192+
...
193+
</project>
194+
```
195+
96196
## Examples
97197

98198
Examples of using wolfssljni can be found in the `./examples` subdirectory.

Diff for: pom.xml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.wolfssl</groupId>
6+
<artifactId>wolfssl-jsse</artifactId>
7+
<version>1.12.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
<name>wolfssl-jsse</name>
10+
<url>https://www.wolfssl.com</url>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
</properties>
15+
16+
<dependencies>
17+
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
18+
<dependency>
19+
<groupId>org.hamcrest</groupId>
20+
<artifactId>hamcrest-all</artifactId>
21+
<version>1.3</version>
22+
<scope>test</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>junit</groupId>
26+
<artifactId>junit</artifactId>
27+
<version>4.13.2</version>
28+
<scope>test</scope>
29+
</dependency>
30+
</dependencies>
31+
32+
<build>
33+
<sourceDirectory>./src/java</sourceDirectory>
34+
<testSourceDirectory>./src/test</testSourceDirectory>
35+
<plugins>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-compiler-plugin</artifactId>
39+
<version>3.11.0</version>
40+
<configuration>
41+
<source>1.8</source>
42+
<target>1.8</target>
43+
</configuration>
44+
</plugin>
45+
<plugin>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-surefire-plugin</artifactId>
48+
<version>3.1.2</version>
49+
<configuration>
50+
<argLine>-Djava.library.path=./lib:/usr/lib/jni</argLine>
51+
</configuration>
52+
</plugin>
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-javadoc-plugin</artifactId>
56+
<version>3.6.0</version>
57+
<configuration>
58+
<outputDirectory>./docs</outputDirectory>
59+
<reportOutputDirectory>./docs</reportOutputDirectory>
60+
</configuration>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
</project>

0 commit comments

Comments
 (0)