0

EclipseでMavenのプロパティを表示するには?

antrun プラグインに基づく以下の pom は機能しません。

<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>
    <groupId>Test_DisplayMavenVariables</groupId>
    <artifactId>Test_DisplayMavenVariables</artifactId>
    <version>0.0.1-SNAPSHOT</version>


    <properties>
        <testproperty>This is a test property</testproperty>
    </properties>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <phase>validate</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <tasks>
                                    <echo>Displaying value of 'testproperty' property</echo>
                                    <echo>[testproperty] ${testproperty}</echo>
                                </tasks>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

アップデート

目標「検証」まで実行した場合、出力は次のようになります。

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Test_DisplayMavenVariables 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.110s
[INFO] Finished at: Sun Mar 23 15:22:00 MSK 2014
[INFO] Final Memory: 4M/183M
[INFO] ------------------------------------------------------------------------
4

1 に答える 1

1

ブロックantrun内に定義を入れました。pluginManagement

pluginManagement意味: 「誰かがこのプラグインを使用する場合、彼は次のようにします...」

あなたの例では、通常のプラグイン定義がないため、誰もプラグインを使用していません。pom からand を削除する<pluginManagement>と、機能します。</pluginManagement>

于 2014-03-23T12:06:19.970 に答える