0

I have a jar that contains map/reduce code for hadoop. It needs a dependency, which I need to put into the jar's lib directory so that the jar is self contained and can work in hadoop.

This is what I did in my pom:

1) add maven-dependency-plugin to copy the libs that I need into the target/lib folder

2) configure the jar plugin to take the libs in the target/lib folder, and add it into the generated jar.

I am just unable to get this to work. The generated jar does not contain the extra libs.

I also tried adding the target/lib directory to the / tag in the pom, and that didnt work either.

Here is my pom, annotated....

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.8</version>
        <executions>
          <execution>
              <id>copy apache-httpcomponents</id>
              <phase>process-resources</phase>
              <goals>
                  <goal>copy-dependencies</goal>
              </goals>
              <configuration>
                  <includeTypes>jar</includeTypes>
                  <includeGroupIds>org.apache.httpcomponents</includeGroupIds>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
                  <stripVersion>false</stripVersion>
              </configuration>
          </execution>
      </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
              <id>add lib directory to jar</id>
              <phase>package</phase>
              <goals>
                  <goal>jar</goal>
              </goals>
              <configuration>
                <classifier>jar</classifier>
                <includes>
                  <include>${project.build.outputDirectory/lib/**</include>
                  <include>${project.build.outputDirectory/target/**</include>
                </includes>
              </configuration>
          </execution>
      </executions>
    </plugin>

Any help appreciated!

feroze
  • 7,380
  • 7
  • 40
  • 57

1 Answers1

0

It looks like you left off the closing bracket in your include.

Add a bracket here: ${project.build.outputDirectory/lib after outputDirectory, and in the same place on the next line as well.

And I think it should be ${project.build.directory}/lib instead of ${project.build.outputDirectory}/lib because project.build.directory by default is the target folder

Evan LaHurd
  • 977
  • 2
  • 14
  • 27