Skip to content

Instantly share code, notes, and snippets.

@bitkill
Last active January 29, 2021 15:04
Show Gist options
  • Save bitkill/24762ea142ed22c6527c52840c02ff8d to your computer and use it in GitHub Desktop.
Save bitkill/24762ea142ed22c6527c52840c02ff8d to your computer and use it in GitHub Desktop.
Maven cheatsheet

Performance compile

-T 1C

Accept snapshots

-Denforcer-snapshot.fail=false

No tests

-Dmaven.test.skip skips tests sources, and does not run tests

-DskipTests - does not run tests

No nothing :)

-PskipAll

Gitbook plugin

mvn clean install -pl :site -am -Pgitbook-serve

Get variable from maven

mvn -q -Dexec.executable='echo' -Dexec.args='$${dependencyY.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:exec

also a faster non maven alternative grep -o -P -m 1 "(?<=<dependencyY.version>)[^<]+" pom.xml

Liquibase generate report

bin/liquibase --defaultsFile="conf/component.properties" --password="secret" --changeLogFile="changelog/changelog-master.xml" dbDoc ./docs/

Docs

Versioning of an API, via maven shade

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <executions>
                    <execution>
                        <id>determine-major-version</id>
                        <phase>initialize</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <extensions>true</extensions>
                <groupId>io.repaint.maven</groupId>
                <artifactId>tiles-maven-plugin</artifactId>
            </plugin>
			<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <id>relocate-classes</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <includes>
                                    <include>${project.groupId}:${project.artifactId}</include>
                                </includes>
                            </artifactSet>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>v${project.major}</shadedClassifierName>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            </transformers>
                            <relocations>
                                <relocation>
                                    <pattern>org.generic.classes</pattern>
                                    <shadedPattern>org.generic.classes.v${project.major}</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
      </plugins>
    </build>

How to debug then? Add manually the generated jar to the project dependencies (IntelliJ) and add breakpoints on the compiled classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment