开发者

How can I use Maven project properties in izpack-maven-plugin install.xml?

开发者 https://www.devze.com 2023-02-13 19:13 出处:网络
Following http://maksim.sorokin.dk/it/2010/06/10/izpack-with-maven/ I wrote a Maven POM which creates an IzPack installer, using the izpack-maven-plugin.

Following http://maksim.sorokin.dk/it/2010/06/10/izpack-with-maven/ I wrote a Maven POM which creates an IzPack installer, using the izpack-maven-plugin.

However I found now way to pass plugin configuration parameters such as the artifact name and version to the install.xml file. Is there a way to pass these values from the POM to the plugin?

Example:

In the src/main/resources/install.xml:

<installation version="1.0">
<info>
  <appname>MyApp</appname>
  <appversion>1.0.0</appversion>
</info>
...

How can I use 开发者_运维百科the Maven properties, project.name and project.version here, so it looks like:

<installation version="1.0">
<info>
  <appname>${project.name}</appname>
  <appversion>${project.version}</appversion>
</info>
...


I know this question is really old, but this was consistently the question that came up in searches when I was trying to figure out how to get the appversion in IzPack to be automatically pulled from the POM project version.

The right approach to this is to set a Maven Property in your POM and reference the property in the IzPack install.xml using the @{property} syntax. No filtering of resources needed.

pom.xml:

...
<properties>
    <myproduct.name>${project.name}</myproduct.name>
    <myproduct.version>${project.version}</myproduct.version>
</properties>
...

install.xml:

...
<info>
    <appname>@{myproduct.name}</appname>
    <appversion>@{myproduct.version}</appversion>
...

IzPack Properties documentation


Your maven-resources-plugin invocation can filter the resources involved using project properties defined in the pom itself, or better using a properties file. maven-resources-plugin usage

<build>
...
  <filters>
     <filter> [a filter property or properties file] </filter>
  </filters>
...
  <plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.2</version>
    ...
          <resources>
            <resource>
              <directory>src/main/resources</directory>
              <filtering>true</filtering>
            </resource>
          </resources>
     ...
  </plugin>
</build>

A filter property has this syntax in the pom:

<properties>
  <your.name>world</your.name>
</properties>

meaning "your.name" property has "world" value.

If you specify a properties file in src/main/resources:

your.name=world

and then indicate the filename in the <filter> element in the pom.

0

精彩评论

暂无评论...
验证码 换一张
取 消