Skip to content
Advertisement

How can I import the Maven shade plugin properly?

I am very frustrated. I’ve spent a long time trying to compile a Maven project into an Uber/Fat jar file using the Maven shade plugin, but I still keep getting “mvn is not recognized as an internal or external command” error in command prompt. Here are the important bits of my pom.xml:

    <build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.2.4</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <mainClass>*my main class*</mainClass>
            </transformer>
          </transformers>
          <filters>
            <filter>
                <artifact>*:*</artifact>
                    <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                    </excludes>
                </filter>
            </filters>
        </configuration>
      </execution>
    </executions>
  </plugin>
</plugins>

I don’t know what I’m doing wrong. I am going into my project’s directory using Windows Command Prompt and typed “mvn clean install” but it doesn’t seem to work. I am new to Maven, I generally use Gradle. Has the plugin not loaded? Am I doing something wrong? Or am I just being stupid as always?

Any help appreciated! Thanks in advance!

Advertisement

Answer

For Maven to work on command line, you need to

  • download and unzip it to some directory
  • Add the bin directory in that directory to your PATH

If you have done that, you may have a type or may need to restart your system.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement