Ravi Bodla
Ravi Bodla

Reputation: 11

overwrite set system properties at runtime in maven pom

I am using org.eclipse.images.renderer plugin to render my images from svg to png. Eclipse has provided support to create highDpi icons as well which requires 2 more arguments to be passed eclipse.svg.scale=2 and eclipse.svg.createFragments=false (to not create separate folder). I want to render both normal icons and high-dpi icons both through my pom, but giving those 2 arguments overwrite my configurations and hence for both the executions I get the same type of icons. Is there any way to overwrite the eclipse.svg.scale property to use 1 for one execution and 2 for the second execution. Attaching my POM for reference:

In my POM I have added 2 execution items to render icons and used properties-maven-plugin plugin to set the set-system-properties for setting the properties. But these properties are being set to both the executions.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.provar.tycho</groupId>
    <artifactId>com.provar.tycho.root</artifactId>
    <version>1.230.0</version>
  </parent>

  <groupId>com.provar.images</groupId>
  <artifactId>com.provar.images</artifactId>
  <version>2.260.0.0</version>
  <packaging>eclipse-plugin</packaging>

  <name>Provar Image Library</name>
  <description>Provar image library and conversion tools</description>

  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.images</groupId>
        <artifactId>org.eclipse.images.renderer</artifactId>
        <version>1.0.100-SNAPSHOT</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>render-icons</goal>
            </goals>
          </execution>
          <execution>
            <id>highDpi</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>render-icons</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0.0</version>
        <executions>
          <execution>
            <!-- any phase before your app deploys -->
            <phase>initialize</phase>
            <goals>
              <goal>set-system-properties</goal>
            </goals>
            <configuration>
              <properties>
                <property>
                  <name>eclipse.svg.sourcedirectory</name>
                  <value>${project.basedir}/svg</value>
                </property>
                <property>
                  <name>eclipse.svg.targetdirectory</name>
                  <value>${images.output.folder}/images</value>
                </property>
                <property>
                    <name>eclipse.svg.scale</name>
                    <value>2</value>
                </property>
                <property>
                    <name>eclipse.svg.createFragments</name>
                    <value>false</value>
                </property>
              </properties>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

I want to use the eclipse.svg.scale property as 1 for one execution and as 2 for second execution. Is it possible to be done by configuring the POM itself. Please help.

Upvotes: 0

Views: 70

Answers (1)

vikingsteve
vikingsteve

Reputation: 40388

You can use a maven "profile" to control specific executions.

Maven Profiles Documentation

Set up your project with 2 profiles, let's say svgscale1 and svgscale2

Then you invoke the maven build like this:

mvn clean install -Psvgscale1
mvn clean install -Psvgscale2

Upvotes: 0

Related Questions