
<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.friendularity</groupId>
		<artifactId>org.friendularity.modules.main</artifactId>
		<version>1.0.2</version>
		<relativePath>../org.friendularity.modules.main/pom.xml</relativePath>
	</parent>		

	<artifactId>org.friendularity.bundle.demo.ccmio</artifactId>
	<packaging>bundle</packaging>

	<name>${project.artifactId} - OSGi</name>	

	<dependencies>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>org.friendularity.bundle.headless.messaging</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>org.cogchar</groupId>
			<artifactId>org.cogchar.bundle.app.puma</artifactId>
			<version>${cogchar.version}</version>
		</dependency>
		<!-- o.a.b.gui allows us to use DemoBrowser object inspector -->
		<dependency>
			<groupId>org.appdapter</groupId>
			<artifactId>org.appdapter.bundle.gui</artifactId>
			<version>${appdapter.version}</version>
		</dependency>		
		<dependency>
			<groupId>org.cogchar</groupId>
			<artifactId>org.cogchar.bundle.app.vworld.startup</artifactId>
			<version>${cogchar.version}</version>
		</dependency>
		<dependency>
			<groupId>org.cogchar</groupId>
			<artifactId>org.cogchar.bundle.render.resources</artifactId>
			<version>${cogchar.version}</version>
			<scope>runtime</scope>
		</dependency>

		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>org.friendularity.bundle.headless.speech</artifactId>
			<version>${project.version}</version>
		</dependency>
			
		
		<dependency>
			<groupId>org.rwshop</groupId>
			<artifactId>org.rwshop.swing.common</artifactId>
			<version>${rwshop.version}</version>
		</dependency>		
		
		
		<dependency>
			<groupId>org.mechio</groupId>
			<artifactId>org.mechio.api.vision</artifactId>
			<version>${mechio.version}</version>
		</dependency>
		<dependency>
			<groupId>org.mechio</groupId>
			<artifactId>org.mechio.impl.vision</artifactId>
			<version>${mechio.version}</version>
		</dependency>

		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>org.friendularity.bundle.jvision</artifactId>
			<version>${project.version}</version>
		</dependency>	

		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>org.friendularity.lib.viz</artifactId>
			<version>${project.version}</version>
		</dependency>				

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>2.3.7</version>
				<extensions>true</extensions>
				<configuration>
					<instructions>
						<Bundle-Activator>org.friendularity.bundle.demo.ccmio.CCMIO_DemoActivator</Bundle-Activator>
						<!-- Cannot just export org.friendularity.*, because that will create copies of
								classes from other bundles that we depend on, e.g. JVision.
								
								On the other hand, a default (implicit) export instruction does not include classes from 
								libraries, like o.f.lib.viz, which we *do* want to include(/export).
								
								Don't know of a tidier way than explicitly exporting all the packages we do want.
								(Including "*" exports the whole universe of visible classes - exciting but horrible!)
						-->
						<Export-Package>org.friendularity.api.*, 
										org.friendularity.impl.visual,
										org.friendularity.vworld,
										org.friendularity.respire,
										org.friendularity.struct,
										org.friendularity.bundle.demo.ccmio
						</Export-Package>
					</instructions>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.scala-tools</groupId>
				<artifactId>maven-scala-plugin</artifactId>
				<version>2.15.2</version>
				<executions>
					<execution>
						<goals>
							<goal>compile</goal>
							<!-- We're not actually using any scala tests right now
							<goal>testCompile</goal>
							-->
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
			<id>build-for-felix</id>
			<dependencies>
				<dependency>
					<groupId>org.apache.felix</groupId>
					<artifactId>org.apache.felix.main</artifactId>
					<version>4.2.1</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>4.2.1</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>
								<!-- Friendularity custom :  Note the log4j.debug flag
Some other options we aint presently using:													
-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:CMSInitiatingOccupancyFraction=60 -XX:CMSIncrementalSafetyFactor=30
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
-XX:+PrintGCDetails -XX:+PrintTenuringDistribution -XX:+PrintGCTimeStamps										
								-->
								<property name="vm.args" value="-Dlog4j.debug -XX:MaxHeapSize=512M -XX:MaxPermSize=384M -XX:+TieredCompilation -XX:+UseConcMarkSweepGC" />
								<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="*" />
									<!-- Friendularity customizations : 
										1) Allow sun.misc package to be used by LWJGL.
										2) org.w3c.dom.* are wanteed by Jena, Xerces, (+?), and are missing from 
											default.properties in felix 4.2.1, tho	they are present in 3.0.7 -->
									<entry key="org.osgi.framework.system.packages.extra" value="sun.misc, org.w3c.dom.css, org.w3c.dom.html, org.w3c.dom.stylesheets, org.w3c.dom.traversal, org.w3c.dom.ranges,                                                     org.w3c.dom.views,                                                     org.w3c.dom.xpath" />

								</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>
