3

I am trying to create a deploy-able jar which using Apache's commons-lang3. However my AWS cluster where my Hadoop is does not contain this library so I get a classNotFoundException. I figured I needed to manually add that dependency in but I am having issues working with the maven shade plugin (I was recommended to use this) My current pom file looks like this :

    <dependency>
        <groupId>org.apache.pig</groupId>
        <artifactId>pig</artifactId>
        <version>0.12.0-cdh5.2.6</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.4</version>
    </dependency>
    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <artifact>org.apache.commons:commons-lang3</artifact>
                                <includes>
                                    <include>org/apache/commons/commons-lang3/3.4/*</include>
                                </includes>
                        <minimizeJar>true</minimizeJar>
                    </configuration>
                </execution>
            </executions>

        </plugin>

I want a completely normal jar with the addition of the commons-lang3 library embedded inside. Is there something I am doing incorrectly?

VSEWHGHP
  • 195
  • 2
  • 3
  • 12
  • According to https://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html - you want to use , not in your ... artifact does not seem to be supported. – Roman Zenka Mar 18 '16 at 20:08

1 Answers1

5

To include whitelisted jars you need to do the following:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.4.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <artifactSet>
                            <includes>
                                <include>org.apache.commons:commons-lang3</include>
                            </includes>
                        </artifactSet>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
beresfordt
  • 5,088
  • 10
  • 35
  • 43
  • 1
    I see that org.apache.commons:commons-lang3 pom dependnecy not getting included. It just add org.apache.commons:commons-lang3 not its transitive dependencies. – Madhav Kumar Jha Dec 10 '19 at 10:27