【发布时间】:2013-07-12 04:00:42
【问题描述】:
当我升级 maven 时,属性插件有问题:
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
在我的 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>...</artifactId>
<groupId>...</groupId>
<packaging>war</packaging>
<version>1.0.10-SNAPSHOT</version>
<name>...</name>
<properties>
<!-- application -->
<appname>appname1</appname>
</properties>
<build>
... // here I dont have properties plugin because I dont need them
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>${appname}</warName> // here is stil name in pom
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
</resource>
</webResources>
</configuration>
</plugin>
...
</build>
<profiles>
<profile>
<id>config</id>
<activation>
<property>
<name>config</name>
</property>
</activation>
<properties>
<config>${basedir}/../config/${config}/build.properties</config>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${config}</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
...
</dependencies>
</project>
然后我有个人资料:
<profile>
<id>config</id>
<activation>
<property>
<name>config</name>
</property>
</activation>
<properties>
<konfig>${basedir}/../config/${config}/build.properties</konfig>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${konfig}</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
我可以在其中指定另一个具有属性的文件:
文件包含:
appname=appname2
所以当我运行 mvn 时,logis 是从 pom.xml 获取的。如果使用配置文件,它应该使用配置文件中的属性。这适用于 maven 2,但 maven 3 仍然从 pom 获取属性。有办法解决吗?
这里:http://mojo.codehaus.org/properties-maven-plugin/read-project-properties-mojo.html 是这样写的:
属性:
Requires a Maven 2.0 project to be executed.
表示maven 3不支持这个插件?
【问题讨论】:
-
你能显示完整的 pom,因为我怀疑这是基于 properties-maven-plugin。
-
我无法显示整个 pom,但我对其进行了编辑并仅显示重要部分。有趣的是,当我从 pom 中删除属性时它可以工作,所以重写属性只是有问题
-
我已经用 maven 3.0.3 进行了检查,它运行良好。你可以发布 pom 文件吗...
-
我使用的是 3.0.4。我只是发布pom。你没看到?
-
你想设置什么样的属性查看build.properties?
标签: maven