Maven: Difference between revisions

From JogampWiki
Jump to navigation Jump to search
(Document *-main packages)
Line 48: Line 48:
An example project is available in the <tt>maven</tt> subdirectory of the <tt>jogl-demos</tt> project
An example project is available in the <tt>maven</tt> subdirectory of the <tt>jogl-demos</tt> project
[http://jogamp.org/git/?p=jogl-demos.git;a=tree;f=maven].
[http://jogamp.org/git/?p=jogl-demos.git;a=tree;f=maven].
=== Package details ===
For each JogAmp project, there are essentially two packages published: One contains the main compiled
jar files and any associated native library jar files, and the other simply contains <i>dependencies</i>
on those files. Using <tt>jogl-all</tt> and <tt>jogl-all-main</tt> as the example, the <tt>jogl-all</tt>
package in the jogamp.org test repository:
http://jogamp.org/deployment/maven/org/jogamp/jogl/jogl-all/2.0.2-rc12/
Note that there are many native jar files attached to the main package. However, if you were to use
the following dependency in your own project:
<code>
<dependency>
  <groupId>org.jogamp.jogl</groupId>
  <artifactId>jogl-all</artifactId>
  <version>2.0.2-rc12</version>
</dependency>
</code>
Maven would download <tt>jogl-all-2.0.2-rc12.jar</tt> but would completely ignore all of the other
native jar files. Why? The reason for this is that the native jar files are uploaded as extra artifacts
to the <tt>jogl-all</tt> package and are, in a manner of speaking, not really considered to be part of
the project where dependencies are concerned. The POM for the <tt>jogl-all-main</tt> package adds
explicit dependencies on all of the extra artifacts in the <tt>jogl-all</tt> package:
http://jogamp.org/deployment/maven/org/jogamp/jogl/jogl-all-main/2.0.2-rc12/jogl-all-main-2.0.2-rc12.pom
So, when you add a dependency on <tt>jogl-all-main</tt> in your own project, the native jar files of
<tt>jogl-all</tt> are brought in as transitive dependencies and everything works as expected.


=== The jogamp.org test repository (optional) ===
=== The jogamp.org test repository (optional) ===

Revision as of 13:35, 11 July 2013

JogAmp now contains support for Maven. As of 2.0-rc11, packages are pushed to Maven Central.

Add dependencies on the correct packages

If you don't know which packages you want, you almost certainly want to use the jogl-all-main and gluegen-rt-main packages, as these automatically set up the correct dependencies on the native jar files for all platforms.

As an example, if your project uses JOGL 2.0.2-rc12:

 <dependencies>
   <dependency>
     <groupId>org.jogamp.gluegen</groupId>
     <artifactId>gluegen-rt-main</artifactId>
     <version>2.0.2-rc12</version>
   </dependency>
   <dependency>
     <groupId>org.jogamp.jogl</groupId>
     <artifactId>jogl-all-main</artifactId>
     <version>2.0.2-rc12</version>
   </dependency>
 </dependencies>

Maven will pull all of the dependencies the next time you attempt to build the project.

Additionally, for joal and jocl support:

 <dependencies>
   <dependency>
     <groupId>org.jogamp.jocl</groupId>
     <artifactId>jocl-main</artifactId>
     <version>2.0.2-rc12</version>
   </dependency>
   <dependency>
     <groupId>org.jogamp.joal</groupId>
     <artifactId>joal-main</artifactId>
     <version>2.0.2-rc12</version>
   </dependency>
 </dependencies>

An example project is available in the maven subdirectory of the jogl-demos project [1].

Package details

For each JogAmp project, there are essentially two packages published: One contains the main compiled jar files and any associated native library jar files, and the other simply contains dependencies on those files. Using jogl-all and jogl-all-main as the example, the jogl-all package in the jogamp.org test repository:

http://jogamp.org/deployment/maven/org/jogamp/jogl/jogl-all/2.0.2-rc12/

Note that there are many native jar files attached to the main package. However, if you were to use the following dependency in your own project:

<dependency>

 <groupId>org.jogamp.jogl</groupId>
 <artifactId>jogl-all</artifactId>
 <version>2.0.2-rc12</version>

</dependency>

Maven would download jogl-all-2.0.2-rc12.jar but would completely ignore all of the other native jar files. Why? The reason for this is that the native jar files are uploaded as extra artifacts to the jogl-all package and are, in a manner of speaking, not really considered to be part of the project where dependencies are concerned. The POM for the jogl-all-main package adds explicit dependencies on all of the extra artifacts in the jogl-all package:

http://jogamp.org/deployment/maven/org/jogamp/jogl/jogl-all-main/2.0.2-rc12/jogl-all-main-2.0.2-rc12.pom

So, when you add a dependency on jogl-all-main in your own project, the native jar files of jogl-all are brought in as transitive dependencies and everything works as expected.

The jogamp.org test repository (optional)

Bleeding edge, experimental packages will continue to be made available from the Jogamp Test Repository. Most users won't need this, but it can be used by adding a new profile in your ~/.m2/settings.xml file that specifies the repository:

 <?xml version="1.0" encoding="UTF-8"?>
 <settings
   xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
   <profiles>
     <profile>
       <id>jogamp</id>
       <repositories>
         <repository>
           <id>jogamp-remote</id>
           <name>jogamp test mirror</name>
           <url>http://www.jogamp.org/deployment/maven/</url>
           <layout>default</layout>
         </repository>
       </repositories>
     </profile>
   </profiles>
   <activeProfiles>
     <activeProfile>jogamp</activeProfile>
   </activeProfiles>
 </settings>

Maven will then check this repository for packages in addition to Maven Central when resolving dependencies.

Please note that packages on the jogamp test repository are subject to unannounced changes at any moment and may break existing code at any time! Do not use for production code!