
<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/maven-v4_0_0.xsd">

	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.cogchar</groupId>
		<artifactId>org.cogchar.modules.main</artifactId>
		<version>1.0.0</version>
		<relativePath>../org.cogchar.modules.main/pom.xml</relativePath>
	</parent>	
	
	<artifactId>org.cogchar.bundle.render.opengl</artifactId>
	<packaging>bundle</packaging>
	<name>${project.artifactId} Bundle</name>

	<dependencies>
	
		<dependency>
			 <!-- This bundle repackages this lib, so it is depended with scope provided, and exported below -->			
			<groupId>${project.groupId}</groupId>
			<artifactId>org.cogchar.lib.render</artifactId>
			<version>${project.version}</version>
			<scope>provided</scope>
		</dependency>		
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>org.cogchar.bundle.core</artifactId>
			<version>${project.version}</version>
		</dependency>		
		<dependency>
			<artifactId>ext.bundle.opengl.jmonkey</artifactId>
			<groupId>org.cogchar</groupId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<!--	This dep on resources is currently used to pull in the marker class token for the resources,
					which happens to be their BundleActivator.
			-->
			<groupId>${project.groupId}</groupId>
			<artifactId>org.cogchar.bundle.render.resources</artifactId>
			<version>${project.version}</version>
		</dependency>

	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>2.0.1</version>
				<extensions>true</extensions>
				<configuration>
					<instructions>
						<Bundle-Activator>org.cogchar.render.opengl.osgi.RenderBundleActivator</Bundle-Activator>
						<Import-Package>*;resolution:=optional</Import-Package>

						<Export-Package>org.cogchar.render.opengl.*</Export-Package>
						<!-- <Embed-Dependency>!org.osgi.*;scope=compile|runtime</Embed-Dependency> -->
						<!--
                        <Include-Resource>
                            {maven-resources},
                            native=src/main/resources/native
                        </Include-Resource>
                        <Bundle-NativeCode>
                            native/linux/32/liblwjgl.so;
                            osname=linux;
                            processor=x86,
                            native/linux/64/liblwjgl64.so;
                            osname=linux;
                            processor=x86-64,
                            native/windows/32/lwjgl.dll;
                            osname=win32;
                            processor=x86,
                            native/windows/64/lwjgl64.dll;
                            osname=win32;
                            processor=x86-64,
                            native/macosx/liblwjgl.jnilib;
                            osname=mac os x;
                            processor=x86;
                            processor=ppc
                        </Bundle-NativeCode>
						-->
					</instructions>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.0.2</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
					<encoding>${project.build.sourceEncoding}</encoding>
				</configuration>
			</plugin>
			<!-- Stu added plugin for Jmonkey3 download 
				http://jmonkeyengine.org/wiki/doku.php/jme3_maven
			-->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.6</version>
				<executions>
					<execution>
						<id>download_install_jme3</id>
						<!--    Download on "clean" target is disabled, for now, which means no auto-download
								at all.
						<phase>clean</phase>
				-->
						<phase>FETCH_JME</phase>
						
						<configuration>
							<target>
								<ant antfile="${basedir}/ant_fetch_jme3.xml">
									<target name="download_nightly_build" />
								</ant>
							</target>
						</configuration>
						<goals>			
							
							<goal>run</goal>
							
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.4.3</version>
				<configuration>
					<encoding>${project.build.sourceEncoding}</encoding>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
            <!-- this profile executes the bundle on apache felix-->
			<id>run-on-felix</id>
			<dependencies>
				<dependency>
					<groupId>org.apache.felix</groupId>
					<artifactId>org.apache.felix.main</artifactId>
					<version>2.0.2</version>
					<scope>provided</scope>
				</dependency>
				<dependency>
					<groupId>org.apache.felix.gogo</groupId>
					<artifactId>org.apache.felix.gogo.commands</artifactId>
					<version>0.2.2</version>
				</dependency>
			</dependencies>

			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.3</version>
						<executions>
							<execution>
								<id>compile</id>
								<phase>compile</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<property name="plugins" refid="maven.runtime.classpath" />
										<pathconvert pathsep=" " dirsep="/" property="project.build.url">
											<path path="${project.build.directory}" />
										</pathconvert>
										<pathconvert property="plugins.jars" pathsep=":">
											<path path="${plugins}" />
											<map from="${project.build.directory}/classes" to="" />
										</pathconvert>
										<makeurl property="urls" separator=" " validate="false">
											<path path="${plugins.jars}" />
										</makeurl>
										<pathconvert pathsep=" " property="bundles">
											<path path="${plugins}" />
											<mapper>
												<chainedmapper>
													<flattenmapper />
													<globmapper from="*" to="file:modules/*" casesensitive="no" />
												</chainedmapper>
											</mapper>
										</pathconvert>
										<makeurl property="main.bundle.url" file="${project.build.directory}/${project.artifactId}-${project.version}.jar" />
										<echo file="${project.build.directory}/run.properties">
                                            felix.auto.install=${urls}
                                            felix.auto.start=${main.bundle.url}
                                            org.osgi.framework.storage=${project.build.url}/felix-cache
                                            org.osgi.framework.bootdelegation=*
										</echo>
										<replace file="${project.build.directory}/run.properties" token="\" value="\\" />
										<echo file="${project.build.directory}/config.properties">
                                            felix.auto.install="${bundles}"
                                            felix.auto.start=file:modules/${project.artifactId}-${project.version}.jar
										</echo>
										<copy file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}" tofile="${project.build.directory}/felix.jar" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-assembly-plugin</artifactId>
						<version>2.2-beta-5</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.artifactId}-${project.version}</finalName>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
<!--
/*
 *  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.
 */
 -->