patch for FELIX-1393 now downloads sigil dependencies on first build


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@797059 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/bldcommon/build.properties b/sigil/bldcommon/build.properties
index 8c9b43e..0e02447 100644
--- a/sigil/bldcommon/build.properties
+++ b/sigil/bldcommon/build.properties
@@ -27,10 +27,11 @@
 # note: clean-local task assumes repository.pattern starts with ${ivy.module}
 repository.pattern = [module]/[revision]/[type]s/[artifact].[ext]
 
-community.version = 1.4.0.SNAPSHOT
-jini.version	= 2.1
-paremus.version	= ${default.version}
-bundle.version	= ${paremus.version}
+ivy.install.version=2.0.0
+bnd.install.version=0.0.312
+equinox.install.version=3.4.0.v20080421-2006
+equinox.release=ganymede
+
 resolve.log	= download-only
 
 # over-ridden by hudson
diff --git a/sigil/bldcommon/common.xml b/sigil/bldcommon/common.xml
index 6703385..2b6209d 100644
--- a/sigil/bldcommon/common.xml
+++ b/sigil/bldcommon/common.xml
@@ -49,32 +49,12 @@
     <!-- ================================= 
           target: load-ivy
          ================================= -->
-    <target name="load-ivy" depends="ident,ivy-taskdefs">
+    <target name="load-ivy" depends="init-sigil">
+	<echo message="Loading Ivy ... common.dir=${common.dir}"/>
 	<ivy:settings file="${common.dir}/ivysettings.xml" />
     </target>
 
     <!-- ================================= 
-          target: ivy-taskdefs
-         ================================= -->
-    <target name="ivy-taskdefs" unless="ivy.loaded">
-    	<property name="ivy.loaded" value="true"/>
-		<echo message="Loading Ivy ... common.dir=${common.dir}"/>
-	
-	    	<taskdef resource="org/apache/ivy/ant/antlib.xml"
-	    	         uri="antlib:org.apache.ivy.ant"
-			 classpath="${ivy.jar}:${sigil-ivy-plugin.jar}"/>
-	
-		<taskdef name="sigil.bundle"
-			 classname="org.apache.felix.sigil.ant.BundleTask"
-			 classpath="${sigil-ivy-plugin.jar}"/>
-    	
-    	<taskdef name="sigil.bundle.info"
-    		 classname="org.apache.felix.sigil.ant.BundleInfoTask"
-    		 classpath="${sigil-ivy-plugin.jar}"/>
-    </target>    
-	
-
-    <!-- ================================= 
           target: build (default target)
          ================================= -->
     <target name="build" depends="publish-local, composites" />
@@ -246,7 +226,7 @@
     <!-- ================================= 
 	  target: clean-local              
 	 ================================= -->
-    <target name="clean-local" depends="load-ivy"
+    <target name="clean-local" depends="boot"
     	description="--> cleans the local repository for the current module">
        <ivy:info file="${ivy.file}"/>
        <delete dir="${repository.dir}/local/${ivy.module}"/>
@@ -276,9 +256,15 @@
 
 
     <!-- ================================= 
+          target: boot
+         ================================= -->
+    <target name="boot" depends="load-ivy">
+    </target>
+
+    <!-- ================================= 
           target: common-init
          ================================= -->
-    <target name="common-init" depends="load-ivy,init">
+    <target name="common-init" depends="ident,boot,init">
     </target>
 
     <!-- ================================= 
@@ -350,129 +336,62 @@
       <delete dir="${install.dir}"/>
       <delete dir="${dist.dir}"/>
     </target>
+
+  <condition property="ivy.home" value="${env.SIGIL_HOME}">
+    <isset property="env.SIGIL_HOME" />
+  </condition>
+
+  <property name="sigil.home" value="cache/ant" />
+  <property name="sigil.jar.dir" value="${sigil.home}/lib" />
+  <property name="ivy.jar.file" value="${sigil.jar.dir}/ivy.jar" />
+  <property name="sigil.jar.file" value="${sigil.jar.dir}/sigil-ivy-plugin.jar" />
+  <property name="bnd.jar.file" value="${sigil.jar.dir}/bndlib.jar" />
+  <property name="equinox.common.jar.file" value="${sigil.jar.dir}/equinox.common.jar" />
+
+
+  <target name="download-deps" unless="offline">
+    <property name="deps.loaded" value="true"/>
+    <mkdir dir="${sigil.jar.dir}"/>
+    <!-- ivy -->
+    <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
+         dest="${ivy.jar.file}" usetimestamp="true" verbose="true"/>
+    <!-- sigil -->
+    <get src="http://people.apache.org/~dsavage/sigil/sigil-ivy-plugin.jar"
+         dest="${sigil.jar.file}" usetimestamp="true" verbose="true"/>
+    <!-- bnd -->
+    <get src="http://www.aQute.biz/repo/biz/aQute/bndlib/${bnd.install.version}/bndlib-${bnd.install.version}.jar"
+         dest="${bnd.jar.file}" usetimestamp="true" verbose="true"/>
+    <!-- equinox.common -->
+    <get src=" http://download.eclipse.org/releases/${equinox.release}/plugins/org.eclipse.equinox.common_${equinox.install.version}.jar"
+         dest="${equinox.common.jar.file}" usetimestamp="true" verbose="true"/>
+  </target>
+
+  <target name="check-sigil">
+    <condition property="sigil.loaded">
+      <typefound name="sigil.bundle" />
+    </condition>
+  </target>
+
+  <target name="init-sigil" depends="check-sigil" unless="sigil.loaded">
+    <antcall target="download-deps" />
+    <!-- try to load ivy here from ivy home, in case the user has not already dropped
+         it into ant's lib dir (note that the latter copy will always take precedence).
+         We will not fail as long as local lib dir exists (it may be empty) and
+         ivy is in at least one of ant's lib dir or the local lib dir. -->
+    <path id="sigil.lib.path">
+      <fileset dir="${sigil.jar.dir}" includes="*.jar"/>
+    </path>
+
+    <echo>Initialising sigil with ${sigil.jar.dir}</echo>
+
+    <taskdef resource="org/apache/ivy/ant/antlib.xml"
+             uri="antlib:org.apache.ivy.ant" classpathref="sigil.lib.path"/>
+
+    <taskdef name="sigil.bundle"
+             classname="org.apache.felix.sigil.ant.BundleTask" classpathref="sigil.lib.path"/>
+
+    <taskdef name="sigil.bundle.info"
+             classname="org.apache.felix.sigil.ant.BundleInfoTask" classpathref="sigil.lib.path"/>
+  </target>
 	
-    <target name="sigil.test" depends="ivy-taskdefs">
-        <mkdir dir="${dist.dir}/lib/sigil" />
-        <copy todir="${dist.dir}/lib/sigil" overwrite="true">
-                <fileset dir="${common.dir}/test/lib">
-                        <include name="*.jar" />
-                </fileset>
-        </copy>
-
-        <mkdir dir="${dist.dir}/etc/sigil/boot" />
-
-        <copy todir="${dist.dir}/etc/sigil/boot" overwrite="true">
-                <fileset dir="${common.dir}/test/etc/boot">
-                        <include name="*" />
-                </fileset>
-        </copy>
-
-    	<property name="install.script" value="${dist.dir}/etc/sigil/boot/2-install-tests" />
-        <delete file="${install.script}" />
-
-        <for param="project">
-            <fileset refid="my.projects" />
-            <sequential>
-                <antcall target="sigil.test.setup">
-					<param name="project" value="@{project}"/>
-                </antcall>
-            </sequential>
-        </for>
-
-        <for param="project">
-            <fileset refid="my.projects" />
-            <sequential>
-                <antcall target="sigil.test.install">
-					<param name="project" value="@{project}"/>
-                </antcall>
-            </sequential>
-        </for>
-    	
-        <delete dir="${dist.dir}/../test-results" />
-    	
-        <exec executable="sh" osfamily="unix">
-          <arg line="${dist.dir}/bin/container equinox -verbose=true" />
-          <arg line="-bootScript=etc/sigil/boot" />
-        </exec>
-    </target>	
-
-	<target name="sigil.test.setup">
-		<property name="dir" location="${project}/../" />
-		<path id="test.resources">
-	        <fileset dir="${dir}">
-	        	<include name="build/lib/*.jar" />
-	        	<exclude name="**/*-dl.jar" />
-	        </fileset>
-            <fileset dir="${dir}">
-            	<include name="build/deps/*.jar" />
-	        	<exclude name="**/*!*.jar" />
-            </fileset>
-		</path>
-        <for param="jar">
-        	<path refid="test.resources"/>
-            <sequential>
-            	<antcall target="sigil.test.load">
-                	<param name="jar" value="@{jar}" />
-            	</antcall>
-            </sequential>
-        </for>
-	</target>
-	
-	<target name="sigil.test.install">
-		<property name="dir" location="${project}/../" />
-		<path id="test.bundles">
-	        <fileset dir="${dir}">
-	        	<include name="build/lib/*test.jar" />
-            </fileset>
-		</path>
-        <for param="jar">
-        	<path refid="test.bundles"/>
-            <sequential>
-            	<antcall target="sigil.test.start">
-                	<param name="jar" value="@{jar}" />
-            	</antcall>
-            </sequential>
-        </for>
-	</target>
-	
-	<target name="sigil.test.load">
-		<sigil.bundle.info bundle="${jar}" header="Bundle-SymbolicName" property="test.bundle.symbolic.name"/>
-		<if>
-			<isset property="test.bundle.symbolic.name"/>
-			<then>
-		        <echo file="${install.script}" append="true">cds load boot ${test.bundle.symbolic.name}.jar ${jar}
-</echo>
-			</then>
-		</if>
-	</target>
-	
-	<target name="sigil.test.start">
-		<sigil.bundle.info bundle="${jar}" header="Bundle-SymbolicName" property="test.bundle.symbolic.name"/>
-		<if>
-			<isset property="test.bundle.symbolic.name"/>
-			<then>
-				<sigil.bundle.info bundle="${jar}" header="Bundle-Version" property="test.bundle.version" defaultvalue="0"/>
-				<sigil.bundle.info bundle="${jar}" header="Fragment-Host" property="test.bundle.fragment"/>
-				<if>
-					<isset property="test.bundle.fragment" />
-					<then>
-						<propertyregex property="test.bundle.fragment.name"
-						              input="${test.bundle.fragment}"
-						              regexp="([^;]*).*"
-									  select="\1"
-						              casesensitive="false" />
-
-		        		<echo file="${install.script}" append="true">nim policy -a osgi.installed.bundle/${test.bundle.fragment.name} osgi.fragment.bundle/${test.bundle.symbolic.name}:${test.bundle.version}
-</echo>
-		        		<echo file="${install.script}" append="true">nim add ${test.bundle.symbolic.name}:${test.bundle.version}@fragment
-</echo>
-					</then>
-					<else>
-		        		<echo file="${install.script}" append="true">nim add ${test.bundle.symbolic.name}:${test.bundle.version}@installed
-</echo>
-					</else>
-				</if>
-			</then>
-		</if>
-	</target>
 </project>