Java 如何在maven中用多模块项目创建装配

Java 如何在maven中用多模块项目创建装配,java,maven,maven-assembly-plugin,Java,Maven,Maven Assembly Plugin,我有多模块Maven项目。模块的一部分是库,另一部分是可执行文件。我已经创建了组装模块,并将其附加到模块列表的末尾。组装模块配置如下所示: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifact

我有多模块Maven项目。模块的一部分是库,另一部分是可执行文件。我已经创建了组装模块,并将其附加到模块列表的末尾。组装模块配置如下所示:

<build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
    <!--   <version>1.1.3</version> -->
        <configuration>
          <descriptor>src/assembly/bin.xml</descriptor>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> 
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins> 
  </build>

  <dependencies>
    <!-- all dependencies -->
  </dependencies>

org.apache.maven.plugins
maven汇编插件
src/assembly/bin.xml
组装
包裹
单一的
我还创建了assembe文件src/assemble/bin.xml:

<id>bin</id>
  <formats>
    <format>dir</format> 
    <format>tar.gz</format> 
    <format>tar.bz2</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>${project.basedir}</directory>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>README*</include>
        <include>LICENSE*</include>
        <include>NOTICE*</include>
        <include>properties*/</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>*.jar</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}/jars</directory>
      <outputDirectory>jars</outputDirectory>
    </fileSet>
  </fileSets> 
  <moduleSets>
    <moduleSet>
        <binaries>
        <unpack>false</unpack>
        <dependencySets>
          <dependencySet>
            <unpack>false</unpack>
            <scope>compile</scope>
            <outputDirectory>jars</outputDirectory>
          </dependencySet>
        </dependencySets>
      </binaries>   
    </moduleSet>
  </moduleSets>
bin
迪尔
tar.gz
焦油bz2
假的
${project.basedir}
/
自述*
许可证*
通知*
性质*/
${project.build.directory}
/
*jar先生
${project.build.directory}/jars
罐
假的
假的
编译
罐
不幸的是,然后我运行Assembly with mvn包。我收到这个错误:

未能执行goal org.apache.maven.plugins:maven assembly plugin:2.2-beta-5:single(make assembly)on project assembly:未能创建程序集:创建程序集存档时出错bin:您必须至少设置一个文件。刚刚解决了这个问题

原来我的maven assembly插件只是缺少版本号:

<version>2.5.5</version>
2.5.5
此外,bin.xml也缺少依赖项:

<useAllReactorProjects>true</useAllReactorProjects> 

<includes>
  <include>org.rdswitchbaord.importers:import_ands</include>
  <!-- etc -->
</includes> 
true
org.rdswitchbaord.importers:import\u and

在那之后,一切都会神奇地运行。

如果你有解决方案,把它作为答案发布,然后接受它。请不要在你的问题标题中加上“已解决”这个词。好了,但我不能接受我自己的回答。一两天内你不能接受,但当你可以的时候,请接受。