Installation :
- Download file from :
- https://maven.apache.org/download.cgi
- https://dlcdn.apache.org/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz
- Extract it
- First choice developer can change the path
-
1export PATH=/opt/apache-maven-3.8.2/bin:$PATH
-
- Second Choice
- Linking the bin/mvn to /bin/mvn
- Third Choice
- User can install over linux package management system
- apt-get install mvn
- User can install over linux package management system
- First choice developer can change the path
Private Repository
- Archiva Installation
- Developer should download it first :
- https://archiva.apache.org/download.cgi
- https://ftp.fau.de/apache/archiva/2.2.5/binaries/apache-archiva-2.2.5-bin.tar.gz
- Developer should download it first :
- On Linux, the bin/archiva script is suitable for linking or copying to /etc/init.d/archiva and running as root, as long as the RUN_AS_USER environment variable is set within the script. This will allow you to start and stop the service with:
-
12$ service archiva start$ service archiva stop
-
Maven Command Line Examples :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
mvn -version # Create maven project mvn archetype:generate -DgroupId=com.kz -DartifactId=testproject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false # compile the project and create target folder mvn compile # builds maven and installs it into local maven repository. mvn install mvn clean install # clean target then install mvn package # for package # skip test mvn -Dmaven.test.skip=true package mvn clean install -T8 -DskipTests # Thread Count -T8 mvn '-Dmaven.test.skip=true' install # ' chars important, can give error mvn '-Dmaven.test.skip=true' package # Exec mvn exec:java -Dexec.mainClass=com.kz.Main # with arguments mvn exec:java -Dexec.mainClass=com.kz.Main -Dexec.args="download 1" # You can also run a single test file or a particular method inside a test file as follows. mvn test mvn test -Dtest=com.mycompany.AppTest#testMethod # Maven build with dependencies mvn clean compile assembly:single # Maven Build : Example jar file create ejb mvn clean compile package install |
Pom File Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>spring-boot-data-jpa</artifactId> <packaging>jar</packaging> <name>Spring Boot Spring Data JPA</name> <version>1.0</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.2.RELEASE</version> </parent> <properties> <java.version>1.8</java.version> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> </properties> <dependencies> <!-- jpa, crud repository --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> ................................. |
Also Make Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
pom.xml contains 4 modules <modules> <module>A</module> <module>B</module> <module>C</module> <module>D</module> </modules> 1- GO to Different PARENT PROJECT mvn --projects A,B,D --also-make clean install OR mvn -pl A,B,D -am clean install OR mvn -pl A,B,D -amd clean install -pl, --projects Build specified reactor projects instead of all projects -am, --also-make If project list is specified, also build projects required by the list |
Ejb Build
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<build> <!-- Set the name of the deployment --> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${version.compiler.plugin}</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>${version.ejb.plugin}</version> <configuration> <ejbVersion>3.1</ejbVersion> </configuration> </plugin> </plugins> </build> |
Single Fat Jar
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<build> <directory>${buildDirectory}</directory> <!-- this variable defined at properties --> <plugins> <!-- db.controller. --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.1.1</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> |
Important Hibernate Libraries for Spring Data
Ref :
https://wpanas.github.io/tools/2018/01/28/maven-repo.html
- https://mkyong.com/maven/how-to-add-remote-repository-in-maven-pom-xml/
- https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
- https://stackoverflow.com/questions/20882622/maven-private-remote-repository-setup
- https://de.sonatype.com/nexus/repository-oss/download
- https://support.cloudbees.com/hc/en-us/articles/219872588-Configure-the-remote-Maven-repository-in-Jenkins-project-jobs
- https://ant.apache.org/manual/tutorial-tasks-filesets-properties.html
- https://stackoverflow.com/questions/15846106/can-i-use-the-same-ant-build-file-for-windows-and-unix
- https://raw.githubusercontent.com/YOUR_ORGANIZATION/YOUR_ARTIFACT/repository/
- https://gist.github.com/fernandezpablo85/03cf8b0cd2e7d8527063
- https://maven.apache.org/guides/introduction/introduction-to-repositories.html
- https://help.liferay.com/hc/en-us/articles/360018164871-Creating-a-Maven-Repository
- https://dzone.com/articles/how-to-setup-a-maven-repository-in-minutes
- https://mymavenrepo.com/
- https://medium.com/@medyo80/how-to-set-up-a-private-maven-repository-for-free-6d346bdcebea
- https://dev.to/fk/creating-private-maven-gradle-repository-2np3
- https://blog.packagecloud.io/eng/2017/03/26/private-maven-repositories-jenkins-gradle/
- https://thisinterestsme.com/downloading-files-curl-php/
- https://archiva.apache.org