forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdupoiri...@apache.org
Subject svn commit: r395881 - in /forrest/trunk: main/forrest.build.xml main/targets/plugins.xml main/var/pluginlist2fetch.xsl plugins/build.xml
Date Fri, 21 Apr 2006 13:44:44 GMT
Author: cdupoirieux
Date: Fri Apr 21 06:44:42 2006
New Revision: 395881

URL: http://svn.apache.org/viewcvs?rev=395881&view=rev
Log:
FOR-747, FOR-388, FOR-343...
New Plugin Fetch method to auto update plugins.
I will close these issues when I will have updated the forrest site UsingPlugins page.

Method summary - for each needed plugin : 
- search sources of plugin in local and in remote site (see http://svn.apache.org/viewcvs?view=rev&rev=391589)
  Locally found :
  - local deploy it if found (the new local-deploy does not clean so that only new plugins
features are deployed)
  Remotly found :
  - if the remote zip file is more recent, then download it and extract it
  - else, no download, no extract.
- Configure the plugin.

The plugins.xml has been cleared and is documented - a little...
In other files, several targets have been updated in order to be quiet sometimes
The order of the targets execution have been reviewed to avoid duplication of execution (init-proxy,
fetch-descriptors-files, for instances...)


Modified:
    forrest/trunk/main/forrest.build.xml
    forrest/trunk/main/targets/plugins.xml
    forrest/trunk/main/var/pluginlist2fetch.xsl
    forrest/trunk/plugins/build.xml

Modified: forrest/trunk/main/forrest.build.xml
URL: http://svn.apache.org/viewcvs/forrest/trunk/main/forrest.build.xml?rev=395881&r1=395880&r2=395881&view=diff
==============================================================================
--- forrest/trunk/main/forrest.build.xml (original)
+++ forrest/trunk/main/forrest.build.xml Fri Apr 21 06:44:42 2006
@@ -502,7 +502,7 @@
 <!-- **                                                             ** -->
 <!-- ***************************************************************** -->
 <!-- ***************************************************************** -->
-  <target name="init-proxy" if="proxy.host">
+  <target name="init-proxy" if="proxy.host" unless="proxy.already.set">
     <echo>Using proxy : ${proxy.host}:${proxy.port}</echo>
     <if>
       <isset property="proxy.user"/>

Modified: forrest/trunk/main/targets/plugins.xml
URL: http://svn.apache.org/viewcvs/forrest/trunk/main/targets/plugins.xml?rev=395881&r1=395880&r2=395881&view=diff
==============================================================================
--- forrest/trunk/main/targets/plugins.xml (original)
+++ forrest/trunk/main/targets/plugins.xml Fri Apr 21 06:44:42 2006
@@ -53,16 +53,16 @@
     <if>
       <isset property="plugin.unavailable"/>
       <then>
-        <echo>${versioned.name} is not available in the build dir</echo>
+        <echo>${versioned.name} is not available in the build dir. Trying to fetch
it...</echo>
       </then>
       <else>
-        <echo>${versioned.name} is available in the build dir</echo>
+        <echo>${versioned.name} is available in the build dir. Trying to update it...</echo>
       </else>
     </if>
   </target>  
             
   <target name="unpack-plugin"
-           if="plugin.unavailable"
+           if="downloaded"
           depends="init-props">
      <if>
        <available file="${forrest.plugins-dir}/${versioned.name}.zip"/>
@@ -121,12 +121,7 @@
      <fileset dir="${forrest.plugins-dir}/">
         <include name="${plugin}.zip"/>
       </fileset>
-   </unzip>       
-   <delete>
-      <fileset dir="${forrest.plugins-dir}/">
-        <include name="${plugin}.zip"/>
-      </fileset>
-   </delete>
+   </unzip>
 
    <!-- add to the entity catalog -->
    <copy file="${forrest.core}/var/initial_catalog.xcat"
@@ -297,11 +292,7 @@
        tofile="${project.temp-dir}/locationmap.xml"/>
   </target>
 
-  <target name="fetch-plugins-descriptors" if="plugin.unavailable" depends="init-proxy">
-    <delete>
-      <fileset dir="${project.temp-dir}" includes="plugins-*.xml"/>
-    </delete>
-  
+  <target name="fetch-plugins-descriptors" depends="init-proxy" unless="plugins.desc.already.fetched">
     <var name="plugin-counter" value="1"/>
     <for list="${forrest.plugins.descriptors}" param="url">
       <sequential>
@@ -339,31 +330,41 @@
   </target>  
   
   <target name="fetch-plugin" 
-          if = "plugin.unavailable"
+          
           depends="init-props, fetch-plugins-descriptors">
-    <for param="plugin-descriptor-file">
-      <path>
-        <fileset dir="${project.temp-dir}" includes="plugins-*.xml"/>
-      </path>
-      <sequential>
-        <xslt in="@{plugin-descriptor-file}" 
-          out="${project.temp-dir}/pluginlist2fetchbuild.xml"
-          style="${forrest.core}/var/pluginlist2fetch.xsl"
-          force="true">
-          <param name="plugin-name" expression="${plugin.name}"/>  
-          <param name="plugin-version" expression="${plugin.version}"/>  
-          <param name="plugin-dir" expression="${forrest.plugins-dir}/"/>  
-          <param name="plugin-src-dir" expression="${project.required.plugins.src}"/>
-          <param name="forrest-version" expression="${forrest.version}"/>   
-       </xslt>  
-       <ant antfile="${project.temp-dir}/pluginlist2fetchbuild.xml"/> 
-      </sequential>
-    </for>
+    <echo>Trying to find the description of ${versioned.name} in the different descriptor
files</echo>
+    <trycatch property="plugin-found">
+      <try>
+      	<for param="plugin-descriptor-file">
+      		<path>
+        		<fileset dir="${project.temp-dir}" includes="plugins-*.xml"/>
+      		</path>
+      		<sequential>
+      		  <echo>Using the descriptor file @{plugin-descriptor-file}...</echo>
+		        <xslt in="@{plugin-descriptor-file}" 
+		          out="${project.temp-dir}/pluginlist2fetchbuild.xml"
+		          style="${forrest.core}/var/pluginlist2fetch.xsl"
+		          force="true">
+		          <param name="plugin-name" expression="${plugin.name}"/>  
+		          <param name="plugin-version" expression="${plugin.version}"/>  
+		          <param name="plugin-dir" expression="${forrest.plugins-dir}/"/>  
+		          <param name="plugin-src-dir" expression="${project.required.plugins.src}"/>
+		          <param name="forrest-version" expression="${forrest.version}"/>   
+		       	</xslt>  
+		       	<antfetch antfile="${project.temp-dir}/pluginlist2fetchbuild.xml" return="plugin-found,downloaded"/>
+		       	<fail if="plugin-found"/>
+      		</sequential>
+		    </for>
+      </try>
+      <catch>
+        <echo>Fetch-plugin Ok, installing !</echo>
+      </catch>
+    </trycatch>
   </target>    
   
   <target name="install-plugin" depends="check-plugin, fetch-plugin, unpack-plugin"/>
   
-  <target name="init-plugins" depends="init-props"
+  <target name="init-plugins" depends="init-props, fetch-plugins-descriptors"
     description="Ensure the required plugins are available locally, if any are not, download
them automatically">
     
     <mkdir dir="${forrest.plugins-dir}"/>
@@ -411,6 +412,8 @@
           <param name="plugin.name" value="${plugin.name}"/>
           <param name="plugin.version" value="${plugin.version}"/>
           <param name="versioned.name" value="@{name}"/>
+          <param name="plugins.desc.already.fetched" value="true"/>
+          <param name="proxy.already.set" value="true"/>
         </antcall>
         <antcall target="configure-plugin">
           <param name="plugin.name" value="${plugin.name}"/>

Modified: forrest/trunk/main/var/pluginlist2fetch.xsl
URL: http://svn.apache.org/viewcvs/forrest/trunk/main/var/pluginlist2fetch.xsl?rev=395881&r1=395880&r2=395881&view=diff
==============================================================================
--- forrest/trunk/main/var/pluginlist2fetch.xsl (original)
+++ forrest/trunk/main/var/pluginlist2fetch.xsl Fri Apr 21 06:44:42 2006
@@ -52,7 +52,7 @@
 
          <target name="fetch-remote-versioned-plugin-version-forrest" unless="plugin-found">
            <!-- Search for the remote versionned plugin in the versionned Forrest...-->
-           <antcallback target="download" return="plugin-found">
+           <antcallback target="download" return="plugin-found,desired.plugin.zip.present">
              <param name="download-plugin-version">
                <xsl:attribute name="value">-<xsl:value-of select="$plugin-version"
/></xsl:attribute>
              </param>
@@ -77,7 +77,7 @@
 
          <target name="fetch-remote-unversioned-plugin-version-forrest" unless="plugin-found">
            <!-- Search for the remote unversionned plugin in the versionned Forrest...-->
-           <antcallback target="download" return="plugin-found">
+           <antcallback target="download" return="plugin-found,desired.plugin.zip.present">
              <param name="download-plugin-version" value=""/>
              <param name="download-plugin-name">
                <xsl:attribute name="value"><xsl:value-of select="$plugin-name" /></xsl:attribute>
@@ -90,7 +90,7 @@
 
          <target name="fetch-remote-unversioned-plugin-unversion-forrest" unless="plugin-found">
            <!-- Search for the remote unversionned plugin in the unversionned Forrest...-->
-           <antcallback target="download" return="plugin-found">
+           <antcallback target="download" return="plugin-found,desired.plugin.zip.present">
              <param name="download-plugin-version" value=""/>
              <param name="download-plugin-name">
                <xsl:attribute name="value"><xsl:value-of select="$plugin-name" /></xsl:attribute>
@@ -112,9 +112,11 @@
                         <xsl:attribute name="file">@{plugin-src-dir}/${local-plugin-name}${local-plugin-version}</xsl:attribute>
                       </available>
                       <then>
+                        <echo message="Found !"/>
                         <ant target="local-deploy">
                           <xsl:attribute name="antfile">@{plugin-src-dir}/${local-plugin-name}${local-plugin-version}/build.xml</xsl:attribute>
                           <xsl:attribute name="dir">@{plugin-src-dir}/${local-plugin-name}${local-plugin-version}</xsl:attribute>
+                          <property name="no.echo.init" value="true"/>
                         </ant>
                         <fail/>
                       </then>
@@ -123,13 +125,29 @@
                 </for>
               </try>
               <catch>
-                <echo>Plugin ${local-plugin-name}${local-plugin-version} deployed !</echo>
+                <echo>Plugin ${local-plugin-name}${local-plugin-version} deployed !
Ready to configure</echo>
               </catch>
             </trycatch>
          </target>
 
-         <target name="download">
+         <target name="download" depends="keep-original-zip,get-from-remote-site,is-downloaded,remove-original-zip"/>
+
+         <target name="keep-original-zip" depends="available-original-zip" if="original.zip.exists">
+           <copy preservelastmodified="true">
+             <xsl:attribute name="file"><xsl:value-of select="$plugin-dir"/>${download-plugin-name}.zip</xsl:attribute>
+             <xsl:attribute name="tofile"><xsl:value-of select="$plugin-dir"/>${download-plugin-name}.zip.orig</xsl:attribute>
+           </copy>
+         </target>
+
+         <target name="available-original-zip">
+           <available property="original.zip.exists">
+             <xsl:attribute name="file"><xsl:value-of select="$plugin-dir"/>${download-plugin-name}.zip</xsl:attribute>
+           </available>
+         </target>
+
+         <target name="get-from-remote-site">
            <echo>Tying to download ${download-plugin-name}${download-plugin-version}
from the distribution site ...</echo>
+           <!-- FIXME the following test does not work... -->
            <if>
              <not><equals arg2="">
                <xsl:attribute name="arg1">${download.forrest.version}</xsl:attribute>
@@ -138,37 +156,68 @@
                <echo>Using Forrest version : ${download-forrest-version}</echo>
              </then>
            </if>
+           <!-- Get from the remote URL -->
            <get verbose="true" usetimestamp="true" ignoreerrors="true">
              <xsl:attribute name="src"><xsl:value-of select="plugin[@name=$plugin-name]/@url"
/>/${download-forrest-version}${download-plugin-name}${download-plugin-version}.zip</xsl:attribute>
              <xsl:attribute name="dest"><xsl:value-of select="$plugin-dir"/>${download-plugin-name}.zip</xsl:attribute>
            </get>
-           <available property="plugin-found">
+           <!-- Check if a zip has been downloaded from this URL -->
+           <available property="desired.plugin.zip.present">
              <xsl:attribute name="file"><xsl:value-of select="$plugin-dir"/>${download-plugin-name}.zip</xsl:attribute>
            </available>
+           <condition property="plugin-found">
+             <!-- or -->
+               <and>
+                 <isset property="desired.plugin.zip.present"/>
+                 <not><isset property="original.zip.exists"/></not>
+               </and>
+           </condition>
+         </target>
+
+         <target name="is-downloaded" if="original.zip.exists">
+           <!-- Check is the downloaded file is more recent than the original zip ...
-->
+           <uptodate property="no-difference-found">
+             <xsl:attribute name="srcfile"><xsl:value-of select="$plugin-dir"/>${download-plugin-name}.zip</xsl:attribute>
+             <xsl:attribute name="targetfile"><xsl:value-of select="$plugin-dir"/>${download-plugin-name}.zip.orig</xsl:attribute>
+           </uptodate>
+           <!-- If there are differences, the plugin is found -->
+           <if>
+              <not><isset property="no-difference-found"/></not>
+              <then>
+                <property name="plugin-found" value="true"/>
+              </then>
+           </if>
          </target>
 
-         <target name="final-check">
-            <available property="desired.plugin.zip.present">
-              <xsl:choose>
-                <xsl:when test="$plugin-version">
-                  <xsl:attribute name="file"><xsl:value-of select="$plugin-dir"/><xsl:value-of
select="$plugin-name" />-<xsl:value-of select="$plugin-version" />.zip</xsl:attribute>
-                </xsl:when>
-                <xsl:otherwise>
-                  <xsl:attribute name="file"><xsl:value-of select="$plugin-dir"/><xsl:value-of
select="$plugin-name" />.zip</xsl:attribute>
-                </xsl:otherwise>
-              </xsl:choose>
-            </available>
+         <target name="remove-original-zip" if="original.zip.exists">
+           <!-- Now, we can delete the original -->
+           <delete>
+             <xsl:attribute name="file"><xsl:value-of select="$plugin-dir"/>${download-plugin-name}.zip.orig</xsl:attribute>
+           </delete>
+         </target>
 
-            <if>
-              <isset property="desired.plugin.zip.present"/>
-              <then>
-                <echo><xsl:value-of select="$plugin-name" /> downloaded, ready
to install</echo>
-              </then>
-              <else>
-                <available property="unversioned.plugin.present" type="dir">
-                  <xsl:attribute name="file"><xsl:value-of select="$plugin-dir"/><xsl:value-of
select="$plugin-name" /></xsl:attribute>
-                </available>
-                <fail unless="unversioned.plugin.present">
+         <target name="final-check" depends="has-been-downloaded,downloaded-message,uptodate-message,not-found-message"/>
+
+         <target name="has-been-downloaded" if="desired.plugin.zip.present">
+           <condition property="up-to-date">
+             <not><isset property="plugin-found"/></not>
+           </condition>
+           <condition property="downloaded">
+             <isset property="plugin-found"/>
+           </condition>
+         </target>
+
+         <target name="downloaded-message" if="downloaded">
+           <echo>Plugin <xsl:value-of select="$plugin-name" /> downloaded ! Ready
to install</echo>
+         </target>
+
+         <target name="uptodate-message" if="up-to-date">
+           <echo>Plugin <xsl:value-of select="$plugin-name" /> was up-to-date
! Ready to configure</echo>
+           <property name="plugin-found" value="true"/>
+         </target>
+
+         <target name="not-found-message" unless="desired.plugin.zip.present">
+           <fail>
   Unable to download the
   "<xsl:value-of select="$plugin-name" />" plugin
   <xsl:if test="$plugin-version">version <xsl:value-of select="$plugin-version"/></xsl:if>
@@ -187,10 +236,10 @@
   To manually install a plugin, download the plugin zip file from
   <xsl:value-of select="plugin[@name=$plugin-name]/@url"/> and
   extract it into
-  <xsl:value-of select="$plugin-dir"/><xsl:value-of select="$plugin-name" /></fail>
-              </else>
-            </if>
+  <xsl:value-of select="$plugin-dir"/><xsl:value-of select="$plugin-name" />
+           </fail>
          </target>
+
       </project>
          </xsl:when>
          <xsl:otherwise>

Modified: forrest/trunk/plugins/build.xml
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/build.xml?rev=395881&r1=395880&r2=395881&view=diff
==============================================================================
--- forrest/trunk/plugins/build.xml (original)
+++ forrest/trunk/plugins/build.xml Fri Apr 21 06:44:42 2006
@@ -70,7 +70,12 @@
     </classpath>
   </taskdef>
   
-  <target name="init">
+  <target name="init" depends="init-build-compiler, echo-init"/>
+
+  <target name="init-build-compiler">
+
+    <fail unless="plugin-name" message="You must run plugin build targets from within
the plugin directory."/>
+
     <tstamp>
       <format property="YEAR" pattern="yyyy" locale="en"/>
     </tstamp>
@@ -87,10 +92,19 @@
     <property name="build.compiler.type"        value="classic"/>
     <property name="build.compiler.vm"          value="1.2"/>
     
-    <fail unless="plugin-name" message="You must run plugin build targets from within
the plugin directory."/>
-           
     <mkdir dir="${build.dir}"/>
     
+    <path id="classpath">
+      <fileset dir="${forrest.home}/lib" includes="**/*.jar"/>
+      <fileset dir="${plugin.lib.dir}" includes="*.jar"/>
+      <fileset dir="${plugin.lib.dir}" includes="*.zip"/>
+    </path>
+  	
+    <available file="${plugin.java.dir}" property="java_exists" type="dir"/>
+    
+  </target>
+  
+  <target name="echo-init" depends="init-build-compiler" unless="no.echo.init">
     <buildnumber file="${build.dir}/build.number"/>
     <echo>
       --------------------------------------------------------------
@@ -106,15 +120,6 @@
       
       --------------------------------------------------------------
     </echo>
-    
-    <path id="classpath">
-      <fileset dir="${forrest.home}/lib" includes="**/*.jar"/>
-      <fileset dir="${plugin.lib.dir}" includes="*.jar"/>
-      <fileset dir="${plugin.lib.dir}" includes="*.zip"/>
-    </path>
-  	
-    <available file="${plugin.java.dir}" property="java_exists" type="dir"/>
-    
   </target>
   
   <target name="clean" depends="init">
@@ -122,11 +127,9 @@
     <delete dir="${forrest.plugins.dist.dir}"/>
   </target>
   
-  
-  <!-- FIXME: FOR-388 Forrest should really use the plugins in-place if they are available
as source -->
   <target name="local-deploy"
           description="Deploy a plugin locally"
-          depends="init, clean, jar">
+          depends="init, jar">
           
     <echo>Locally deploying ${plugin-name}</echo>
     



Mime
View raw message