My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Maven  
Maven repository and usage instructions
Featured
Updated Feb 23, 2012 by olivier.chafik@gmail.com

Introduction

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

JNAerator's Maven-generated sites are available here.

TODO future developments might include Maven archetypes to bootstrap standard native library wrappings projects

Repository

<project>
	...
	<repositories>
		<repository>
			<id>sonatype</id>
			<name>Sonatype OSS Snapshots Repository</name>
			<url>http://oss.sonatype.org/content/groups/public</url>
		</repository>
		<repository>
			<id>nativelibs4java-repo</id>
			<url>http://nativelibs4java.sourceforge.net/maven</url>
		</repository>
	</repositories>
	<pluginRepositories>
		<pluginRepository>
			<id>sonatype</id>
			<name>Sonatype OSS Snapshots Repository</name>
			<url>http://oss.sonatype.org/content/groups/public</url>
		</pluginRepository>
		<pluginRepository>
			<id>nativelibs4java-repo</id>
			<url>http://nativelibs4java.sourceforge.net/maven</url>
		</pluginRepository>
	</pluginRepositories>
	...
</project>

Usage

JNAerator runtime classes

Needed to support JNAerated sources :

<project>
	...
	<dependencies>
	   <dependency>
		<groupId>com.nativelibs4java</groupId>
		 <artifactId>jnaerator-runtime</artifactId>
		 <version>0.9.10-SNAPSHOT</version>
		<scope>compile</scope>
	   </dependency>
	</dependencies>
	...
</project>

Maven JNAerator Plugin

  1. Put command line arguments in file src/main/jnaerator/config.jnaerator
  2. Add the following lines to your pom.xml :
  3. <project>
    	...
    	<build>
    		<plugins>
    			...
    			<plugin>
    				<groupId>com.nativelibs4java</groupId>
    				<artifactId>maven-jnaerator-plugin</artifactId>
    				<version>0.9.10-SNAPSHOT</version>
    			</plugin>
    			...
    		</plugins>
    	</build>
    	...
    </project>
  4. Run JNAerator through Maven with the following command :
  5. mvn com.jnaerator:maven-jnaerator-plugin:jnaerate
This will create Java & Scala files in target/generated-sources
Comment by brice.c...@gmail.com, Jul 30, 2010

Above version 0.9.2 of the plugin, I cannot get it to work with Maven 2.

In version 0.9.2, I cannot seem to use the -runtime command line argument (the plugin complains that "file -runtime does not exist"). I suspect the argument only works in versions about 0.9.2, but I cannot download any dependencies for 0.9.3 or 0.9.4. I tried switching the maven repository to Sourceforge, as I noticed the later versions of the plugin are there, but to no avail.

for 0.9.4, it complains that it cannot resolve version "org.rococoa:rococoa-core:jar:${parent.version}" for 0.9.3, it complains about "com.jnaerator:jna-jnaerator:jar:${jna.version}"

Comment by guillegu...@gmail.com, Oct 11, 2010

Good work, keep it up. Just two issues to get it working:

- plugins tag should end with </plugins> instead of </plugin>
- The only release version in the maven repository is 0.9.4, so 0.9.1 won't work.

Regards!

Comment by project member olivier.chafik@gmail.com, Oct 11, 2010

@guilleguti84 Thanks, fixed !

@brice.copy Sorry I missed your comment... repository issues for 0.9.4 should now be fixed, but I'd advise using 0.9.5-SNAPSHOT to get *many* fixes.

Cheers

Comment by neme...@gmail.com, Jan 11, 2011

In case you want to automatically generate the sources as part of the build, bind jnaerator plugin to generate-sources lifecycle:

        <plugin>
          <groupId>com.jnaerator</groupId>
          <artifactId>maven-jnaerator-plugin</artifactId>
          <version>0.9.3</version>
          <executions>
            <execution>
              <phase>generate-sources</phase>
              <goals><goal>jnaerate</goal></goals>
            </execution>
          </executions>
        </plugin>
Comment by neme...@gmail.com, Jan 11, 2011

And, in order to have those generated files compiled as part of the build and included in the final JAR, add the source directory to the list of source directories that Maven is aware of with help from build-helper-maven-plugin:

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.5</version>
          <executions>
            <execution>
              <phase>generate-sources</phase>
              <goals><goal>add-source</goal></goals>
              <configuration>
                <sources><source>target/generated-sources/java</source></sources>
              </configuration>
            </execution>
          </executions>
        </plugin>
Comment by tserings...@gmail.com, Oct 27, 2011

Hi, I am using maven-jnaerator-plugin version 0.9.8 and it tries to download this:

Downloading: http://www.blackpad.fr/nexus/content/groups/public/com/jnaerator/jnaerator-parent/0.9.9-SNAPSHOT/maven-metadata.xml

Why is this happening? Why is it not using all 0.9.8 version jars and poms?

Comment by ynonc...@gmail.com, Nov 7, 2011

Continuing the above comment, I keep getting timeouts from the blackpad server:

Downloading: http://www.blackpad.fr/nexus/content/groups/public/com/jnaerator/jnaerator-parent/0.9.9-SNAPSHOT/maven-metadata.xml WARNING? Could not transfer metadata com.jnaerator:jnaerator-parent:0.9.9-SNAPSHOT/maven-metadata.xml from blackpad-nexus (http://www.blackpad.fr/nexus/content/groups/public): Error transferring file: Connection timed out

Downloading: http://www.blackpad.fr/nexus/content/groups/public/com/nativelibs4java/nativelibs4java-parent/1.6-SNAPSHOT/maven-metadata.xml

This takes about 2-3 annoying minutes. It does not stop the Maven build and does not seem to have any additional effect.

Is it possible to remove this download?

Thanks, Ynon

Comment by tserings...@gmail.com, Nov 18, 2011

0.9.9 version avoids SNAPSHOT dependecies

Comment by flf....@gmail.com, Feb 15, 2012

Dear JNAerator team, at first thanks for this project. I would like to use it but I have a question. I want to use the maven implemntation where do I have to put my c header files? it would be very helpfull if you could provide in fully maven example.

Thanks a lot.

Comment by finsondr...@gmail.com, Feb 22, 2012

The name of the goal is 'generate', not 'jnaerate'. From JNAeratorMojo.java:

/**
 * Launch JNAerator to wrap native libraries in Java for use with JNA.
 * @goal generate
 * @phase generate-sources
 * @description Launches JNAerator with the command-line arguments contained in src/main/jnaerator/config.jnaerator. To launch from command line, use "mvn jnaerator:generate"
 */

Sign in to add a comment
Powered by Google Project Hosting