0

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 を実行したときです...プロファイルプロパティなしで pom から取得されます。プロファイルを使用する場合は、構成ファイルのプロパティを使用する必要があります。これは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 でサポートされていないということですか?

4

1 に答える 1

0

Maven 2 から Maven 3 に移行する場合は注意してください。Maven 2 は起動時にすべての依存関係をロードし、Maven 3 はそれらをオンデマンドでロードするためです。そのため、Maven 3 で動作するビルドは、Maven 2 を実行するビルド ボックスでは壊れます。

于 2013-07-11T20:00:42.997 に答える