Skip to content

Instantly share code, notes, and snippets.

@TobseF
Created January 23, 2020 09:53
Show Gist options
  • Save TobseF/8097f2267ab7af96c80cec0993bbfd0c to your computer and use it in GitHub Desktop.
Save TobseF/8097f2267ab7af96c80cec0993bbfd0c to your computer and use it in GitHub Desktop.
đź“‹ Maven CheatSheet

đź“‹ Maven CheatSheet

Artefakte

Artefakt ins nexus einspielen

mvn clean deploy

Artefakt ins lokale .mvn einspielen

mvn clean install

Artefakt Abhängigkeiten auflösen

mvn dependency:resolve

Sourcecode hinzufĂĽgen

mvn source:jar install

Tests ĂĽberspringen

-Dmaven.test.skip  //Skip compile and running tests
-DskipTests        //Compile, but skip tests

Auf Dependency Updates prĂĽfen

mvn versions:display-dependency-updates

Doppelte dependencies auflisten

mvn dependency:analyze-duplicate

(Un-)benutzte dependencies auflisten

mvn dependency:analyze

https://carlosbecker.com/posts/maven-dependency-hell/

Multithreading

-T 4  # Use 4 Thread
-T 1C # Use 1 Thread per available Core

Jar manuell ins Nexus Repository deployen

mvn deploy:deploy-file -Dfile=your-lib.jar -DrepositoryId=its-nexus -Durl=http://nexus.local.itscope.com/content/repositories/releases -DartifactId=lib-id -DgroupId=lib-group -Dversion=lib-version

Parameter Finetuning

https://zeroturnaround.com/rebellabs/your-maven-build-is-slow-speed-it-up/

MAVEN_OPTS= -XX:+TieredCompilation -XX:TieredStopAtLevel=1
mvn -T 1C install -pl $moduleName -am —offline
//no clean

Doppelte Abhängikeiten auflisten

Dealing with Maven dependency hell - Carlos Alexandro Becker

mvn dependency:list -Dsort=true |
  grep "^\[INFO\]    " |
  awk '{print $2}' |
  cut -f1-4 -d: |
  sort |
  uniq |
  cut -f1-3 -d: |
  uniq -c |
  grep -v '^ *1 '

Maven will check for a newer UPDATE version on every build

<repository>
   <id>foo-repository</id>
   <url>...</url>
   <snapshots>
      <enabled>true</enabled>
      <updatePolicy>always</updatePolicy>
   </snapshots>
</repository>

Maven Konfiguration mavenrc

Maven can apparently be configured with the mostly undocumented files ~/.mavenrc (for current user) and /etc/mavenrc (for all users). In there, environment variables and command line options for the Java command can be configured.

With this, it is easy to set JAVA_HOME just for the Maven command, which will lead to it running with the specified version. Here's the content of that file:

JAVA_HOME="/path/to/your/jdk-9"

Widgetset lokal starten

	* Ins Verzeichnis des einzelnen Widgets gehen
cd de.itscope.redgiant.widget.nanoscrollpanel
	* Bauen:
mvn -Pdemo clean install -Dgwt.extraJvmArgs="-Xms1024m -Xmx2048m"
	* Jetty starten:
mvn -Pdemo jetty:run
http://127.0.0.1:8080/#?debug!comparison
	* Codeserver starten (superdevmode):
mvn -Pdemo vaadin:run-codeserver
http://localhost:9876/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment