-
Notifications
You must be signed in to change notification settings - Fork 109
Maven
Olivier Chafik edited this page Nov 10, 2022
·
6 revisions
JNAerator is fully Maven-ized, which means that the following are possible:
- Run the JNAerator plugin in a Maven project on a set of headers to create Java bindings
- Add a dependency to JNAerator runtime classes (which include JNA + Rococoa) in a Maven project
- Build JNAerator with Maven
- Generate a Maven-ready project with
-mode Maven
or-mode AutoGeneratedMaven
(see options)
TODO future developments might include Maven archetypes to bootstrap standard native library wrappings projects
<project>
...
<repositories>
<repository>
<id>sonatype</id>
<name>Sonatype OSS Snapshots Repository</name>
<url>https://oss.sonatype.org/content/groups/public</url>
</repository>
<!-- For old snapshots, please use groupId `com.jnaerator` and the following repo -->
<repository>
<id>nativelibs4java-repo</id>
<url>https://nativelibs4java.sourceforge.net/maven</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>sonatype</id>
<name>Sonatype OSS Snapshots Repository</name>
<url>https://oss.sonatype.org/content/groups/public</url>
</pluginRepository>
<!-- For old snapshots, please use groupId `com.jnaerator` and the following repo -->
<pluginRepository>
<id>nativelibs4java-repo</id>
<url>https://nativelibs4java.sourceforge.net/maven</url>
</pluginRepository>
</pluginRepositories> ...
</project>
JNAerator runtime classes, needed to support JNAerated sources:
<project>
...
<dependencies>
<dependency>
<groupId>com.nativelibs4java</groupId>
<artifactId>jnaerator-runtime</artifactId>
<version>0.12-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
...
</project>
Put command line arguments in file src/main/jnaerator/config.jnaerator
.
Add the following lines to your pom.xml:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>com.nativelibs4java</groupId>
<artifactId>jnaerator-maven-plugin</artifactId>
<version>0.12-SNAPSHOT</version>
</plugin>
...
</plugins>
</build>
...
</project>
Run JNAerator through Maven with the following command:
mvn com.nativelibs4java:jnaerator-maven-plugin:generate
That will create Java & Scala files in target/generated-sources
For BridJ bindings, put your native libraries in src/main/resources/lib/xyz
where xyz is win32
, win64
, linux_x86
, linux_x64
, etc...
(please read BridJ's wiki for more information)