<!--

/*
 *  Copyright 2011 by The Cogchar Project (www.cogchar.org).
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
 
 -->
<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>
	<parent>
		<groupId>org.cogchar</groupId>
		<artifactId>org.cogchar.modules.main</artifactId>
		<version>1.0.2</version>
		<relativePath>../org.cogchar.modules.main/pom.xml</relativePath>
	</parent>	
	<artifactId>ext.bundle.opengl.jmonkey</artifactId>
	<packaging>bundle</packaging>

	<name>${project.artifactId} - OSGi Bundle</name>
	<description>OSGi bundle wrapper of the jMonkeyEngine-3 + LWJGL + Bullet + other gaming+opengl jars.</description>

<!--

See also this trivial jME3 demo client project:
			
http://subversion.assembla.com/svn/friendularity/trunk/maven/org.friendularity.demo.jme3.maven/pom.xml
		
Vecmath is an example of a dependency that could be fetched by Maven independently if we did not
use our JME3 rebundling of it below, which is generally considered undesirable.
See also eventbus, stack-alloc, and xmlpull-xpp	libraries, which could also be handled by Maven
for us.
			
For now, as long as JME3 is delivering its own snapshots of these jars, we will use those instead 
of letting Maven fetch them for us.   When jME3 reaches 3.0 - GA, we will create a slimmed bundle  
pointing to the correct versions of each 3rd party jar from the original repositories, where 
possible.

Those "release" 3rd party deps will look more like this (compare to what you see below.
		<dependency>
			<groupId>java3d</groupId>
			<artifactId>vecmath</artifactId>
			<version>1.3.1</version>
			<scope>provided</scope>			
		</dependency>

 Below ere dependencies on all the main JMonkeyEngine-3 libraries, which all have "provided" 
 scope, preventing them from being seen as as transitive dependencies by our bundle's user.  
 If our user wants these raw jars in hir project, user should just depend on them directly 
 and not on ext.bundle.opengl.jmonkey. You probably don't want to mix those jars with this
bundle.
			
The jmonkey.verson property is inherited from our parent project's pom.xml.  
		-->
	<dependencies>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-core</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-jbullet</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jbullet</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-lwjgl</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-lwjgl-natives</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>lwjgl</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>
		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-blender</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-core</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-desktop</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-plugins</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-terrain</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-jogg</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>j-ogg-oggd</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>j-ogg-vorbisd</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jinput</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>
		<!-- See note at top of dependency list about these
			dubious re-wrapped third party deps:  
			eventbus, stack-alloc, vecmath, xmlpull, noise
		-->
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>eventbus</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>stack-alloc</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>vecmath</artifactId>
			<version>${jmonkey.version}</version>
			<scope>provided</scope>	
		</dependency>		

		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>xmlpull-xpp3</artifactId>
			<version>${jmonkey.version}</version>
		</dependency>	
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>noise</artifactId>
			<version>${jmonkey.version}</version>
		</dependency>	
		

		<dependency>
			<groupId>org.osgi</groupId>
			<artifactId>org.osgi.core</artifactId>
			<version>4.2.0</version>
		</dependency>
		
		<!-- The jmonkeyengine3 contains just the jme3test demo classes,
			and so is not part of our bundle exports.	 
			
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jmonkeyengine3</artifactId>
			<version>3.0.0-SNAPSHOT</version>
			<scope>test</scope>
		</dependency>
		--> 	
		
		<!-- Large set of test data used for JME3 demos 
			Disabled as a dependency due to size.
		<dependency>
			<groupId>com.jme3</groupId>
			<artifactId>jME3-testdata</artifactId>
			<version>3.0.0-SNAPSHOT</version>
			<scope>test</scope>
		</dependency>
		-->		
	
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>2.2.0</version>
				<extensions>true</extensions>
				<configuration>
					<instructions>
						<Bundle-Activator>org.cogchar.ext.bundle.opengl.jmonkey.OpenglJmonkeyBundleActivator</Bundle-Activator>
						<!-- Explicit import of sun.misc is necessary for running under netigso (Netbeans-OSGI) -->
						<Import-Package>sun.misc, *;resolution:=optional</Import-Package>
						<Export-Package>com.jme3.*, jme3tools.*, org.lwjgl.*, com.bulletphysics.*, javax.vecmath.*, de.jarnbjo.*, Common.*, Interface.*</Export-Package>
					</instructions>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
			<id>build-for-felix</id>
			<dependencies>
				<dependency>
					<groupId>org.apache.felix</groupId>
					<artifactId>org.apache.felix.main</artifactId>
					<version>3.0.7</version>
					<scope>provided</scope>
				</dependency>
                <!-- To include a shell:
                <dependency>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>org.apache.felix.gogo.shell</artifactId>
                    <version>0.6.1</version>
                </dependency>
                -->
			</dependencies>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.6</version>
						<executions>
							<execution>
								<id>compile</id>
								<phase>package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<pathconvert property="plugins.jars" pathsep="${path.separator}">
											<path refid="maven.runtime.classpath" />
											<map from="${project.build.directory}${file.separator}classes" to="" />
										</pathconvert>
										<pathconvert pathsep=" " property="bundles">
											<path path="${plugins.jars}" />
											<mapper>
												<chainedmapper>
													<flattenmapper />
													<globmapper from="*" to="file:modules/*" casesensitive="no" />
												</chainedmapper>
											</mapper>
										</pathconvert>
										<propertyfile file="${project.build.directory}/config.properties">
											<entry key="felix.auto.start" value="${bundles} file:modules/${project.build.finalName}.jar" />
											<entry key="org.osgi.framework.bootdelegation" value="*" />
										</propertyfile>
										<copy file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}" tofile="${project.build.directory}/felix.jar" />
									</target>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-assembly-plugin</artifactId>
						<version>2.2</version>
						<executions>
							<execution>
								<id>create-executable-jar</id>
								<phase>package</phase>
								<goals>
									<goal>single</goal>
								</goals>
								<configuration>
									<descriptors>
										<descriptor>${basedir}/src/main/assembly/felix.xml</descriptor>
									</descriptors>
									<finalName>${project.build.finalName}</finalName>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>run-on-felix</id>
			<dependencies>
				<dependency>
					<groupId>org.apache.felix</groupId>
					<artifactId>org.apache.felix.main</artifactId>
					<version>3.0.7</version>
					<scope>provided</scope>
				</dependency>
                <!-- org.apache.felix:org.apache.felix.gogo.shell:0.6.1 useless from Maven since stdin is swallowed -->
			</dependencies>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.6</version>
						<configuration>
							<target>
								<property name="vm.args" value="" />
								<pathconvert property="plugins.jars" pathsep="${path.separator}">
									<path refid="maven.runtime.classpath" />
									<map from="${project.build.directory}${file.separator}classes" to="" />
								</pathconvert>
								<makeurl property="urls" separator=" ">
									<path path="${plugins.jars}" />
									<path location="${project.build.directory}/${project.build.finalName}.jar" />
								</makeurl>
								<propertyfile file="${project.build.directory}/run.properties">
									<entry key="felix.auto.start" value="${urls}" />
									<entry key="felix.auto.deploy.action" value="uninstall,install,update,start" />
									<entry key="org.osgi.framework.storage" value="${project.build.directory}${file.separator}felix-cache" />
									<entry key="org.osgi.framework.bootdelegation" value="*" />
								</propertyfile>
								<makeurl property="run.properties.url" file="${project.build.directory}/run.properties" />
								<java fork="true" jar="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}">
									<sysproperty key="felix.config.properties" value="${run.properties.url}" />
									<jvmarg line="${vm.args}" />
								</java>
							</target>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
