Are any of you successful in loading LWGJL with maven

Started by eildosa, April 19, 2012, 15:15:44

Previous topic - Next topic

eildosa

Hi,

I tried loading this librairy with eclipse indigo, maven 3.0.4 and m2eclispe 1.0.200.20111228-1245 by adding

<dependencies>
		<dependency>
			<groupId>org.lwjgl.lwjgl</groupId>
			<artifactId>lwjgl</artifactId>
			<version>2.8.1</version>
		</dependency>
		
		<dependency>
    			<groupId>org.lwjgl.lwjgl</groupId>
    			<artifactId>lwjgl_util</artifactId>
    			<version>2.8.1</version>
		</dependency>
</dependencies>


to my POM.xml and it didn't work, no surprise, the native dll were not included.
So I added them myself but it's still buging, maven is automatically removing those path right after I inputed them D:



so obvioiusly eclipse is not happy
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
	at java.lang.Runtime.loadLibrary0(Runtime.java:823)
	at java.lang.System.loadLibrary(System.java:1028)
	at org.lwjgl.Sys$1.run(Sys.java:73)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
	at org.lwjgl.Sys.loadLibrary(Sys.java:95)
	at org.lwjgl.Sys.<clinit>(Sys.java:112)
	at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
	at runnable.Tut05.createWindow(Tut05.java:157)
	at runnable.Tut05.init(Tut05.java:177)
	at runnable.Tut05.run(Tut05.java:32)
	at runnable.Tut05.main(Tut05.java:24)


Do you know if there is any way to use maven in a way to automatically manage those native dll?
Any Idea how to not allow maven to delete my path?

thanks =D

ruben01

You can use this http://code.google.com/p/mavennatives/

It is a maven plugin that is in charge of extracting the natives from the dependency jars into some dir (by default target/natives)

and then an eclipse plugin that is in charge of setting up the java.library.path to the dir where the natives are deployed.

good luck, and ask again if you have any problems

eildosa

mmh,

I installed the plugin through help>install, rebooted

then I edited my pom.xml to this :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.github.Gtut</groupId>
  <artifactId>Gtut</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>GtutProject</name>
  <description>des tuto openGL</description>
  

  
<dependencies>
		<dependency>
			<groupId>org.lwjgl.lwjgl</groupId>
			<artifactId>lwjgl</artifactId>
			<version>2.8.1</version>
		</dependency>
		
		<dependency>
    		<groupId>org.lwjgl.lwjgl</groupId>
    		<artifactId>lwjgl_util</artifactId>
    		<version>2.8.1</version>
		</dependency>
		
</dependencies>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.googlecode.mavennatives</groupId>
				<artifactId>maven-nativedependencies-plugin</artifactId>
				<version>0.0.5</version>
				<executions>
					<execution>
						<id>unpacknatives</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<archive>
						<manifest>
							<mainClass>${main.class}</mainClass>
							<addClasspath>true</addClasspath>
							<classpathPrefix>lib/</classpathPrefix>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>2.2.1</version>
				<executions>
					<execution>
						<id>bundle-project-sources</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>src/META-INF/assembly.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>


</project>


but it's still the same, "no lwjgl in java.library.path."
Also I learned about maven existence this morning, so...

ruben01

try this please,
    first update the maven-nativedependencies-plugin to version 0.0.6 in the pom
    then left click on the eclipse project, go to the maven menu and click on "update project configuration"

if you are still having problems, in the eclipse console tab, open the maven console (it is in the right-most icon in the console tab I think) and do the "update project configuration" option again, there you should find some logs about  the natives like this:

4/19/12 3:57:58 PM GMT-03:00: [INFO] Configuring mvn natives
4/19/12 3:57:58 PM GMT-03:00: [INFO] MavenNatives - Setting nativesPath: proj1-desktop/target/natives
4/19/12 3:57:58 PM GMT-03:00: [INFO] Saving natives in /home/username/workspace/proj1/proj1-desktop/target/natives
4/19/12 3:57:58 PM GMT-03:00: [INFO] G:org.lwjgl.lwjgl - A:lwjgl-platform - C:natives-windows
4/19/12 3:57:59 PM GMT-03:00: [INFO] G:org.lwjgl.lwjgl - A:lwjgl-platform - C:natives-linux
4/19/12 3:57:59 PM GMT-03:00: [INFO] G:org.lwjgl.lwjgl - A:lwjgl-platform - C:natives-osx
4/19/12 3:57:59 PM GMT-03:00: [INFO] G:net.java.jinput - A:jinput-platform - C:natives-linux
4/19/12 3:57:59 PM GMT-03:00: [INFO] G:net.java.jinput - A:jinput-platform - C:natives-windows
4/19/12 3:57:59 PM GMT-03:00: [INFO] G:net.java.jinput - A:jinput-platform - C:natives-osx
4/19/12 3:57:59 PM GMT-03:00: [INFO] MavenNatives - Done

seanrowens

Hey,

I'm new to maven and I just followed this tutorial;

http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Maven

And I had no problem at all, although I was using Netbeans not Eclipse. 

The ONLY thing that might be considered a bit iffy was covered in Trouble Shooting, I had to manually add the native library path to the run options. 

eildosa

Quote from: seanrowens on April 20, 2012, 03:32:12
I had to manually add the native library path to the run options. 

well I don't want to do that =p I want maven to do everything alone.

Quote
try this please,
    first update the maven-nativedependencies-plugin to version 0.0.6 in the pom
    then left click on the eclipse project, go to the maven menu and click on "update project configuration"

It worked! thanks, you are a god!

One last question tho, each time you use a <plugin></plugin> in your pom.xml,
do you always need to first install a plugin inside eclipse?
(help>instal new software,  copy url, etc)

arielsan

No, there is no need. The <plugin> is a Maven tag for Maven plug-ins. The maven-nativedependencies-plugin is a Maven plug-in and it works independent from the IDE (you should be able to run it from console too). What you installed on Eclipse is an Eclipse plug-in which does stuff if you have configured the Maven plug-in in your pom.xml.  In other words, they are two separated plug-ins, one for Maven and one for Eclipse.

sliders_alpha

that's weird because I tried without the plugin installed inside eclipse and the <execution> field was underlined in red by eclipse (and thus it was not working)

ruben01

They changed the behavior in the newer versions of eclipse. They used to do nothing about maven plugins in eclipse, but the outcome of that was that the build behavior was undefined depending on each project configuration, or plugin it was unknown what would run when compiling, cleaning eclipse workspace, etc.

What they do now is force you to define the behavior exactly, you can do that by having an eclipse plugin that defines the interaction between your maven plugin and m2eclipse, have a little xml file in the maven plugin jar that defines that, or have a little xml in your own pom that does that.

If you just want to say, when running in eclipse running XXXX goal for some plugin makes no sense, you can just add the xml to the maven plugin jar (as the plugin dev) or add the xml to your project pom as the plugin user and disable that goal, or set it to run at some point in the eclipse build. If you need some extra behavior like we do in the mavennatives plugin (we run the goal, and set up the java.library.path) you need an eclipse plugin to do all that.

Here you have more information http://wiki.eclipse.org/M2E_plugin_execution_not_covered

hope the info helps :-)

eildosa

sorry for the late anwser  :-X

thanks, so basically the plugin code need to be re-written to work with the new eclipse version,
in my case it's working beacause it's doing a part and the other part is being handled by the plugin installed in eclipse.

Jens v.P.

If you want to build an Eclipse plugin using LWJGL with Maven, you may want to have a look at Tycho. Tycho can load P2 repositories, and I have added this functionality to the LWJGL Eclipse update site. Unfortunately, this code is not online yet, but I have installed an LWJGL P2 repository at my personal web site temporarily. I'm using that update site and Tycho for building Eclipse GEF3D, the GEF3D maven scripts are all available in the repository, have a look at

parent POM: http://git.eclipse.org/c/gef3d/org.eclipse.gef3d.git/tree/pom.xml

Cheers,
Jens