【发布时间】:2013-06-15 23:34:43
【问题描述】:
我正在尝试将属性文件中的属性读入我的父级pom.xml。从那里我需要将读取的属性放入我的 html 文件中定义的变量中。
包含属性文件的代码:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<executions>
<!-- Associate the read-project-properties goal with the initialize phase, to read the properties file. -->
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/build.${build.env}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<!-- Maven War file generator plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${basedir}/src/main/java</directory>
<targetPath>WEB-INF/classes</targetPath>
<includes>
<include>**/*.properties</include>
<filtering>false</filtering>
<include>**/*.xml</include>
<filtering>false</filtering>
<include>**/*.css</include>
<filtering>false</filtering>
<include>**/*.html</include>
<filtering>true</filtering>
</includes>
</resource>
</webResources>
</configuration>
<version>2.3</version>
</plugin>
<!-- Maven compiler plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<version>2.3</version>
</plugin>
</plugins>
我之前使用过 ant,我使用 filterset 标签来应用这些过滤器,例如
build.xml 中的代码:
<filterset>
<filter token="HOSTNAME_PREFIX" value="${hostname.prefix}"/>
<filter token="MIN_SUFFIX" value="${min.suffix}"/>
<filter token="APP_VERSION" value="${build.app.version}"/>
</filterset>
但我不知道如何使用 maven 实现相同的目标。
index.html 中要替换的代码是:
<link rel="shortcut icon" href="@HOSTNAME_PREFIX@appimages/app-logo.ico" type="image/png"/>
<link rel="stylesheet" href="@HOSTNAME_PREFIX@css/jquery.mobile-1.2.0@MIN_SUFFIX@.css" />
【问题讨论】:
标签: maven ant properties pom.xml