<?xml version="1.0" encoding="UTF-8" ?> <settings> <profiles> <profile> <id>my_profile</id> <repositories> <repository> <id>central</id> <name>Maven Central Repository</name> <url>https://repo1.maven.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> <repository> <id>internal</id> <name>Internal Company Repository</name> <url>https://internal.repository.mycompany.com/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <name>Maven Central Plugin Repository</name> <url>https://repo1.maven.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> </pluginRepository> <pluginRepository> <id>internal-plugins</id> <name>Internal Company Plugin Repository</name> <url>https://internal.repository.mycompany.com/</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>my_profile</activeProfile> </activeProfiles> </settings>Note: The local repository is typically located at "${user.home}/.m2/repository" on Unix-like systems (Linux/macOS) and "%USERPROFILE%\.m2\repository" on Windows.
mvn install:install-file \ -DgroupId=mtitek.maven.samples \ -DartifactId=mtitek-maven-samples \ -Dversion=1.0.0-SNAPSHOT \ -Dpackaging=jar \ -DgeneratePom=true \ -Dfile=/opt/artifacts/mtitek-maven-samples.jarAlternative: You can also install from a local pom.xml file if available:
mvn install:install-file \ -DpomFile=path/to/pom.xml \ -Dfile=/opt/artifacts/mtitek-maven-samples.jar
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies>Before Maven starts building a project, Maven will try to resolve all project dependencies.
Scope: Direct Dependency ("A" ► "B") |
Available During Phases | Comment |
---|---|---|
compile |
"compile" "test-compile" "test" "package" |
Available in all phases. If any of these phases needs to be executed for project "A", the build will fail if Maven cannot find the dependency "B" in the repository. The dependency will be included in the final packaged artifact. |
test |
"test-compile" "test" |
If the phases "test-compile" or "test" have to be executed for the project "A",
the build will fail if Maven cannot find the dependency "B" in the repository. Note that if the phase "compile" has to be executed for the project "A", the build will fail if the code (not test code) of the project "A" refers the code of the project "B". |
provided |
"compile" "test-compile" "test" |
If any of the phases "compile", "test-compile", or "test" has to be executed for the project "A", the build will fail if Maven cannot find the dependency "B" in the repository. |
runtime |
"test" "package" |
If any of the phases "test" or "package" has to be executed for the project "A",
the build will fail if Maven cannot find the dependency "B" in the repository. Note that if the phase "compile" has to be executed for the project "A", the build will fail if the code (not test code) of the project "A" refers the code of the project "B". |
Scope: Direct Dependency ("B" ► "C") |
Scope: Direct Dependency ("A" ► "B") |
Scope: Transitive Dependency ("A" ► "C") |
Available During Phases | Comment |
---|---|---|---|---|
compile | compile | compile |
"compile" "test-compile" "package" |
If any of the phases "compile", "test-compile", or "package" has to be executed for the project "A", the build will fail if Maven cannot find the dependency "C" in the repository. |
compile | test | test | "test-compile" |
If the phase "test-compile" has to be executed for the project "A",
the build will fail if Maven cannot find the dependency "C" in the repository. Note that if the phase "compile" has to be executed for the project "A", the build will fail if the code (not test code) of the project "A" refers to the code of the project "C". |
compile | provided | provided |
"compile" "test-compile" |
If any of the phases "compile" or "test-compile" has to be executed for the project "A", the build will fail if Maven cannot find the dependency "C" in the repository. |
compile | runtime | runtime |
"test-compile" "package" |
If any of the phases "test-compile" or "package" has to be executed for the project "A",
the build will fail if Maven cannot find the dependency "C" in the repository. Note that if the phase "compile" has to be executed for the project "A", the build will fail if the code (not test code) of the project "A" refers to the code of the project "C". |
Scope: Direct Dependency ("B" ► "C") |
Scope: Direct Dependency ("A" ► "B") |
Scope: Transitive Dependency ("A" ► "C") |
Available During Phases | Comment |
---|---|---|---|---|
runtime | compile | runtime |
"test-compile" "package" |
If any of the phases "test-compile" or "package" has to be executed for the project "A",
the build will fail if Maven cannot find the dependency "C" in the repository. Note that if the phase "compile" has to be executed for the project "A", the build will fail if the code (not test code) of the project "A" refers to the code of the project "C". |
runtime | test | test | "test-compile" |
If the phase "test-compile" has to be executed for the project "A",
the build will fail if Maven cannot find the dependency "C" in the repository. Note that if the phase "compile" has to be executed for the project "A", the build will fail if the code (not test code) of the project "A" refers to the code of the project "C". |
runtime | provided | provided |
"compile" "test-compile" |
If any of the phases "compile" or "test-compile" has to be executed for the project "A", the build will fail if Maven cannot find the dependency "C" in the repository. |
runtime | runtime | runtime |
"test-compile" "package" |
If any of the phases "test-compile" or "package" has to be executed for the project "A",
the build will fail if Maven cannot find the dependency "C" in the repository. Note that if the phase "compile" has to be executed for the project "A", the build will fail if the code (not test code) of the project "A" refers to the code of the project "C". |
<dependency> <groupId>A</groupId> <artifactId>A</artifactId> <version>1.0.0-SNAPSHOT</version> <exclusions> <exclusion> <groupId>B</groupId> <artifactId>B</artifactId> </exclusion> </exclusions> </dependency>You can use the Maven Dependency Plugin to print the dependency tree of your project:
$ mvn dependency:tree