{"id":606,"date":"2013-01-21T08:27:07","date_gmt":"2013-01-21T08:27:07","guid":{"rendered":"http:\/\/www.softwareeverydayblog.com\/?p=606"},"modified":"2018-12-15T19:47:32","modified_gmt":"2018-12-15T19:47:32","slug":"creating-installer-using-izpack","status":"publish","type":"post","link":"https:\/\/www.softwareeverydayblog.com\/?p=606","title":{"rendered":"Creating installer using IzPack and Maven"},"content":{"rendered":"<p>I recently created a <a href=\"http:\/\/code.google.com\/p\/wordpress-izpack-installer\/\" title=\"wordpress-izpack-installer\">wordpress installer using IzPack<\/a> and uploaded the source code on Google Code. It will 1.) Download wordpress source code, 2.) copy wordpress folder into any directory (usually its the www directory) and  3.) Create an empty DB into MySql. For all practical purposes in doesn&#8217;t do much, however it was a good learning experience of IzPack which i am sharing here. Even the <a href=\"http:\/\/izpack.codehaus.org\/izpack-maven-plugin\/\">izPack Maven plugin<\/a> website has some good examples.<\/p>\n<p>Here&#8217;s how the entire build process goes:-<\/p>\n<ol>\n<li>As soon as you update, http:\/\/core.svn.wordpress.org\/tags\/3.4.2\/ is downloaded into externals\\wordpress-src. If you&#8217;re not sure how this works look at <a href=\"http:\/\/svnbook.red-bean.com\/en\/1.0\/ch07s03.html\" title=\"SVN externals\">svn externals<\/a>.<\/li>\n<li>Compile all your izpack related sources. Add dependencies to pom.xml . Add all dependencies that you need. Include izpack-standalone-compiler for all izpack related classes.\n<pre lang=\"xml\" line=\"1\">\r\n  <dependency>\r\n    <groupId>org.codehaus.izpack<\/groupId>\r\n    <artifactId>izpack-standalone-compiler<\/artifactId>\r\n    <version>${izpack-standalone.version}<\/version>\r\n    <optional>true<\/optional>\r\n  <\/dependency>\r\n<\/pre>\n<\/li>\n<li>Every file that we would need while building (and eventually running) the installer, we would need to copy them into some folder (lets call it a staging folder). We use the maven-antrun-plugin to copy izpack related xml files and wordpress source code. We use the maven-dependency-plugin to copy dependencies.<\/li>\n<li>Finally, the izpack-maven-plugin is called to create our standalone installer. It asks for the staging folder location which we provide. Remember at this point the staging folder contains everything we need to be packaged in the installer.<\/li>\n<li><strong>install.xml<\/strong> &#8211; Notice how the jar elements are included. You MUST include all the jar files that you would need while running the installer.\n<pre lang=\"xml\" line=\"1\">\r\n <jar src=\"..\/wordpressinstaller-1.0-SNAPSHOT.jar\"\/>\r\n <jar src=\"mysql-connector-java-5.1.21.jar\"\/>\r\n<\/pre>\n<p>In our example we have included mysql-connector-java-5.1.21.jar (remember it&#8217;s in the same folder as install.xml, the staging folder) for access to mysql. We also included wordpressinstaller-1.0-SNAPSHOT.jar which actually had all the izpack related components. Since it goes in the target folder which is one hierarchy above the staging folder, we need to use &#8216;..\/&#8217;. Remember, whatever files we need while running the installer, we need to include using the jar element, just including them in the dependencies in pom is not enough.<\/p>\n<p>Add all the panels in order using the panels element. All these are inbuilt izpack panels. The userinput panels are specified within userInputSpec.xml. The MySqlDetails user input panel will be displayed only if the condition wordpress-izpack-installer.condition.dbinstallation is true (, when checkbox is checked).<\/p>\n<pre lang=\"xml\" line=\"1\">\r\n<panels>\r\n  <panel classname=\"HelloPanel\"\/>\r\n  <panel classname=\"PacksPanel\"\/>\r\n  <panel classname=\"TargetPanel\"\/>\r\n  <panel classname=\"UserInputPanel\" id=\"SpecifyWebServerDir\"\/>\r\n  <panel classname=\"UserInputPanel\" id=\"MySqlDetails\" condition=\"wordpress-izpack-installer.condition.dbinstallation\">\r\n    <validator classname=\"com.validators.MySQLAccessValidator\"\/>\r\n  <\/panel>\r\n  <panel classname=\"SummaryPanel\"\/>\r\n  <panel classname=\"InstallPanel\"\/>\r\n  <panel classname=\"ProcessPanel\"\/>\r\n  <panel classname=\"SimpleFinishPanel\"\/>\r\n<\/panels>\r\n<\/pre>\n<p>The packs panel displays a list of all the packs declared in the install.xml, in this case just one option of copying the wordpress source code will be displayed. The dir=&#8221;wordpress-src&#8221; is releative to the staging directory where we have copied the wordpress-src during our build process.<\/p>\n<pre lang=\"xml\" line=\"1\">\r\n<packs>\r\n  <pack name=\"Wordpress Sourcecode\" required=\"no\" >\r\n   <description>WordPress source code!<\/description>\r\n   <fileset dir=\"wordpress-src\" targetdir=\"${wordpress-izpack-installer.variable.wwwdir}\/${wordpress-izpack-installer.variable.wordpressfoldername}\" \/>\r\n  <\/pack>    \r\n<\/packs>\r\n<\/pre>\n<p>The <strong>InstallPanel<\/strong> actually copies all packs data to respective folders when installer is run. The <strong>ProcessPanel<\/strong> calls all the processes from the ProcessPanel.Spec.xml one after the other. Usually creating services, creating and running db scripts etc is done here. <strong>Validators<\/strong> are used to make sure users enter correct information while installation. We have added a MySQLAccessValidator to the panel, to validate the mysql connection when next is clicked. <a href=\"http:\/\/izpack.org\/documentation\/installation-files.html#validator-optional-validation-on-idata\">izPack documentation of validators<\/a>.<\/li>\n<li>When the standalone jar is built it literally packages everything within itself, all packs, all necessary jars (unpackaged) etc. Thus, while running you dont need to package anything else except that jar itself.\n<p><a href=\"https:\/\/www.softwareeverydayblog.com\/wp-content\/uploads\/2013\/01\/wordpressinstallerjar.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softwareeverydayblog.com\/wp-content\/uploads\/2013\/01\/wordpressinstallerjar-300x171.png\" alt=\"wordpressinstallerjar\" width=\"300\" height=\"171\" class=\"alignnone size-medium wp-image-641\" srcset=\"https:\/\/www.softwareeverydayblog.com\/wp-content\/uploads\/2013\/01\/wordpressinstallerjar-300x171.png 300w, https:\/\/www.softwareeverydayblog.com\/wp-content\/uploads\/2013\/01\/wordpressinstallerjar.png 875w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<\/ol>\n<p><strong>IzPack workflow on paper<\/strong>:-<\/p>\n<p><a href=\"https:\/\/www.softwareeverydayblog.com\/wp-content\/uploads\/2013\/01\/izpack-e1544903246108.jpeg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.softwareeverydayblog.com\/wp-content\/uploads\/2013\/01\/izpack-e1544903246108.jpeg\" alt=\"\" width=\"500\" height=\"439\" class=\"alignnone size-full wp-image-10760\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently created a wordpress installer using IzPack and uploaded the source code on Google Code. It will 1.) Download wordpress source code, 2.) copy wordpress folder into any directory (usually its the www directory) and 3.) Create an empty DB into MySql. For all practical purposes in doesn&#8217;t do much, however it was a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-606","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=\/wp\/v2\/posts\/606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=606"}],"version-history":[{"count":41,"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=\/wp\/v2\/posts\/606\/revisions"}],"predecessor-version":[{"id":10759,"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=\/wp\/v2\/posts\/606\/revisions\/10759"}],"wp:attachment":[{"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.softwareeverydayblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}