Issue Details (XML | Word | Printable)

Key: IZPACK-158
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Brett Bergquist
Reporter: Thomas Diesler
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IzPack

AntActionListener cannot reference an internal build script

Created: 05/Sep/08 05:02 AM   Updated: 14/Sep/09 03:35 PM   Resolved: 15/Jun/09 06:18 PM
Return to search
Component/s: None
Affects Version/s: 4.0.0
Fix Version/s: 4.3.1

Time Tracking:
Not Specified


 Description  « Hide

Currently I have to install the ant script before the AntActionListener can call it

<!-- JBoss-4.2.2 -->
    <pack name="Download JBoss-4.2.2" required="no" parent="Optional Downloads" preselected="no">
      <description>Download and Install JBoss-4.2.2</description>
      <file src="@{resources.dir}/installer/download-helper.xml" targetdir="$INSTALL_PATH/Uninstaller"/>
    </pack>
    
    <!-- Eclipse-3.4.0 -->
    <pack name="Download Eclipse-3.4.0" required="no" parent="Optional Downloads" preselected="no">
      <description>Download and Install Eclipse-3.4.0</description>
      <file src="@{resources.dir}/installer/download-helper.xml" targetdir="$INSTALL_PATH/tmp"/>
    </pack>
<antactions>
  <pack name="Download JBoss-4.2.2">
    <antcall order="afterpack" buildfile="$INSTALL_PATH/Uninstaller/download-helper.xml">
      <property name="install.path" value="$INSTALL_PATH"/>
      <target name="download-jboss"/>
    </antcall>
  </pack>
  <pack name="Download Eclipse-3.4.0">
    <antcall order="afterpack" buildfile="$INSTALL_PATH/Uninstaller/download-helper.xml">
      <property name="install.path" value="$INSTALL_PATH"/>
      <target name="download-eclipse"/>
    </antcall>
  </pack>
</antactions>

I'd rather not have to install the download-helper.xml at all.

cheers
-thomas



Thomas Diesler added a comment - 05/Sep/08 05:03 AM
<project>

  <target name="download-jboss">
    <get src="http://downloads.sourceforge.net/jboss/jboss-4.2.2.GA.zip" dest="${install.path}/Uninstaller/jboss-4.2.2.GA.zip" usetimestamp="true"/>
    <unzip src="${install.path}/Uninstaller/jboss-4.2.2.GA.zip" dest="${install.path}"/>
  </target>
  <target name="download-eclipse">
    <get src="http://download.eclipse.org/technology/epp/downloads/release/ganymede/R/eclipse-java-ganymede-linux-gtk.tar.gz" 
      dest="${install.path}/Uninstaller/eclipse-java-ganymede-linux-gtk.tar.gz" usetimestamp="true"/>
    <untar src="${install.path}/Uninstaller/eclipse-java-ganymede-linux-gtk.tar.gz" dest="${install.path}" compression="gzip"/>
  </target>

</project>

Brett Bergquist added a comment - 25/Feb/09 10:37 AM

Email that I sent to the dev list:

I need the ability to run an ant action before packs are installed. Currently the build file called must exist on the system since at the point the ant action is called, no files have been extracted from the packs. In my use case, the build file does not exist on the system, so this is not going to work.

What I would like to do is to modify the AntActiionInstallListener to be able to reference a build file that is stored as a resource of the installed:

<?xml version="1.0" encoding="UTF-8"?>
<actactions>
<pack name="App">
<antcall
order="beforepacks"
messageid="Preparing for upgrade"
buildresource="embedded_build_xml">
<target name="prepare-for-upgrade"/>
</antcall>
</pack>
</actactions>

In the above example, "embedded_build_xml" would be a reference to a resource:

<resource id="embedded_build_xml" src="build.xml" parse="yes" type="ant"/>

What this will do is extract out the resource into a temporary file while substituting variables and then set the temporary file as the build file. The DTD for AntActionSpec would be changed to have a new "buildresource" attribute and the "buildfile" attribute would be changed to IMPLIED. Either "buildfile" or "buildresource" must be specified but not both.

I have the code up and running. Attached is a patch to show the changes. If after review no one objects, I will open an enhancement issue and apply the changes including updating the documentation.


Brett Bergquist added a comment - 30/Mar/09 02:04 PM

I modified this to follow the standard build file processing in that the build resource, when extracted, will NOT substitute variables into the extracted build file. Like the standard build file processing, variables can be passed into the extracted build file by using ant properties.


Brett Bergquist added a comment - 30/Mar/09 02:25 PM

Added support for referencing a "buildresource" by resource Id in the AntActionSpec.xml. The Id given must match one defined like:
<resource id="prebuild_script" src="prebuild.xml"/>

The file "prebuild.xml" will be extracted into a temporary file and ant will be called with this file as its build file. The temporary will be removed when the installation completes.


Julien Ponge added a comment - 30/Mar/09 03:04 PM

Thanks!


Tom Van Buskirk added a comment - 08/May/09 06:36 PM

Thanks for this fix! ...

One issue though that seems unresolved... If you use buildresource rather than buildfile and also have an <uninstall_target> defined for that <antcall>, then un-installation will fail looking for the buildresource in the Temp directory.

Here's some information...

The <antcall>
<antcall order="afterpack" uninstall_order="beforedeletion" messageid="install.msg" buildresource="AntInstallFile.xml">
  <property name="install.dir" value="$INSTALL_PATH" />
  <target name="install-prod-win" />
  <uninstall_target name="uninstall-prod-win" />
</antcall>

The Exception
java.io.FileNotFoundException: C:\Users\Me\AppData\Local\Temp\buildfile_resource232746....82xml (The system cannot find the file specified)

System Info:
Operating System: Windows Vista x64
JRE: Java SE 6 update 13

The work-around that I'm planning is to declare separate _<antcall>_s for my uninstall tasks, which point to a different Ant build.xml file than I use for my install tasks. That build file would be installed at installation into the Uninstaller directory. It should work for now, but I really like the idea of not exposing any of these tasks to users. Any chance this could be addressed?

Thanks!


Brett Bergquist added a comment - 11/May/09 07:44 AM

Tom, I do use a separate "antcall" in my installer for this. My use case was that I needed to upgrade an installation. My upgrade uses ant but there was not currently a build file on the system and in fact the upgrade process build file did not need to exist after the upgrade. I needed to perform some actions before packs were installed, so I came up with this solution. I did not think about an uninstall situation.

I will take a look at what it will take to extract out the same build file during the uninstall and execute it there.


Brett Bergquist added a comment - 11/May/09 07:46 AM

Reopen this issue to support extracting the embedded build file when uninstalling. Right now, the ant call will fail during uninstallation if there is an uninstall target.


Julien Ponge added a comment - 03/Jun/09 02:34 PM

Hi Brett,

Any news on this issue?

Thanks


Brett Bergquist added a comment - 03/Jun/09 02:41 PM

I will try to get to this over the weekend. I know I can fix it, it is just finding the time.


Brett Bergquist added a comment - 15/Jun/09 06:18 PM

Made changes to AntActionInstallListener and AntActionUninstallListerner and IOHelper to copy the internal build script to
the uninstaller and have the uninstaller extract out the build script and set the ant uninstall actions to point to it.


Tom Van Buskirk added a comment - 16/Jun/09 11:11 PM

Hi Brett and Julien,

Thanks for your work on this issue. I'm excited to upgrade to 4.3.1 to try it out.

Thanks again,
Tom


Thomas Diesler added a comment - 14/Sep/09 03:35 PM

For my reference:

IzPack-4.3.1

install-definition.xml

<!-- jars -->
<jar src="@{deploy.artifacts.dir}/lib/ant.jar" stage="both" />
<jar src="@{deploy.artifacts.dir}/lib/ant-launcher.jar" stage="both" />

<!-- Listeners -->
<listeners>
<listener installer="AntActionInstallerListener" uninstaller="AntActionUninstallerListener" />
</listeners>

<!-- Resources -->
<resources>
<res id="AntActionsSpec.xml" src="@{filtered.resources.dir}/ant-actions-spec.xml" />
<res id="antBuild.xml" src="@{filtered.resources.dir}/ant-jbossas-integration.xml" type="ant"/>
...
</resources>

ant-actions-spec.xml

<antactions>
<pack name="JBossAS Integration">
<antcall order="beforepack" buildresource="antBuild.xml" verbose="yes">
<target name="delete-jboss-jars"/>
</antcall>
</pack>
</antactions>

ant-jbossas-integration.xml

<project>
<target name="delete-jboss-jars">
<echo message="Hello from Ant target"/>
</target>
</project>