{"id":442,"date":"2012-08-08T09:27:16","date_gmt":"2012-08-08T07:27:16","guid":{"rendered":"http:\/\/www.pellissier.co.za\/hermien\/?p=442"},"modified":"2013-02-10T08:54:05","modified_gmt":"2013-02-10T06:54:05","slug":"migrating-my-mind-to-maven-part-6-customising-the-installers","status":"publish","type":"post","link":"https:\/\/www.pellissier.co.za\/hermien\/?p=442","title":{"rendered":"Migrating my Mind to Maven (Part 6) &#8211; Customising the Installers"},"content":{"rendered":"<p>The nbm:build-installers Maven goal allows you to build the platform application installers using Maven, as I wrote about in an <a href=\"http:\/\/www.pellissier.co.za\/hermien\/?p=301\">earlier blog post<\/a>. Yesterday I decided to investigate how to configure the installer when building it using that goal.<\/p>\n<p>The first thing that can be customised is which platform(s) to create installers for. This can be configured in the IDE from the application project&#8217;s properties, under the Build &gt; Installer category. I chose to build an installer only for Windows. And when I looked at the pom.xml for the application project, I found the following:<\/p>\n<p>[xml]<plugin>\n    <groupId>org.codehaus.mojo<\/groupId><br \/>\n    <artifactId>nbm-maven-plugin<\/artifactId><br \/>\n    <configuration><br \/>\n        <installerOsLinux>false<\/installerOsLinux><br \/>\n        <installerOsMacosx>false<\/installerOsMacosx><br \/>\n        <installerOsSolaris>false<\/installerOsSolaris><br \/>\n    <\/configuration>\n<\/plugin>[\/xml]<\/p>\n<p>Looking at [1] (see Useful References below), we see that there are a number of other properties that can be set in addition to those now set by the IDE. This includes the parameters that get passed to the template.xml file via the userSettings property. To understand what this actually means, run the nbm:build-installers goal and have a look at the target folder of the application. In the folder targetinstallernbistub you will see the file template.xml. It is the ant script that will get executed during the process of building the installer. And that is the script that the properties get passed to.<\/p>\n<p>The first useful thing is setting the icon that is displayed in the installer when it is running (see also [2]). After adding the icon, the same section in the pom.xml now looks like this:<\/p>\n<p>[xml]<plugin>\n    <groupId>org.codehaus.mojo<\/groupId><br \/>\n    <artifactId>nbm-maven-plugin<\/artifactId><br \/>\n    <configuration><br \/>\n        <installerOsSolaris>false<\/installerOsSolaris><br \/>\n        <installerOsMacosx>false<\/installerOsMacosx><br \/>\n        <installerOsLinux>false<\/installerOsLinux><br \/>\n        <userSettings><br \/>\n            <nbi.icon.file>${basedir}\/src\/resources\/icon.png<\/nbi.icon.file><br \/>\n        <\/userSettings><br \/>\n    <\/configuration>\n<\/plugin>[\/xml]<\/p>\n<p>However you will most likely not want to stop at the icon, but also change all the other images in the installer (see [4]). The template.xml provided with NetBeans 7.2 does not allow this out of the box. But the changes are simple (see [3] for some info towards the bottom of the page and also [5] as an example of a template.xml). First lets add a new property called nbi.instleftcorner.file that will specify the location of the image to be displayed at the top left of most of the installer wizard pages.<\/p>\n<p>[xml]<plugin>\n    <groupId>org.codehaus.mojo<\/groupId><br \/>\n    <artifactId>nbm-maven-plugin<\/artifactId><br \/>\n    <configuration><br \/>\n        <installerOsSolaris>false<\/installerOsSolaris><br \/>\n        <installerOsMacosx>false<\/installerOsMacosx><br \/>\n        <installerOsLinux>false<\/installerOsLinux><br \/>\n        <userSettings><br \/>\n            <nbi.icon.file>${basedir}\/src\/resources\/icon.png<\/nbi.icon.file><br \/>\n            <nbi.instleftcorner.file>${basedir}\/src\/resources\/left.png<\/nbi.instleftcorner.file><br \/>\n        <\/userSettings><br \/>\n    <\/configuration>\n<\/plugin>[\/xml]<\/p>\n<p>Then we create a copy of the template.xml file and specify the templateFile property in the pom.xml:<\/p>\n<p>[xml]<plugin>\n    <groupId>org.codehaus.mojo<\/groupId><br \/>\n    <artifactId>nbm-maven-plugin<\/artifactId><br \/>\n    <configuration><br \/>\n        <installerOsSolaris>false<\/installerOsSolaris><br \/>\n        <installerOsMacosx>false<\/installerOsMacosx><br \/>\n        <installerOsLinux>false<\/installerOsLinux><br \/>\n        <templateFile>${basedir}\/src\/resources\/template.xml<\/templateFile><br \/>\n        <userSettings><br \/>\n            <nbi.icon.file>${basedir}\/src\/resources\/icon.png<\/nbi.icon.file><br \/>\n            <nbi.instleftcorner.file>${basedir}\/src\/resources\/left.png<\/nbi.instleftcorner.file><br \/>\n        <\/userSettings><br \/>\n    <\/configuration>\n<\/plugin>[\/xml]<\/p>\n<p>The final part of the puzzle is changing the template.xml file to also copy the new file (see [5] again for a more complete example). As a quick fix, I just added the following<\/p>\n<p>[xml]<copy file=\"${nbi.instleftcorner.file}\"\n    tofile=\"${installer.build.dir}\/ext\/engine\/src\/org\/mycompany\/installer\/wizard\/wizard-description-background-left.png\"\n    overwrite=\"true\"\/>[\/xml]<\/p>\n<p>to the -prepare-icon target. Now when the nbm:build-installers goal is executed, the custom template.xml is copied including this change and the wizard-description-background-left.png image will be replaced before the installer gets built. The same can be done for any of the images. \ud83d\ude42<\/p>\n<p><b>Useful References<\/b><\/p>\n<ol>\n<li><a href=\"http:\/\/mojo.codehaus.org\/nbm-maven\/nbm-maven-plugin\/build-installers-mojo.html\">NBM Maven Plugin documentation<\/a><\/li>\n<li><a href=\"http:\/\/java.net\/projects\/agrosense\/pages\/DevFAQCreateInstallers\">Developers FAQ Create Installers<\/a><\/li>\n<li><a href=\"http:\/\/old.nabble.com\/-jira--(MNBMODULE-155)-Build-installers-goal-proposal-td33052364.html\">JIRA Build installers goal proposal<\/a><\/li>\n<li><a href=\"https:\/\/blogs.oracle.com\/geertjan\/entry\/customizing_the_netbeans_platform_installer\">Geertjan&#8217;s Blog: Customizing the NetBeans Platform Installer<\/a><\/li>\n<li><a href=\"http:\/\/osm2garmin.googlecode.com\/svn\/trunk\/template.xml\">template.xml from osm2garmin<\/a><\/li>\n<\/ol>\n<p><strong>Edit (4 October 2012):<\/strong> Another useful resource:<\/p>\n<ul>\n<li><a href=\"http:\/\/mojo.codehaus.org\/nbm-maven\/nbm-maven-plugin\/buildinstexample.html\">HOWTO: Customize installers generated by nbm:build-installers<\/a><\/li>\n<\/ul>\n<p><strong>Edit (1 February 2013):<\/strong> Timon Veenstra of <a href=\"http:\/\/www.agrosense.eu\/\">AgroSense<\/a> provided the following additional very useful information:<\/p>\n<p>&#8220;If you want to adjust only the installation folder for windows, you will need to copy the default template.xml and adjust this part:<\/p>\n<p>[xml]<replacefilter token=\"{product-install-directory-name}\"         \n        value=\"${suite.props.app.installdir}\"\/><br \/>\n<replacefilter token=\"{product-install-directory-name-windows}\" \n        value=\"${suite.props.app.installdir}\"\/><br \/>\n<replacefilter token=\"{product-install-directory-name-macosx}\"  \n        value=\"${suite.props.app.installdir}\"\/>[\/xml]<\/p>\n<p>If you want to adjust all of them, you could change your branding token. But beware that the branding token should be the same as the parent artifactId (without -_[0-9]).&#8221;<\/p>\n<p>Also read Timon&#8217;s article entitled <a href=\"http:\/\/netbeans.dzone.com\/articles\/change-your-netbeans\">How to Change a NetBeans Platform Executable Icon with Maven<\/a> for more valuable information!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The nbm:build-installers Maven goal allows you to build the platform application installers using Maven, as I wrote about in an earlier blog post. Yesterday I decided to investigate how to configure the installer when building it using that goal. The first thing that can be customised is which platform(s) to create installers for. This can &#8230; <a title=\"Migrating my Mind to Maven (Part 6) &#8211; Customising the Installers\" class=\"read-more\" href=\"https:\/\/www.pellissier.co.za\/hermien\/?p=442\" aria-label=\"More on Migrating my Mind to Maven (Part 6) &#8211; Customising the Installers\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[2,3,5],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1v8WL-78","_links":{"self":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/442"}],"collection":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=442"}],"version-history":[{"count":2,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/442\/revisions"}],"predecessor-version":[{"id":679,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/442\/revisions\/679"}],"wp:attachment":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}