Skip to content

Instantly share code, notes, and snippets.

@sidlors
Last active June 10, 2021 12:01
Show Gist options
  • Select an option

  • Save sidlors/c47183090e2380ce130a1f8e2d4ebfd2 to your computer and use it in GitHub Desktop.

Select an option

Save sidlors/c47183090e2380ce130a1f8e2d4ebfd2 to your computer and use it in GitHub Desktop.
Maven tips & tricks

Generar proyectos desde terminal

Para generar un maven-archetype-quickstart

  • windows
mvn archetype:generate ^
	-DgroupId={project-packaging} ^
	-DartifactId={project-name} ^
	-DarchetypeArtifactId=maven-archetype-quickstart ^
	-DinteractiveMode=false
  • Linux/mac/unix
mvn archetype:generate \                                                                                                       
        -DgroupId={project-packaging} \
        -DartifactId={project-name} \
        -DarchetypeArtifactId=maven-archetype-quickstart \
        -DinteractiveMode=false
  • One Line
mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Hacer un Uber Jar

cuando queremos hacer un jar gordo que tenga todo lo que necesita de clases para correr el jar usamos el siguiente plugin

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <!-- Attach the shade into the package phase -->
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>${your.package.qualify.MainClass}</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
</build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment