1

One of the best strategies recommended for adding of JARs files in maven's project with no public repository is using of static in-project repository. Nice blog : http://charlie.cu.cc/2012/06/how-add-external-libraries-maven/ or one of the most popular as I found StackOverflow posts Can I add jars to maven 2 build classpath without installing them? Does someone have had next issue when make totally same steps for integrating of the solution (my particular case is adding of filters-1.0.jar file): "Missing artifact imageUtil:filters:jar:0.1:compile" or in other words, nevertheless the static in-project repository is set up in pom.xml at the end also could not be recognized ? Does something is missed by me ?

Here are my steps integrating of the solution:

  • create a "repo" folder in root of my maven project
  • in pom.xml I registered static in-repository :

<repository>

       <id>repo</id>
       <releases>
           <enabled>true</enabled>
           <checksumPolicy>ignore</checksumPolicy>
       </releases>
       <snapshots>
           <enabled>false</enabled>
       </snapshots>
       <url>file://${project.basedir}/repo</url>

</repository>

  • Again in pom.xml added mention dependency :

<dependency>

  <groupId>imageUtil</groupId>
  <artifactId>filters</artifactId>
  <version>0.1</version>

</dependency>

  • last step is copy-pacing of mention JAR in next sub-folder structure

    /repo/imageUtil/filters/0.1/filters-0.1.jar

When I checked in buildpath for the project (I am using Eclipse) I also saw that mention JAR is looking in my local repository or - /home/simeon/.m2/repository/imageUtil/filters/0.1 (missing)

Maybe the question here is "how to say to my maven project that this JAR should be searched in my static in-project repository" ?

Thanks in advance, SImeon

Community
  • 1
  • 1
Simeon Angelov
  • 470
  • 4
  • 18
  • maybe it's too late, but when first time running maven, do a `mvn install -U` so it force updates all dependencies and puts to local repo and then in Eclipse right click on your project `Maven` > `Update Project...` – Skyzer Nov 03 '13 at 03:22

1 Answers1

2

Your settings look fine. Is it never taking your in-project repository or do you mean it works first time and after that it will look only in the /home/simeon/.m2/repository/imageUtil/filters/0.1

I tried something similar and saw that if I give the name of a standard library which is available in a Maven Central repository, it looks there first and downloads it from there.

So I took a standard library (saxon) and renamed it to something different (eg: saxonic) which I know will not be available in any external repo, and I can see it uses my defined "inprojrepo" and installs this into my own local maven repository.

After that it uses from the local maven repository for next build.

[INFO] ------------------------------------------------------------------------
Downloading: file://D:\mymavenproject\someproject/inprojrepo/net/sf/Saxo
nic/9.4/Saxonic-9.4.pom
Downloading: http://repo.maven.apache.org/maven2/net/sf/Saxonic/9.4/Saxonic-9.4.
pom
[WARNING] The POM for net.sf:Saxonic:jar:9.4 is missing, no dependency informati
on available
Downloading: file://D:\mymavenproject\someproject/inprojrepo/net/sf/Saxo
nic/9.4/Saxonic-9.4.jar
Downloaded: file://D:\mymavenproject\someproject/inprojrepo/net/sf/Saxon
ic/9.4/Saxonic-9.4.jar (9560 KB at 29234.1 KB/sec)
[INFO]

My POM

<repository>
    <id>inprojrepo</id>
    <releases>
           <enabled>true</enabled>
           <checksumPolicy>ignore</checksumPolicy>
       </releases>
       <snapshots>
           <enabled>false</enabled>
       </snapshots>
    <url>file://${project.basedir}/inprojrepo</url>
</repository>
JoseK
  • 31,141
  • 14
  • 104
  • 131
  • Hi Jose, Thanks for the recommendation, but another issue appeared applying it - all JARs taken from the public repository are now marked as missing : Missing artifact org.slf4j:slf4j-api:jar:1.6.1:compile Missing artifact org.freemarker:freemarker:jar:2.3.19:compile ..... and so on Regarding the JAR, local one, with changed name - no information about it. DId you have such kind of issues when you start with implementration of name changing strategy ? – Simeon Angelov Jan 17 '13 at 12:02
  • @SimeonAngelov: Nope nothing like that - which version of Maven? I am using apache-maven-3.0.4-bin – JoseK Jan 28 '13 at 09:09
  • At the end I used other strategy: first I install all local JARs (in a parent) and then I use them as normal dependences. Cheers, Simeon – Simeon Angelov Jan 28 '13 at 10:12