File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Install 3rd party jars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Install 3rd party jars" Watch "Install 3rd party jars" New topic
Author

Install 3rd party jars

Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
I have a 3rd party jar I need to install to my local repository. I followed the instructions here:
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
and the jar installed to my local repository just fine.
When I try to build my project it pulls the jar but then gives me an error about the pom file missing.
Can someone give me some pointers about how to get around this error? Do I need to code a pom for each of 3rd party jar that I install?
Eventually I'll deploy the jar to the our remote repo, but for now I just want to get it working locally.

Sincerely

Kev.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The plugin should have created the pom for you: what's in the repo?
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
the path to the jar I'm installing is this:
C:\LocalRepository\spring\j2ee\mail\spring-mail\0.0.0
inside of that is spring-mail-0.0.0.jar and no pom.

Here is the exact command i used.
mvn install:install-file -Dfile=spring-framework-2.5.5\lib\j2ee\mail.jar -DgroupId=spring.j2ee.mail -DartifactId=spring-mail -Dversion=0.0.0 -Dpackaging=jar

my version of maven is:
Apache Maven 2.2.1 (r801777; 2009-08-06 14:16:01-0500)
Java version: 1.6.0_16
Java home: C:\Program Files\Java\jdk1.6.0_16\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"

my version of the install plugin is:
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install

I opened up the jar with 7zip and everything looks normal there so the jar is being installed to the localRepository.
David, I too read that the pom is supposed to be auto generated. Is there a version conflict or something happening here?

Thanks,

Kevin.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The pom would be in the repository, not in the jar. I find it unlikely to be a version issue, because unless you explicitly state what version of something you want to use it's going to use the latest (in other words, I'm using the same version of Maven2, same install plugin version, and even the same Java version, though on Linux).

I'm not sure what to tell you; I've run similar installs countless times across Linux, Windows, and OS X without issue.

Perhaps posting the actual error would be a good idea.
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
David, I wasn't suggesting the pom would be in the jar. Thanks for taking the time to reply. Sincerely appreciated.

I put -DgeneratePom=true on the end of the command above and the pom was generated.

So, to replicate the problem I was having regarding pom generation, I deleted the spring/j2ee/mail directory which wiped out the jar and pom. Reissued my original command without -DgenereatePom=true. I looked in my local repo, checked the spring/j2ee/mail/spring-mail, found maven-metadata-local.xml and a folder named 0.0.0. Inside 0.0.0 was only a single jar named mail.jar and no pom.

I then ran a clean and build in netbeans, here is the dump.

NetBeans: Executing 'mvn.bat -Dnetbeans.execution=true clean install'
NetBeans: JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16
Scanning for projects...
------------------------------------------------------------------------
Building solr-maven
task-segment: [clean, install]
------------------------------------------------------------------------
[clean:clean]
[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\workspace\solr-maven\src\main\resources
Downloading: http://dis.local/repo/spring/j2ee/mail/spring-mail/0.0.0/spring-mail-0.0.0.pom
Unable to find resource 'spring.j2ee.mail:spring-mail:pom:0.0.0' in repository remoteRepo (http://dis.local/repo)
Downloading: http://dis.local/opt/snapshotRepo/spring/j2ee/mail/spring-mail/0.0.0/spring-mail-0.0.0.pom
Unable to find resource 'spring.j2ee.mail:spring-mail:pom:0.0.0' in repository remoteSnapshotRepo (http://dis.local/opt/snapshotRepo)
Downloading: http://repo1.maven.org/maven2/spring/j2ee/mail/spring-mail/0.0.0/spring-mail-0.0.0.pom
Unable to find resource 'spring.j2ee.mail:spring-mail:pom:0.0.0' in repository central (http://repo1.maven.org/maven2)
[compiler:compile]
Compiling 8 source files to C:\workspace\solr-maven\target\classes
[resources:testResources]
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\workspace\solr-maven\src\test\resources
[compiler:testCompile]
Compiling 1 source file to C:\workspace\solr-maven\target\test-classes
[surefire:test]
Surefire report directory: C:\workspace\solr-maven\target\surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running ok.tax.gov.solr.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[jar:jar]
Building jar: C:\workspace\solr-maven\target\solr-maven-1.0-SNAPSHOT.jar
[install:install]
Installing C:\workspace\solr-maven\target\solr-maven-1.0-SNAPSHOT.jar to c:\LocalRepository\blah\blah\left this out\
------------------------------------------------------------------------
BUILD SUCCESSFUL
------------------------------------------------------------------------
Total time: 4 seconds
Finished at: Wed Aug 11 09:07:09 CDT 2010
Final Memory: 20M/36M
------------------------------------------------------------------------

Although it says build successful, there's a lot of dependencies I have on apache poi etc, that Netbeans is telling me that it can't find.

for example this class: NoPropertySetStreamException
which I have defined in the pom here

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.6</version>
</dependency>

lol, geeze, this is getting weirder as I go. By the way, I know these jar's are correct as I'm converting this existing project to maven.
I used this link http://www.jarvana.com/jarvana/digest-check to get the dependency settings for the apache poi stuff.

Any suggestions are most welcome. I can't spend to much time on trying to convert this project. I really really really want it to be a maven project though.

Kev.

Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
I pulled my maven project up in Netbeans 6.7.1 and the dependency issues regarding apache poi have vanished. The problems I was experiencing regarding dependencies seemed to be specific to Netbeans 6.9.1. I apologize for not realizing this earlier. Hopefully, this info will be helpful to someone else. And if anyone can confirm they are having the same problems with 6.9.1, please do so.

However, the auto generated pom issue is still a mystery. I still have to explicitly state -DgeneratePom=true.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you're having problems with NetBeans, post a question in the IDE forum--that kind of issue would be related to Maven/NetBeans integration, not Maven itself.
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
The problem with netbeans mentioned above was just something I noticed as I was working on my project. My issue with the generatePom not defaulting to true still stands. I'm using windows xp. I ran the install command from the dos prompt. I replicated the issue several times yesterday. Could there be a setting in the super pom that I'm unaware of that could be causing the issue? If I wasn't the only java guy in the shop, I'd ask someone else to try the same command on their machine. But I'm a Lone Ranger here. So I have no basis for comparison.

Kevin.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Install 3rd party jars