1
プロジェクトルートのdist/
のように、いくつかのディレクトリ(jar、起動スクリプト、ドキュメント)にいくつかのファイルをコピーしたいとします。Maven、ファイルのコピー方法は?
私はmaven-assembly-pluginを使用し、<configuration><outputDirectory>
をpom.xmlに設定しています。ファイルはdist/
ですが、<my_project>-<decsriptor_id>/
サブディレクトリに作成されます。
dist/
のルートに出力する方法はありますか?
Mavenにファイルを単にコピーするプラグインがありますか?
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>maven-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.basedir}/dist</outputDirectory>
<descriptors>
<descriptor>${project.basedir}/src/main/maven-assembly/dist.xml</descriptor>
</descriptors>
</configuration>
</plugin>
dist.xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>dist</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>path........</source>
<fileMode>0755</fileMode>
<outputDirectory>.</outputDirectory>
</file>
</files>
</assembly>
あなたは '' DIR でディレクトリを作成するプラグインを告げたので、なぜあなたは持っていることに驚いていますそれは出力? ZIPを作成し、( ' false includeBaseDirectory>'のために)ここには基本ディレクトリがないことを確認してください。あなたが達成しようとしている仕事は何ですか?また、 'target'以外の場所にファイルを作成しないでください(' $ {project.basedir}/dist outputDirectory> 'は良い考えではありません)。 –
Tunaki
便宜のために、1つのディレクトリにすべての必要なファイルを(異なる場所から)、ターゲットから他のものをすべて持たないようにしてください。なぜそれは良い考えではないのですか? – AlexP11223
srcフォルダがバージョン管理下にあるため、ビルド中に生成されたファイルで汚染されていることを意味します...デフォルトでは、ターゲットフォルダは除外する必要があります(コンパイルされたクラス、コンパイルテストなど、作成されたzipファイルまたはjarファイル)....これは良い考えではない理由です... – khmarbaise