3

Suppose I have some Maven coordinates, like

org.ow2.asm:asm:5.0.3

How would I cache these artifact into (existing) local maven repository?

Dims
  • 47,675
  • 117
  • 331
  • 600

2 Answers2

3

I believe this truly answers your question: it shows how to download and cache locally a specific Maven artifact from specific Maven repository with all dependencies without having to create pom.xml or any other sort of dependency declaration.

Andrei LED
  • 2,560
  • 17
  • 21
0

In your pom.xml add under <dependencies> the following :

<dependency>
    <groupId>org.ow2.asm</groupId>
    <artifactId>asm</artifactId>
    <version>5.0.3</version>
</dependency>

and use the command

mvn clean verify

at your project level to build the project and its dependencies to find the artifact in the corresponding .m2/repository folder.

Naman
  • 27,789
  • 26
  • 218
  • 353
  • Is it possible not to create `pom.xml`? – Dims Dec 08 '16 at 10:06
  • Using maven you must be having one already to define a project. – Naman Dec 08 '16 at 10:08
  • @Naman I do not use Maven as build tool, but do use Maven repository, so there is no `pom.xml` in my project. – Pavlus May 25 '19 at 11:50
  • @Pavlus In such a case, you can include the dependency using the build framework of yours e.g. `build.gradle` file for gradle as well. The question was tagged with [tag:maven], hence the answer to include the dependency in pom.xml. – Naman May 26 '19 at 02:13
  • @Naman well, I included this dependency in `build.gradle` and it ended up in gradle cache, and not in local Maven repository, I believe, commentaries about *command* and "is it possible not to create pom.xml" was because one want to cache it in local repo, by explicitly running command to do that and without creating Maven project. – Pavlus May 27 '19 at 15:13
  • @Pavlus The answer to that was considering that the maven framework in use would need you to anyway have a `pom.xml`. I am not sure how gradle caches the dependencies, but as far as `maven` is concerned it would download the artifact from the repository specified and cached it in `.m2` which is where it would lookup for the artifact the next time unless forced to download the artifact from global repository again. If you want to cache it in a local repository, there has to be some configuration to drive that. Unless you just download a jar and move it to the folder manually. – Naman May 27 '19 at 15:27