Ticket #272 (closed task: fixed)

Opened 9 years ago

Last modified 8 years ago

JOCL as Maven Dependency

Reported by: rlentz Owned by: rlentz
Priority: minor Milestone: biweekly-2010: Nov-29 to Dec-10
Component: Other Version:
Severity: serious Keywords:
Cc: Blocked By:
Blocking:

Description (last modified by rlentz) (diff)

Several libraries are used in ImageJ that rely on additional native libs. JOCL is an example of a software connector that allows use of OpenCL from within Java. This work will allow other native libs to become maven dependencies.

Attachments

pom.xml Download (16.9 KB) - added by rlentz 9 years ago.

Change History

comment:1 Changed 9 years ago by rlentz

  • Description modified (diff)

comment:2 Changed 9 years ago by rlentz

  • Status changed from new to accepted

A quick Google search revealed the following earlier work:

On 06/01/2010 02:36 PM, Kraft [via jogamp] wrote:
Hi !

Maybe this will help other user of jogl to use current JARs into their maven projects.
After some days trying many solutions, here is what i found :

My goal :
My goal was to make use of

  • gluegen-rt.jar
  • gluegen-rt-natives-linux-i586.jar
  • jogl.all.jar
  • jogl.all-natives-linux-i586.jar
  • nativewindow.all.jar
  • nativewindow-natives-linux-i586.jar

in Ubuntu+Eclipse+Maven+Nexus.

I wanted to configure all stuff about dependencies to jogl into the pom.xml of my project.
Then other members of my dev team just have to checkout the project (including the pom.xml) from the svn repository to have a complete configured project.

My solution :

  • in Nexus, i uploaded the artifact listed above in the 3rd party repository.

I set the groupid to "jogamp" and the articatid to the name of the jar (without .jar)

  • In Eclipse, in the pom.xml of the project,

i declared the repository like this (you can utilize my nexus repository if you want but at your own risks )

<repository>

<id>blackpad-nexus</id>
<name>Blackpad Nexus</name>
<layout>default</layout>
<url> http://www.blackpad.fr/nexus/content/groups/public</url>
<snapshots>

<enabled>true</enabled>

</snapshots>

</repository>


I declared the dependencies to jogl like this :

<dependency>

<groupId>jogamp</groupId>
<artifactId>gluegen-rt</artifactId>
<version>0.0.1</version>

</dependency>
<dependency>

<groupId>jogamp</groupId>
<artifactId>gluegen-rt-natives-linux-i586</artifactId>
<version>0.0.1</version>

</dependency>
<dependency>

<groupId>jogamp</groupId>
<artifactId>nativewindow.all</artifactId>
<version>0.0.1</version>

</dependency>
<dependency>

<groupId>jogamp</groupId>
<artifactId>nativewindow-natives-linux-i586</artifactId>
<version>0.0.1</version>

</dependency>
<dependency>

<groupId>jogamp</groupId>
<artifactId>jogl.all</artifactId>
<version>0.0.1</version>

</dependency>
<dependency>

<groupId>jogamp</groupId>
<artifactId>jogl-natives-linux-i586</artifactId>
<version>0.0.1</version>

</dependency>


Then 2 steps to make maven add the .so (for linux but you can adapt to windows or macos) into the java.library.path.

  • First, i configured the maven-dependency-plugin to unpack the natives jars into /target/lib after downloading them

<build>

<plugins>


<plugin>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>

<execution>

<id>unpack</id>
<phase>compile</phase>
<goals>

<goal>unpack</goal>

</goals>
<configuration>

<artifactItems>

<artifactItem>

<groupId>jogamp</groupId>
<artifactId>gluegen-rt-natives-linux-i586</artifactId>
<version>0.0.1</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>

</artifactItem>
<artifactItem>

<groupId>jogamp</groupId>
<artifactId>jogl-natives-linux-i586</artifactId>
<version>0.0.1</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>

</artifactItem>
<artifactItem>

<groupId>jogamp</groupId>
<artifactId>nativewindow-natives-linux-i586</artifactId>
<version>0.0.1</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>

</artifactItem>

</artifactItems>

</configuration>

</execution>

</executions>

</plugin>


</plugins>

</build>


  • Second, to let java found the natives libs, when i run the project using the "Run As" menu, i made a new Run Configuration and added -Djava.library.path=/target/lib as argument.

That's it !

With some adjustments , this solution let you use jogl in a maven project on any platform.
Hope i'm understandable, anyway i'm open to questions :)

posted at:
 http://jogamp.762907.n3.nabble.com/What-about-Maven-td844816.html

This is a great start... and with the additional platform jars at:
 http://jogamp.org/deployment/jogamp-next/

Additionally, our repository information was added to the pom.xml

<repositories>
<!-- NB: for loci-base-pom -->
<repository>

<id>loci.releases</id>
<url> http://dev.loci.wisc.edu:8081/content/repositories/releases</url>

</repository>

</repositories>

These maven dependencies will need to be added to the Java version.

 http://jogamp.org/deployment/jogamp-next/

comment:3 Changed 9 years ago by rlentz

add deps to  http://dev.loci.wisc.edu:8081/index.html#view-repositories;thirdparty
for nativewindow, jogl, jocl, and gluegen for win64,win32,osx,linux32,linux64

comment:4 Changed 9 years ago by rlentz

Several NAR application examples can be found at:
 https://github.com/duns/maven-nar-plugin/tree/master/src/it

It turned out that the the maven-nar plugin was not needed for this example. Others can extend on the attached pom.xml file to ease use of JOGAMP gluegen-rt, jocl, jogl, and nativewindow dependencies.

Changed 9 years ago by rlentz

comment:6 Changed 8 years ago by rlentz

  • Status changed from accepted to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.