2013-05-22 3 views
1

ПроблемаMaven не упаковки зависимостей в банке

У меня есть вложенные несколько модулей (правильная терминология?) Проект Maven и зависимости для одного из модулей не получаю в комплекте с банкой, когда я mvn clean package

Проект на самом деле является вилкой чего-то еще, что я не писал, а где-то вдоль линии я сломал процесс сборки, но я не могу понять, что я сделал.

Структура проекта заключается в следующем:

  • корень
    • распределение (родитель = корень)
    • child1 (родитель = корень) < - зависимостей не получает упакованы для этого одного
    • child2 (parent = корень)

В помам следующим образом (извиняюсь за размещение их все здесь, но я действительно не знаю, где искать):

корень

<groupId>com.something</groupId> 
<artifactId>root</artifactId> 
<packaging>pom</packaging> 

<modules> 
    <module>child1</module> 
    <module>child2</module> 
    <module>distribution</module> 
</modules> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
     </plugin> 
    </plugins> 
</build> 

распределение

<parent> 
    <groupId>com.something</groupId> 
    <artifactId>root</artifactId> 
</parent> 

<artifactId>distribution</artifactId> 
<packaging>pom</packaging> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
       <descriptors 
        <descriptor>src/main/assembly/distribution.xml</descriptor> 
       </descriptors> 
       <appendAssemblyId>false</appendAssemblyId> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

child1

<parent> 
    <groupId>com.something</groupId> 
    <artifactId>root</artifactId> 
</parent> 

<artifactId>child1</artifactId> 
<packaging>jar</packaging> 

<dependencies> 
    many dependencies here... 
</dependencies> 

child2

<parent> 
    <groupId>com.something</groupId> 
    <artifactId>root</artifactId> 
</parent> 

<artifactId>child2</artifactId> 
<packaging>jar</packaging> 

<dependencies> 
    many dependencies here... 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
       <appendAssemblyId>false</appendAssemblyId> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

distribution.xml

<id>package</id> 
<formats> 
    <format>tar.gz</format> 
</formats> 
<includeBaseDirectory>true</includeBaseDirectory> 
<fileSets> 
    <fileSet> 
     <directory>..</directory> 
     <outputDirectory>.</outputDirectory> 
     <fileMode>0644</fileMode> 
     <includes> 
      <include>README</include> 
      <include>CHANGELOG</include> 
      <include>LICENSE.txt</include> 
      <include>NOTICE.txt</include> 
     </includes> 
    </fileSet> 
    <fileSet> 
     <directory>../bin</directory> 
     <outputDirectory>bin</outputDirectory> 
     <fileMode>0755</fileMode> 
    </fileSet> 
    <fileSet> 
     <directory>../workloads</directory> 
     <outputDirectory>workloads</outputDirectory> 
     <fileMode>0644</fileMode> 
    </fileSet> 
</fileSets> 
<moduleSets> 
    <moduleSet> 
     <useAllReactorProjects>true</useAllReactorProjects> 
     <includeSubModules>true</includeSubModules> 
     <sources> 
      <includeModuleDirectory>true</includeModuleDirectory> 

      <fileSets> 
       <fileSet> 
        <directory>.</directory> 
        <fileMode>0644</fileMode> 
        <includes> 
         <include>README</include> 
        </includes> 
       </fileSet> 
       <fileSet> 
        <directory>src/main/conf</directory> 
        <outputDirectory>conf</outputDirectory> 
        <fileMode>0644</fileMode> 
       </fileSet> 
       <fileSet> 
        <outputDirectory>lib</outputDirectory> 
        <directory>target</directory> 
        <includes> 
         <include>*.jar</include> 
        </includes> 
        <fileMode>0644</fileMode> 
       </fileSet> 
      </fileSets> 
     </sources> 
    </moduleSet> 
</moduleSets> 

Примечание: код на GitHub, я с удовольствием предоставить ссылку на хранилище, если кто-то время и желание посмотреть настоящий проект!

ответ

2

Я считаю, что это по дизайну. Это просто способ работы банок. Если вы хотите упаковывать зависимости в свою банку, они все равно не сработают. Решение состоит в том, чтобы использовать теневой плагин для создания uberjar. Here's a tutorial on how.

Этот maven-assembly-plugin плагин также может это сделать, но у него не так много функций. В любом случае, если вы добавили это к вашему child1 pom, он также упакует зависимости.

+0

Спасибо, но оригинальный проект НЕ использовал этот плагин, который заставляет меня задаться вопросом, как он на самом деле работал ...? (и он сделал/действительно работает) –

+0

Это буквально то, что 'child1' выглядел как в исходном проекте https://github.com/brianfrankcooper/YCSB/blob/master/core/pom.xml. Обратите внимание, что' maven-assembly -plugin' не используется ... любая идея как/почему? –

+0

И делает ли ребенок 1 pom самостоятельным и включает в себя банки в своей банке? –

Смежные вопросы