4

構成内のリストを取得するプラグインがあります。

<build>
  <plugins>
    <plugin>
      <groupId>com.example</grouId>
      <artifactId>fictional-plugin</artifactId>
      <configuration>
        <fictionalSet>
          <setItem>First</setItem>
          <setItem>Second</setItem>
          <setItem>Third</setItem>
        </fictionalSet>
  ...
</build>

の内容は<fictionalSet>、現在のプロファイルに基づいて変更されます。現在、プロファイル内でプラグイン定義を複製していますが、これは少し無駄に感じます。私が本当にしたいのは、アイテムのセットをプロパティとして定義することです:

<properties>
  <fictional.set.items>
    <setItem>First</setItem>
    <setItem>Second</setItem> 
 ...
</properties>

ただし、上記を試みると、Maven からエラーが発生します。

[ERROR]     Non-parseable POM <path>/pom.xml: TEXT must be immediately followed 
by END_TAG and not START_TAG (position: START_TAG seen ...
<fictional.set.items>\r\n\t\t\t<setItem>... @37:13)  @ line 37, column 13

リストをMavenプロパティからプラグイン構成に渡す方法はありますか?

4

1 に答える 1

0

Maven doesn't support any sort of list or way to store several properties/tags inside one tag. However, you don't need to duplicate the plugin configuration, you can just move it entirely into the profiles and not have it defined in the main pom at all (alternate: still remove it from the main pom but make an activeByDefault profile which has the default plugin configuration). As maven doesn't bother parsing inactive profiles the duplicate code shouldn't cause any performance problems.

于 2012-05-31T22:17:33.137 に答える