
<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.appdapter</groupId>
		<artifactId>org.appdapter.modules.math</artifactId>
		<version>1.0.4</version>
		<relativePath>../org.appdapter.modules.math/pom.xml</relativePath>
	</parent>
	<artifactId>ext.bundle.math.jscience_50SNAP</artifactId>
	<packaging>bundle</packaging>
	<name>ext.bundle.math.jscience_50SNAP - OSGi - Jscience wrapper</name>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		
		<jscience.groupId>org.jscience</jscience.groupId>
		<jscience.math.artifactId>jscience-mathematics</jscience.math.artifactId>
		<jscience.version>5.0-SNAPSHOT</jscience.version>
	</properties>
	<repositories>
		<!-- 		
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net Repository for Maven</name>
            <url>http://download.java.net/maven/2/</url>
        </repository>		

		May be used again for JScience, but Javolution is now in Sonatype
		<repository>
		
			<id>maven.java.net-SNAP</id>
			<name>maven.java.net SNAPSHOTS Repo</name>
			<url>https://maven.java.net/content/repositories/snapshots/</url>
		</repository>
	-->
	</repositories>	
	<dependencies>
		<dependency>
			<groupId>org.apache.felix</groupId>
			<artifactId>org.osgi.core</artifactId>
			<version>1.4.0</version>
		</dependency>
		<!-- JScience snapshots have disappeared, so using uploaded libs and
			a direct dep on javolution. It is an OSGi bundle, but cannot
			be cleanly shared via maven 
			not need re-wrapping.
		
		<dependency>
			<groupId>org.jscience</groupId>
			<artifactId>jscience</artifactId>
			<version>5.0-SNAPSHOT</version>
			<type>pom</type>
			<scope>provided</scope>
		</dependency>
		-->
		<!-- This dep is installed to local repo during initialize phase below. 
			Must disable the dep, run mvn initialize, then re-enable the deb
			-->
			
		<dependency>
			<groupId>org.jscience</groupId>
			<artifactId>jscience-mathematics</artifactId>
			<version>5.0-SNAPSHOT</version>
			<scope>provided</scope>
		</dependency>
		
		<dependency>
			<groupId>javolution</groupId>
			<artifactId>javolution</artifactId>
		  <!-- We tearfully have to re-export javolution, even though it's  supplied to us as a "bundle", 
				because the embedded poms are entangled with the broken java.net repository, and 
				it is all just too screwed up.
			-->
			<type>jar</type>
			<version>5.5.1</version>
			<scope>provided</scope>
		</dependency>  		
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-install-plugin</artifactId>
				<version>2.3.1</version>
				<executions>
					<execution>
						<id>install-jScience-snap-jar</id>
						<phase>initialize</phase>
						<goals>
							<goal>install-file</goal>	
						</goals>
						<!--
						<goals>
							<goal>install-jar-manually-goal-by-stub22</goal>
						</goals>
						-->
						<configuration>
							<packaging>jar</packaging>
							<groupId>${jscience.groupId}</groupId>
							<artifactId>${jscience.math.artifactId}</artifactId>
							<version>${jscience.version}</version>
							<file>ext.lib.org.jscience/${jscience.math.artifactId}/${jscience.version}/${jscience.math.artifactId}-${jscience.version}.jar</file>
						</configuration>
					</execution>
				</executions>
			</plugin>				
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>2.2.0</version>
				<extensions>true</extensions>
				<configuration>
					<instructions>
						<Bundle-Activator>org.appdapter.ext.bundle.math.jscience.Activator</Bundle-Activator>
						<!-- (re-)export both JScience and javolution, plus any extra activator classes -->
						<Export-Package>org.jscience.*, javolution.*, org.appdapter.* </Export-Package>
						<Import-Package>javax.realtime.*;resolution:='optional', *</Import-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>
<!--
/*
 *  Copyright 2011 by The Appdapter Project (www.appdapter.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.
 */
-->

