私はこのプロジェクトをできるだけシンプルにすることをやめました。私はmaven-echo-plugin を使用しています。このプロジェクトが行うのは、deluxe
のプロファイルがアクティブかどうかに応じて、特定のステートメントをエコーすることだけです。デラックスプロファイルを使用していない場合は、This is the base configuration
が印刷されます。デラックスプロファイルを使用している場合、プロジェクトはThis is the deluxe configuration
を出力します。私が実行した場合なぜ、子供のポンは正しいプロフィールを選んでいないのですか?
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>name.weintraub</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<profiles>
<profile>
<id>deluxe</id>
<activation>
<property>
<name>deluxe</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>maven-echo-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<goals>
<goal>echo</goal>
</goals>
<phase>validate</phase>
<configuration>
<echos>
<echo>This is the deluxe configuration</echo>
</echos>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>maven-echo-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<goals>
<goal>echo</goal>
</goals>
<phase>validate</phase>
<configuration>
<echos>
<echo>This is the base configuration</echo>
</echos>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
:
$ mvn validate
これはThis is the base configuration
を出力します
は、私は、次の親ポンポンを持っています。
私が実行している場合:
$ MVN -Pdeluxeこれは、これまでのところは良いThis is the deluxe configuration
を出力します
を検証:
私は今、子供のポンポンを作成します。
<?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>
<properties>
<deluxe>true</deluxe>
</properties>
<parent>
<groupId>name.weintraub</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
</parent>
<groupId>name.weintraub</groupId>
<artifactId>foo</artifactId>
<version>1.0.0</version>
</project>
プロパティを設定したことに注意してください。pomの先頭の〜true
。
私が実行します。
$ mvn validate
それはThis is the base configuration
を出力します。
私はこのようにそれを実行した場合:
mvn -Ddeluxe=true validate
それは、その後This is the deluxe configuration
を印刷します。私がしている場合
mvn -Pdeluxe validate
それはThis is the deluxe configuration
を印刷します。
私は子供の親が親のプロファイルを選んでいることがわかります。また、コマンドラインで直接プロファイルを使用するか、プロパティを使用してプロファイルをアクティブにするとわかります。しかし、私はpom自体のプロパティを設定しても、私のプロジェクトは、親のプロファイルをピックアップしていないようです。
なぜですか?
私は、Mavenの中央での最新バージョンですので、バージョン0.1を使用していて、これは、それは、バージョン1.0でmaven-echo-plugin
バックと呼ばれていました。そうでない場合のドキュメンテーションは同じです。
まず[エコーのmaven-pluginの]の新しいバージョンがあります( http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.soebes.maven.plugins%22%20AND%20a%3A%22echo-maven-plugin%22)名前が変更されました...子にプロパティを設定した場合、親は既に読み込まれて解析されており、プロファイルはアクティブ化されているかどうかは... – khmarbaise
BTW:質問の背後にあるアイデアは何ですか? – khmarbaise
@khmarbaiseはいプラグインの名前が変更されていることは分かっていますが、Maven Centralでそれ以降のバージョンを見つけることができず、古いバージョンがこの目的には十分であると考えましたe。 –