Validate installation
mvn --version ###################################
Scaffolding a project with Maven
mvn archetype:generate
-DgroupId=com.mycompany.app
-DartifactId=my-app
-DarchetypeArtifactId=maven-archetype-quickstart
-DarchetypeVersion=1.4
-DinteractiveMode=false
###################################
Creating a Maven Wrapper
cd {your-project} mvn -N io.takari:maven:wrapper -Dmaven=3.6.2 ####################################
for Heroku deploy
echo 'web: java -Dserver.port=$PORT $JAVA_OPTS -jar target/*.jar' > Procfile #################################### echo '#!/usr/bin/env bash ./mvnw exec:java -q ' > run.sh && chmod 755 run.sh ####################################
create gitignore
gi Linux,VisualStudioCode,Java,Maven >> .gitignore
create git repo
git init gitpub ####################################
Set Properties Java Version
' <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>12</maven.compiler.source> <maven.compiler.target>12</maven.compiler.target> <maven.compiler.release>12</maven.compiler.release> <main.class>MainClass</main.class> <junit.version>4.12</junit.version> <junit.jupiter.version>5.5.2</junit.jupiter.version> <junit.vintage.version>5.5.2</junit.vintage.version> ' ####################################
add dependency slf4j and junit
' org.junit.jupiter junit-jupiter-api ${junit.jupiter.version} test junit junit ${junit.version} test org.junit.jupiter junit-jupiter-engine ${junit.jupiter.version} test org.junit.vintage junit-vintage-engine ${junit.vintage.version} test org.mockito mockito-core 3.0.0 test org.apache.logging.log4j log4j-core 2.12.1 org.apache.logging.log4j log4j-api 2.12.1
'
add line to every class
private static final Logger log = LoggerManager.getLogger(Class.class);
################################## ' maven-surefire-plugin 3.0.0-M3 --enable-preview ' ###################################
execute a Java program with Maven
add plugin to build->plugins tag pom.xml
' org.codehaus.mojo exec-maven-plugin 1.6.0 ${main.class} '
run mnv wrapper
./mvnw clean package ./mvnw exec:java ####################################
add manifest mainfest make a executable jar
add mvn configuration to maven-jar-plugin
' maven-jar-plugin 3.1.1 true ${main.class} ' ####################################
Building a fat jar
' org.apache.maven.plugins maven-assembly-plugin 3.1.1 jar-with-dependencies ${mainClass} make-assembly package single '
remove tag if exist
./mvnw clean package java -jar target/*.jar ####################################
Show the dependency tree
./mvnw dependency:tree -Dverbose ####################################
is newer versions of a dependency available
./mvnw versions:display-dependency-updates ####################################
build block pom.xml example
'
4.0.0
org.robatipoor hello-java-world 0.0.1
hello-java-world
UTF-8 12 12 org.robatipoor.App 4.12 5.5.1 5.5.1 org.junit.jupiter junit-jupiter-api ${junit.jupiter.version} test junit junit ${junit.version} test org.junit.jupiter junit-jupiter-engine ${junit.jupiter.version} test org.junit.vintage junit-vintage-engine ${junit.vintage.version} test org.slf4j slf4j-api 1.7.26 org.slf4j slf4j-simple 1.7.26 runtime org.mockito mockito-core 3.0.0 test maven-clean-plugin 3.1.0 maven-resources-plugin 3.0.2 maven-compiler-plugin 3.8.0 12 --enable-preview maven-surefire-plugin 3.0.0-M3 --enable-preview slow maven-jar-plugin 3.1.1 true ${main.class} org.apache.maven.plugins maven-assembly-plugin 3.1.1 jar-with-dependencies ${main.class} make-assembly package single maven-install-plugin 2.5.2 maven-deploy-plugin 2.8.2 maven-site-plugin 3.7.1 maven-project-info-reports-plugin 3.0.0 org.codehaus.mojo exec-maven-plugin 1.6.0 --enable-preview --release 12 ${main.class}'