A buildr plugin contributing a new packaging method to package your project as a IzPack installer.
This is for Buildr, the build system that lets you build like you code. see buildr.apache.org/
Some ideas/naming conventions were picked up from github.com/bmuschko/gradle-izpack-plugin.
This plugin provides a one-stop solution for packaging, distributing and deploying applications for the Java platform using IzPack (izpack.org/). Before using it, install it via
gem install BuildrIzPack
It has been tested using jruby-1.6.5, ruby-1.8.7-p358 and ruby-1.9.3-p125. Running “rake spec” with rubies 1.8.7 and 1.9.2 failed with the message “Failed to download org.jruby:jruby-complete:jar:1.5.4,”. This problem should be fixed once buildr 1.4.7 will be out.
-
Include one or more files and let the BuildrIzPack build a simple installer, where you may choose the installation path. Default langues is ‘eng’. The locales accepts an array of locale-identifiers (3-letters ISO code)
-
Specifiy a IzPack installer-XML via the the input methods
-
Specify the XML-content of the various elements of the IzPack installation
include one or more files and let the BuildrIzPack build a simple installer
require 'buildrizpack' Buildr::write "example_1/src/main/java/Hello.java", "public class Hello {}" define 'example_1', :version => '0.9.8' do package(:jar) package(:izpack).locales = ['eng', 'fra', 'deu'] package(:izpack).include(package(:jar)) end
Specifiy a IzPack installer-XML via the the input methods
require 'buildrizpack' define 'example_2', :version => '0.9.8' do myInstXml = path_to(:target, 'myInstaller.xml') xm = Builder::XmlMarkup.new(:target=>File.open(myInstXml, 'w+'), :indent => 2) xm.instruct! xm.installation('version'=>'1.0') { xm.tag!('info') { xm.appversion(project.version); xm.appname(project.name) } xm.guiprefs('width' => '400', 'height' => '400', 'resizable' => 'no') xm.panels { |x| xm.panel('classname' => 'InstallPanel') } xm.locale { |x| xm.langpack('iso3'=>'eng') } xm.packs { xm.pack('name' => 'main', 'required' => 'yes') {
xm.description(“my first and only pack for #{project.name}”) xm.file(‘src’=> myInstXml, ‘targetdir’ =>‘$INSTALL_PATH’) } }
} xm.target!().close package(:jar) # It is you responsability to specify correctly all dependencies!! package(:izpack).input = myInstXml package(:izpack) end
Example 3: A more realistic example. Specifies installer.xml, dependencies and integration checks¶ ↑
This example is closer to what you will probably need for a full blown application.
require 'buildrizpack' define 'example_3', :version => '0.9.8' do myJavaFile = "example_3/src/main/java/Hello.java" myFirstTextFile = path_to(:target)+"/1_5.txt" mySecondTxtFile = path_to(:target)+"/3_7.txt" myInstXml = path_to(:target, 'myInstaller.xml') myInstaller = _('deploy/myInstaller.jar') Buildr::write myJavaFile, "public class Hello {}" if !File.exists?(myJavaFile) package(:jar) # :file attribute must appear on the first call to package(:izpack) or it will have no effet package(:izpack, :file => myInstaller).locales = ['eng', 'fra', 'deu'] # we create file task for each file to be packed file(myFirstTextFile) do Buildr.write(myFirstTextFile, "This is file 1_5.txt") end file(mySecondTxtFile) do Buildr.write(mySecondTxtFile, "This is file 3_7.txt") end # Use the BuildrIzPack::Pack to pack some files pack = BuildrIzPack::Pack.new('myPackName', 'myPack description') pack.addFile(myInstXml) pack.addFile(package(:jar).to_s) pack.addFile(myFirstTextFile) pack.addFile(mySecondTxtFile, "$INSTALL_PATH/another_name") # Create a custom installer.xml as there are just too many options to find a simple, # less complex, easy to use abstraction. And XmlMarkup is easy to read & create! file(myInstXml => [package(:jar).to_s, myFirstTextFile, mySecondTxtFile]) do xm = Builder::XmlMarkup.new(:target=>File.open(myInstXml, 'w+'), :indent => 2) xm.instruct! xm.installation('version'=>'1.0') { xm.tag!('info') { xm.appversion(project.version); xm.appname(project.name) } xm.guiprefs('width' => '400', 'height' => '400', 'resizable' => 'no') xm.panels { |x| xm.panel('classname' => 'InstallPanel') } xm.locale { |x| xm.langpack('iso3'=>'eng') }
xm.packs { pack.emitIzPackXML(xm) }
} xm.target!().close end # Specify an explizit dependency to the installer.xml file package(:izpack).input = myInstXml file(package(:izpack).to_s => myInstXml) package(:izpack) # It is always a good idea to check whether your buildr project had the desired effect. # Therefore I love to add some integration tests like check package(:izpack), 'checks, whether IzPack installer works correctly' do File.should exist(myJavaFile) File.should exist(myInstXml) File.should exist(myInstaller) content = IO.readlines(myInstXml).join('') content.should match(/installation/) content.should match(/\$INSTALL_PATH\/another_name/) content.should match(/pack name="myPackName"/) content.should match(/<description>myPack description<\/description>/) content.should match(/target="\$INSTALL_PATH\/plugins\/1_5.txt"/) content.should match(/target="\$INSTALL_PATH\/another_name"/) end end
You can check the latest sources via:
git clone git://github.com/ngiger/buildrizpack
To install BuildrIzPack locally from source:
cd buildrizpack rake install
If the cutting edge doesn’t work, make sure to check the CHANGELOG, to see which changes might have broken your build. To run all the test cases:
rake spec
(Works only with ruby-1.8.7 not with jruby or ruby 1.9) If you have any questions or suggestions for improvements you may reach me via E-Mail to mail:[email protected]
A continuos integration setup can be found under ngiger.dyndns.org/jenkins/job/buildrizpack/.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.