Skip to content

Instantly share code, notes, and snippets.

@rafaeltuelho
Created March 10, 2022 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaeltuelho/694d50f9996010242455a534ded2d0b7 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/694d50f9996010242455a534ded2d0b7 to your computer and use it in GitHub Desktop.
Useful/helpful maven build plugins

Used when working with vscode-java to enable javadoc hover

  <build>
    <plugins>
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.1.2</version>
          <executions> 
              <execution>
                <?m2e execute onConfiguration?>
                  <goals>
                      <goal>sources</goal>
                      <goal>resolve</goal>
                  </goals>
                  <configuration>
                      <classifier>javadoc</classifier>
                      <classifier>sources</classifier>
                  </configuration>
              </execution>
          </executions>
      </plugin>
    </plugins>
  </build>

To generate an executable uber-jar

  <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>
              <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>
  </build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment