1

次のエラーが表示されます。設定されていないからinstall_pathでしょうか?もしそうなら、プロファイルを使用するとき、デフォルトのプラグインが実行されていないことを意味しますか (を設定するプラグインinstall_path)?

実行:

mvn clean install site -Pfull

エラー:

プロジェクト bo-full でゴール org.apache.maven.plugins:maven-clean-plugin:2.5:clean (clean-deploy-folder) を実行できませんでした: ファイル セットのベース ディレクトリがありません: null (含まれる: []、除外される: [])

:

<project>
    <plugins>
        <plugin>
            <!-- Workaround maven not being able to set a property conditionally based on environment variable -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <exportAntProperties>true</exportAntProperties>
                        <target>
                            <property environment="env"/>
                            <condition property="install.path" value="${env.SERVER_HOME}" else="C:\MY_SERVER">
                                <isset property="env.SERVER_HOME" />
                            </condition>
                            <echo message="${install.path}"/>
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
...

子供:

<project>
    <profiles>
        <profile>
            <id>full</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>clean-deploy-folder</id>
                                <phase>pre-site</phase>
                                <goals>
                                    <goal>clean</goal>
                                </goals>
                                <configuration>
                                    <excludeDefaultDirectories>true</excludeDefaultDirectories>
                                    <filesets>
                                        <fileset>
                                            <directory>${install.path}</directory>
                                        </fileset>
                                    </filesets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
...
4

1 に答える 1

0

1) プロファイルを使用する場合でも、デフォルトのプラグインを実行する必要があります。ビルド ログに従って、これが発生していることを確認してください。プラグイン自体が何もログに記録しない場合でも、すべてのプラグインの実行は maven によって記録されます。

2) プロパティを作成する実行と同じ Maven プロジェクト/モジュールでクリーンアップの実行を維持する必要があります。理由の 1 つは、子モジュールを個別にビルドできることです (利用可能な場合は、ローカル/リモート リポジトリの親 pom.xml を使用します)。何らかの理由で、リアクター ビルド内でプロパティが適切に伝播されない可能性もあります。

3)問題が実際にプロパティの伝播であり、antrun プラグインに問題がある場合は、antrun の実行を Maven プロファイルに置き換えることができます。次のようになります。

<properties>
  <!-- default value goes here: -->
  <install.path>C:\MY_SERVER</install.path>
</properties>

<profiles>
  <profile>
    <id>env</id>
    <activation>
      <property>
        <!-- activate this profile when property is specified: -->
        <name>env.SERVER_HOME</name>
      </property>
    </activation>
    <properties>
      <!-- override default property value: -->
      <install.path>${env.SERVER_HOME}</install.path>
    </properties>
  </profile>
</profiles>
于 2016-05-23T12:52:45.010 に答える