22

I used to work only with maven, and when project requires some jar which is not available in any repository, I was able to install it with

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

It was quite easy.

Now I struggle with gradle, my project depends on a jar which no longer exists in any repository. I have the jar file on my disk. Changing the jar version in project dependencies does not apply to my problem.

Is there any way to install jar file into the gradle cache from command line without changing any project dependencies?

kokosing
  • 5,251
  • 5
  • 37
  • 50
  • You can also configure gradle globally in order to use the maven local artifacts. Edit the file **~/.gradle/init.gradle** and add this information inside of it: `allprojects { repositories { mavenLocal() maven { url "http://central.maven.org/maven2/" } } }` – Dimas Crocco Dec 26 '17 at 22:35

1 Answers1

7

@DaveNewton posted a link to a question that talks about adding your local Maven repository to Gradle's artifact search path. If you still have your local Maven repository, and the file has been deployed there, this will work.

Gradle also lets you reference dependencies on your local filesystem. However, if your computer crashes, you're in trouble.

I think a far better approach is to use a repository manager, like Nexus or Artifactory. It should be running on a separate machine that is regularly backed-up and/or uses RAID disks for its repository.

parsifal
  • 1,645
  • 9
  • 6
  • 1
    Thanks, I have managed to solve the problem. I have added maven repository to scanned by gradle and I installed jar manually by maven to its repository. – kokosing Jan 22 '13 at 15:17