doblejota93
doblejota93

Reputation: 171

Add java libraries into Maven

I would like to know if there is any way to embed native java libraries in maven as dependency or something like that but from the internet not from local.

Like java.util or all that jdk provides.

Example of "pom.xml":

<dependency>
    <groupId>jdk</groupId>
    <artifactId>java.util.arraylist</artifactId>
    <version>1.1.3</version>
</dependency>

Upvotes: 0

Views: 2565

Answers (2)

Andre
Andre

Reputation: 410

Think of Maven as an infrastructure that handles dependencies.

mvn install

Write to local Maven directory on your machine.

mvn deploy

Write to an external repository server, e.g. Nexus, so it can be shared with others. (Your local Maven must be configured to recognize this Nexus.)

See https://maven.apache.org/run.html

Upvotes: -1

Jason
Jason

Reputation: 11822

All of the standard, built-in Java classes are available to your build already - you don't need to add them as dependencies.

If you have a jar (possibly home-built) that you need to use in your maven build as a dependency, you can add it to your local maven repository as an artefact and have your pom.xml depend upon it as normal.

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
    -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

For more details, see this SO answer, or this Maven reference for details on how to perform this.

Upvotes: 3

Related Questions