7

私は次の形式のプロジェクトを持っています

- pom.xml
- projectA
  - pom.xml
  - src/main/
    - java
    - startupScript
- projectB
  - pom.xml
  - src/main/
    - java
    - startupScript
- projectAssembly
  - pom.xml

projectAssemblyprojectA 用と projectB 用の 2 つのフォルダーを含む tar.gz を作成したいと思います。各フォルダーには、プロジェクトの依存関係とstartupScriptライブラリがあります。

これを行う「素朴な」方法は、assembly.xml各プロジェクトにファイルを追加することです。ファイルはおおよそ次のようになります。

<assembly>
<formats>
    <format>tar.gz</format>
</formats>
<baseDirectory>/${project.artifactId}</baseDirectory>
<fileSets>
    <fileSet>
        <directory>${basedir}/src/main/startupScripts</directory>
        <outputDirectory>/startupScripts</outputDirectory>
    </fileSet>
 </fileSets>
<dependencySets>
    <dependencySet>
        <outputDirectory>/lib</outputDirectory>
    </dependencySet>
</dependencySets>
</assembly>

次に、 で、との両方projectAssemblyに依存し、大まかに次のようなアセンブリ ファイルを追加します。<type>tar.gz</type>projectAprojectB

<assembly>
<dependencySets>
    <dependencySet>
        <outputDirectory>/</outputDirectory>
        <unpack>true</unpack>
    </dependencySet>
</dependencySets>
</assembly>

tar.gzこれは機能しますが、プロジェクトAとの中間は必要ありませんB。特に依存関係が多い場合、それらの作成には時間がかかります。

projectAssembly中間アーカイブのパックとアンパックに時間を無駄にすることなく、 tar.gz のみを直接アセンブリするように maven に指示するにはどうすればよいですか?

4

1 に答える 1

1

projectAssembly のアセンブリ記述子は、次のようにする必要があります (内部のコメントを参照)。

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<formats>
  <format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
  <moduleSet>

    <!-- Enable access to all projects in the current multimodule build! -->
    <useAllReactorProjects>true</useAllReactorProjects>

    <!-- Now, select which projects to include in this module-set. -->
    <includes>
      <include>*:projectA</include>
      <include>*:projectB</include>
    </includes>

    <!-- Select and map resources from each module -->
    <sources>
      <includeModuleDirectory>false</includeModuleDirectory>
      <fileSets>
        <fileSet>
          <directory>src/main/startupScript</directory>
          <outputDirectory>${module.artifactId}/startupScript</outputDirectory>
        </fileSet>
      </fileSets>
    </sources>

   <!-- Select and map dependencies from each module -->
    <binaries>
      <dependencySets>
        <dependencySet>
          <outputDirectory>${module.artifactId}/lib</outputDirectory>
        </dependencySet>
      </dependencySets>
    </binaries>
  </moduleSet>
</moduleSets>
</assembly>

私はそれがあなたが必要とするものだと信じています. そうでない場合はお知らせください..

于 2013-05-14T06:19:10.070 に答える