You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Maven POM中为两次插件执行设置不同的eclipse.svg.scale属性

解决Eclipse SVG渲染插件多DPI图标生成问题

我需要使用org.eclipse.images.renderer插件同时生成普通DPI(eclipse.svg.scale=1)和高DPI(eclipse.svg.scale=2)的PNG图标,其中高DPI渲染需额外设置eclipse.svg.createFragments=false避免生成独立文件夹。但当前POM通过properties-maven-plugin设置的系统属性会全局应用到两次插件执行中,导致生成的图标参数完全一致,无法区分版本。

解决方案

不需要依赖全局系统属性,直接在org.eclipse.images.renderer的每个执行节点(execution)中单独配置插件参数即可。该插件支持直接在<configuration>中定义scale、createFragments等参数,每个执行的配置相互独立,不会互相覆盖。

修改后的完整POM代码如下:

<?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>
          <!-- 普通DPI图标渲染 -->
          <execution>
            <id>normalDpi</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>render-icons</goal>
            </goals>
            <configuration>
              <sourceDirectory>${project.basedir}/svg</sourceDirectory>
              <targetDirectory>${images.output.folder}/images</targetDirectory>
              <scale>1</scale>
              <createFragments>true</createFragments>
            </configuration>
          </execution>
          <!-- 高DPI图标渲染 -->
          <execution>
            <id>highDpi</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>render-icons</goal>
            </goals>
            <configuration>
              <sourceDirectory>${project.basedir}/svg</sourceDirectory>
              <targetDirectory>${images.output.folder}/images</targetDirectory>
              <scale>2</scale>
              <createFragments>false</createFragments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

关键说明

  • 为每个执行节点添加唯一<id>,便于区分不同的渲染任务
  • 每个执行的<configuration>独立配置参数,互不干扰
  • 移除全局的properties-maven-plugin,避免系统属性全局生效导致的参数覆盖
  • 普通DPI渲染的createFragments可按需设置,高DPI版本按需求设为false

内容的提问来源于stack exchange,提问作者Ravi Bodla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 15:54:58