IzPack

AntActionListener cannot reference an internal build script

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 4.0.0
  • Fix Version/s: 4.3.1
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

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

Activity

Hide
Thomas Diesler added a comment -
<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>
Show
Thomas Diesler added a comment -
<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>
Hide
Brett Bergquist added a comment -

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.

Show
Brett Bergquist added a comment - 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.
Hide
Brett Bergquist added a comment -

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.

Show
Brett Bergquist added a comment - 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.
Hide
Brett Bergquist added a comment -

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.

Show
Brett Bergquist added a comment - 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.
Hide
Julien Ponge added a comment -

Thanks!

Show
Julien Ponge added a comment - Thanks!
Hide
Tom Van Buskirk added a comment -

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!

Show
Tom Van Buskirk added a comment - 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!
Hide
Brett Bergquist added a comment -

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.

Show
Brett Bergquist added a comment - 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.
Hide
Brett Bergquist added a comment -

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.

Show
Brett Bergquist added a comment - 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.
Hide
Julien Ponge added a comment -

Hi Brett,

Any news on this issue?

Thanks

Show
Julien Ponge added a comment - Hi Brett, Any news on this issue? Thanks
Hide
Brett Bergquist added a comment -

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

Show
Brett Bergquist added a comment - I will try to get to this over the weekend. I know I can fix it, it is just finding the time.
Hide
Brett Bergquist added a comment -

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.

Show
Brett Bergquist added a comment - 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.
Hide
Tom Van Buskirk added a comment -

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

Show
Tom Van Buskirk added a comment - 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
Hide
Thomas Diesler added a comment -

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>

Show
Thomas Diesler added a comment - 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>

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: