これが私が直面している状況です。現在、2 つの Maven プロジェクトがあります。1 つは依存関係、リポジトリなどを記述することだけを行います (親)、もう 1 つは pom.xml を継承する子です。子と同じモデルに従って、将来さらに多くのモジュールが作成される予定です。
プロジェクトのサイト (maven-site-plugin で生成) を、現時点ではsftp経由でのみアクセスできる場所にデプロイすることにしました。また、sftp プロトコルを統合できなかったため、サイトの場所を定義することが不可能であることがわかりました<distributionManagement>
(wagon-ssh-external を使用してみました)。
その結果、リモート マシンに接続し、サイト展開フェーズでサイトが展開されているローカル フォルダーの内容をアップロードするスクリプトを作成しました。
echo "Uploading the site.."
lftp -u ${username},${password} sftp://${host} <<EOF
mirror -R --delete-first $sitedir $remotedir
echo "Exiting from lftp.."
bye
EOF
echo "Terminating script execution.."
これは親サイトでは完全に機能し、ローカルで作成された直後にサイトをアップロードしますが、子がスクリプトの最後に到達すると、正しく終了せず、印刷さTerminating script execution..
れてそこにとどまります。
デフォルトの Maven プラグイン (v. 3.0.2) を備えた最新バージョン (3.7) の Eclipse を使用しています。Eclipse でサイトを生成してデプロイするために、親プロジェクトを右クリックし、[Run as] > [Maven build...] > parent clean site-deploy
.
これらは親の の一部ですpom.xml
:
<distributionManagement>
<!-- Generate the site locally, then it'll be uploaded to the server -->
<!-- Children will append their artifact ID to the base url -->
<site>
<id>project-name</id>
<name>Project Name</name>
<url>file://${env.HOME}/testsite/</url>
</site>
</distributionManagement>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<configuration>
...
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>sh</id>
<phase>site-deploy</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sh</executable>
<arguments>
<argument>publish-site.sh</argument>
<argument>${localsitedir}</argument>
...
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
そして子供から:
<build>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>sh</id>
<phase>site-deploy</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sh</executable>
<arguments>
<argument>../parent/publish-site.sh</argument>
<argument>${localsitedir}/child</argument>
...
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</build>
execプラグインを構成するさまざまな方法を試しました(を使用せずpluginManagement
に、プラグインの親の構成を継承し、引数部分のみを書き換えるなど)、スクリプトの終了時に常にブロックされ、実行を終了しません。
サイトは正しくアップロードされていますが、もちろん、サイトを更新するたびに Maven ビルドの実行を手動で終了したくはありません (また、プロジェクトから Jenkins サーバーにアーティファクトをデプロイする予定であるため、サイトはそれまでに展開が機能することを願っています)。