[izpack-dev] izpack-maven-plugin and resources

342 views
Skip to first unread message

Nicolas Monchy

unread,
May 3, 2013, 5:04:14 AM5/3/13
to d...@izpack.codehaus.org
Hi everyone,

I would like to have your opinion on a new feature about resources for the izpack-maven-plugin.

The simple rule employed by Maven is this: any directories or files placed within the ${basedir}/src/main/resources directory are packaged in your JAR.
But this doesn't seem to work with izpack-maven-plugin. And it would be great if I could add jars and properties file into my installer jar.

I can of course work on the code, but I wanted to have your opinion first since I'm new to Izpack.

Thank you !

Ron Wheeler

unread,
May 3, 2013, 10:11:51 AM5/3/13
to d...@izpack.codehaus.org, Nicolas Monchy
Do you want to install these files or are they required to support your
custom panels?

Both of these are already supported.

Try to restate your question.
I am also new but am working on the docs to try to get them more useful
to someone like me who knows nothing about the izPack code.


Ron
--
Ron Wheeler
President
Artifact Software Inc
email: rwhe...@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Paul Bors

unread,
May 3, 2013, 12:25:55 PM5/3/13
to d...@izpack.codehaus.org
You can always do so by configuring the izpack-maven-plugin:
<!-- mvn help:describe -DgroupId=org.codehaus.izpack
-DartifactId=izpack-maven-plugin -Dversion=5.0.0-beta11 -Ddetail -->
<configuration>
<installFile>${staging.dir}/install.xml</installFile>
<attach>false</attach>
<kind>standard</kind>
<descriptorEncoding>UTF-8</descriptorEncoding>
<izpackBasedir>${staging.dir}</izpackBasedir>
<customPanelDirectory>${staging.dir}</customPanelDirectory>
</configuration>

This is part of my installer's POM which packages GlassFish and my own war.
I have a utility class that during installation it configures glassfish and
deploys the war.

<properties>
<!-- IzPack configuration (also substituted in the descriptor) -->
<staging.dir>${project.build.directory}/staging</staging.dir>
<events.dir>${staging.dir}/custom</events.dir>
<panels.dir>${staging.dir}/custom</panels.dir>
</properties>

<!--
Dependencies we need in the installer. Those are copied to
${staging.dir} but they are not
magically added to the installer.

We need to move them to the correct place via maven-antrun-plugin and
then add the
corresponding jar entry to the installer descriptor.
See:
http://izpack.org/documentation/installation-files.html#the-jar-merging-elem
ent-jar
-->
<dependencies>
<!-- COMPILE dependencies (jar stage = both) -->
...
<dependency>
<groupId>com.myorg</groupId>
<artifactId>my-war</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.glassfish.main.distributions</groupId>
<artifactId>glassfish</artifactId>
<version>${glassfishVersion}</version>
<type>zip</type>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>cli-optional</artifactId>
<groupId>org.glassfish.main.admin</groupId>
</exclusion>
<exclusion>
<artifactId>server-mgmt</artifactId>
<groupId>org.glassfish.main.admin</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- RUNTIME dependencies (jar stage = install) -->
...
<!-- TEST dependencies -->
...
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
<!-- Turn on filtering. -->
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/izpack</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.gif</exclude>
<exclude>**/*.ico</exclude>
</excludes>
</resource>
</resources>
<pluginManagement>
<plugins>
<!-- Do not install this artifact to the local repository. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<!-- Do not deploy this artifact to the remote repository. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- Configure the compiler to use Java 1.5 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<!-- Have project dependencies be picked up by izPack when its
compiler runs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
<outputDirectory>${staging.dir}/dependency</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<!-- this excludes tools.jar, e.g. -->
<excludeScope>system</excludeScope>
<!-- Don't copy custom panels or events where our application
jars live -->

<excludeArtifactIds>my-installer-panels,my-installer-event</excludeArtifactI
ds>
<!-- Filter out what we don't want inside the installer (stand
alone compiler, Wicket, sprint, etc.) -->

<excludeGroupIds>org.codehaus.izpack,org.apache.wicket,org.springframework</
excludeGroupIds>
</configuration>
</execution>
<execution>
<!-- copy izpack custom (custom panels, etc.) jars to izpack
staging custom -->
<id>copy-izpack-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${staging.dir}/custom</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>true</stripVersion>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<!-- This causes *only* our custom panels to be copied -->

<includeArtifactIds>my-console-installer-panels,my-console-installer-event</
includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
<!-- Copy other checked and filtered resource into staging area -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>${mavenAntrunPluginVersion}</version>
<executions>
<execution>
<id>create-staging-area</id>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy todir="${staging.dir}" overwrite="true"
verbose="true">
<fileset dir="${basedir}/src/main/izpack" />
</copy>
<copy todir="${staging.dir}" overwrite="true"
verbose="true">
<fileset dir="${basedir}/target/classes" />
</copy>
<!-- Obtain fresh copy of GlassFish and patch it as needed
-->
<unzip src="${staging.dir}/dependency/glassfish.zip"
dest="${staging.dir}" />
<delete verbose="true">
<fileset dir="${staging.dir}/dependency"
includes="**/glassfish.zip" />
</delete>
<move file="${staging.dir}/glassfish3"
toFile="${staging.dir}/glassfish" />
<move file="${staging.dir}/dependency/ojdbc6.jar"
toFile="${staging.dir}/drivers/ojdbc6-${ojdbcVersion}.jar" />
<move file="${staging.dir}/dependency/jtds.jar"
toFile="${staging.dir}/drivers/jtds-${jtdsVersion}.jar" />
<move file="${staging.dir}/dependency/ntlmauth.dll"
tofile="${staging.dir}/glassfish/lib/ntlmauth.dll" />
<move file="${staging.dir}/dependency/ntlmauth64.dll"
tofile="${staging.dir}/glassfish/lib/ntlmauth64.dll" />
<move
file="${staging.dir}/dependency/hibernate-jpa-2.0-api.jar"
tofile="${staging.dir}/glassfish/lib/endorsed/hibernate-jpa-2.0-api.jar" />
<move file="${staging.dir}/dependency/my-console-war.war"
tofile="${staging.dir}/my.war" />
<delete verbose="true">
<!-- Keep only files that will be merged into the
Installer -->
<fileset dir="${staging.dir}/dependency"
includes="**"
excludes="**/my-console-util.jar, **/my-commons.jar,
**/log4j.jar"
/>
</delete>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-maven-plugin</artifactId>
<version>${izpackVersion}</version>
<dependencies>
<dependency>
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-panel</artifactId>
<version>${izpackVersion}</version>
</dependency>
<dependency>
<groupId>com.myorg</groupId>
<artifactId>my-console-installer-panels</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.myorg</groupId>
<artifactId>my-console-installer-event</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<!-- mvn help:describe -DgroupId=org.codehaus.izpack
-DartifactId=izpack-maven-plugin -Dversion=5.0.0-beta11 -Ddetail -->
<configuration>
<installFile>${staging.dir}/install.xml</installFile>
<attach>false</attach>
<kind>standard</kind>
<descriptorEncoding>UTF-8</descriptorEncoding>
<izpackBasedir>${staging.dir}</izpackBasedir>
<customPanelDirectory>${staging.dir}</customPanelDirectory>
</configuration>
<executions>
<execution>
<id>standard-installer</id>
<phase>package</phase>
<goals>
<goal>izpack</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Do not deploy any of the installer artifacts. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${mavenDeployPluginVersion}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

Nicolas Monchy

unread,
May 7, 2013, 5:55:01 AM5/7/13
to d...@izpack.codehaus.org
Thank you for your answers :)

Indeed the jar merging element <jar> is enough to import my external jar.
But I would still appreciate that the files placed within the ${basedir}/src/main/resources directory are packaged in the installer JAR so I would be able to add a properties file.

To explain my situation :
I have 2  Maven projects

db-management -> db-management.jar
installer -> installer.jar

installer project imports db-management.jar, merge it with install.xml <jar> markup.
And db-management.jar needs properties only known by installer project so I want to add a database.properties file in the root of installer.jar :

installer.jar
    |__com
        |__mywebsite/.../DbManagement.class
        |__izpack/...
    |__database.properties
    |__resources
    |__META-INF

Then, during the processPanel, the DbManagement class would load and use database.properties file.

This feature would be a way to add what we want in our installer.jar without any change in the install.xml and its <resources> markup.

René Krell

unread,
May 7, 2013, 6:24:53 AM5/7/13
to IzPack developer mailings
You can add your properties file in a jar file as resource, maybe assembling it in Maven before as resource jar and loading it in your code as resource. This would be the more general way and this is the way how there are loaded settings for instance in Java Webstart.

In fact, plain file resources are currently just imported for Izpack-internal purposes, see http://docs.codehaus.org/display/IZPACK/Resources.
Those resources are packaged into the installer jar under /resources/ and might be loaded from there as resource, but I'v never tried it.
Even if we'd add a plain resource file you must load it using the classloader from the installer jar, not from the filesystem.

I'm not sure, whether this is a necessary feature, because there is the cleaner way of packaging plain files into resource jars, but you might raise an issue (wish) for it. Maybe someone contributes some clever piece of code for it. Nevertheless, IMHO I'd not add new features to 5.0 now, but get rather around with the existing open bugs and release as soon as possible. But this is of course subject to be discussed.

René


2013/5/7 Nicolas Monchy <nicolas...@gmail.com>

Nicolas Monchy

unread,
May 14, 2013, 3:55:09 AM5/14/13
to d...@izpack.codehaus.org
I can't add my properties file in my database-management.jar as resource because database-management.jar is unpacked in installer.jar with the <jar> markup.

But I finally found a workaround : once installer.jar is packaged by izpack-maven-plugin, I add database.properties with maven-antrun-plugin "jar uf ${project.build.directory}/${project.build.finalName}.jar -C ${staging.dir} database.properties"

So I won't developp the "resource package feature" for the moment.

Thank you for your help !
Reply all
Reply to author
Forward
0 new messages