tags:

views:

330

answers:

2

I have a multi module project and I am using assembly plugin to build a tar file. I have included all of my modules in assembly plugin using moduleSets tag.

<moduleSets>
    <moduleSet>
         <includes>
             <include>module1</include>
             <include>module2</include>

All of my module jars are assembled into a lib folder. I want to add mysql jar from my local maven repository to the same lib folder that contains all of my other modules. Adding local repository jars in moduleset doesnt seem to work.

[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o  'mysql.mysql-connector-java:mysql-connector-java-version'

How can I include jars from maven repository.

A: 

I don't think you need to do anything special, just make sure mysql is listed as dependency in your project and it should work. Same applied to dependencies on modules - just list them as dependencies. Below is typical configuration of assembly plugin.

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
maximdim
+2  A: 

I think that you need to declare your mysql jar in the includes subelement of a dependencySet.

Something like this:

<assembly>
  <id>my-assembly</id>
  ...    
  <dependencySets>
    <dependencySet>
      <outputDirectory>/lib</outputDirectory>
      <includes>
        <include>mysql:mysql-connector-java</include>
      </includes>
      <unpack>false</unpack>
      <scope>runtime</scope>
    </dependencySet>
  </dependencySets>
  ...
</assembly>

Refer to the Descriptor Format documentation and/or the chapter 12.5.4. dependencySets Section of the Maven Book for more details on this element.

Pascal Thivent
+1. Another good option would be adding this mysql connector to module that need it as a runtime dependency.
cetnar