D.2. プラグインのプロジェクトへの追加
プラグインを有効にするには、以下を pom.xml
ファイルに追加します。
<plugin> <groupId>io.fabric8.forge</groupId> <artifactId>fabric8-camel-maven-plugin</artifactId> <version>2.3.90</version> </plugin>
<plugin>
<groupId>io.fabric8.forge</groupId>
<artifactId>fabric8-camel-maven-plugin</artifactId>
<version>2.3.90</version>
</plugin>
注記:
fabric8-forge リリースの現在のバージョン番号を確認してください。最新のリリースは https://github.com/fabric8io/fabric8-forge/releases
にあります。
ただし、ゴールの検証はコマンドラインまたは IDEA や Eclipse などの Java エディターから実行できます。
mvn fabric8-camel:validate
mvn fabric8-camel:validate
プラグインを有効にしてビルドの一部として自動的に実行し、エラーを検出することも可能です。
<plugin> <groupId>io.fabric8.forge</groupId> <artifactId>fabric8-camel-maven-plugin</artifactId> <version>2.3.80</version> <executions> <execution> <phase>process-classes</phase> <goals> <goal>validate</goal> </goals> </execution> </executions> </plugin>
<plugin>
<groupId>io.fabric8.forge</groupId>
<artifactId>fabric8-camel-maven-plugin</artifactId>
<version>2.3.80</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
フェーズはプラグインが実行されるタイミングを決定します。上記の例では、メインのソースコードの完了後に実行される process-classes
がフェーズです。
Maven プラグインを設定して、テストソースコードを検証することもできます。以下のように process-test-classes
のとおりにフェーズを変更します。
<plugin> <groupId>io.fabric8.forge</groupId> <artifactId>fabric8-camel-maven-plugin</artifactId> <version>2.3.80</version> <executions> <execution> <configuration> <includeTest>true</includeTest> </configuration> <phase>process-test-classes</phase> <goals> <goal>validate</goal> </goals> </execution> </executions> </plugin>
<plugin>
<groupId>io.fabric8.forge</groupId>
<artifactId>fabric8-camel-maven-plugin</artifactId>
<version>2.3.80</version>
<executions>
<execution>
<configuration>
<includeTest>true</includeTest>
</configuration>
<phase>process-test-classes</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>