Haider Ali
Haider Ali

Reputation: 800

Add External JAR in Maven Dependency

I am trying to add external JAR file tigase-muc in a maven based project tigase-server in eclipse IDE.
I have tried following method

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
[INFO] Scanning for projects...
[INFO] 
[INFO] Building Tigase XMPP Server 5.1.0 5.2.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3:install-file (default-cli) @ tigase-server ---
[INFO] Installing /home/haider/Downloads/tigase-muc-2.2.0.jar to /
home/haider/.m2/repository/tigase/tigase-muc/2.2.0/tigase-muc-2.2.0.jar
[INFO] --------------
[INFO] BUILD SUCCESS
[INFO] -------------
[INFO] Total time: 0.791s
[INFO] Finished at: Mon Aug 05 18:06:48 PKT 2013
[INFO] Finished at: Mon Aug 05 18:06:48 PKT 2013
[INFO] ----------------------

From above BUILD SUCCESS message i assume that JAR file is correctly added , but when i add following dependency in POM file

        <dependency>
            <groupId>tigase</groupId>
            <artifactId>tigase-xmltools</artifactId>
            <version>3.3.6</version>
            <scope>compile</scope>
        </dependency>

It give me following error Missing artifact tigase:tigase-muc. This message clearly indicate that it didn't get the JAR file that i am referring in dependency

You Contribution will be highly appreciated THANKS

Upvotes: 5

Views: 11688

Answers (5)

jamlee
jamlee

Reputation: 1353

My solution is use the embed lib repo:

enter image description here

and add local lib:

    <dependencies>
        <dependency>
            <groupId>ok</groupId>
            <artifactId>comet4j-tomcat7</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>


    <repositories>
        <repository>
            <id>lib</id>
            <name>lib</name>
            <url>file://${basedir}/lib</url>
        </repository>
    </repositories>

Upvotes: 0

Dinesh Kumar
Dinesh Kumar

Reputation: 11

You can install external jars in local repository.

Here is a blog - http://findnerd.com/list/view/External-Dependencies-in-Maven-Project/3501/

Hope this would help you.

Upvotes: 0

Eric
Eric

Reputation: 2358

A more complete error message would help narrow down what's gone wrong. The artifact you installed should be resolvable via the following dependency:

<dependency>
    <groupId>tigase</groupId>
    <artifactId>tigase-muc</artifactId>
    <version>2.2.0</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>

You're reference tigase-xmltools which I'm assuming has a dependency on tigase-muc.

My guess is tigase-xmltools might have dependency on the actual pom of tigase-muc, which you don't have despite having the jar. Seeing the full error message and the pom of tigase-xmltools.

Installing the file with -DgeneratePom=true might help.

Upvotes: 1

Mark Bramnik
Mark Bramnik

Reputation: 42541

It looks like it installs the Jar like this: [INFO] Installing /home/haider/Downloads/tigase-muc-2.2.0.jar to / home/haider/.m2/repository/tigase/tigase-muc/2.2.0/tigase-muc-2.2.0.jar

As maven works, its group id is resolved to be ''tigase'', artifactId is ''tigase-muc'', version is ''2.2.0'' So this is right.

Now, I've took a look on tigase:tigase-xmltools:3.3.6 available here

It doesn't define any dependency at all.

So it looks like this would happen even if you don't specify this dependency :)

I would suggest you to run mvn dependency:tree to see where does this dependency comes from

Hope this helps

Upvotes: 2

Arpit
Arpit

Reputation: 6260

Well, if you have added the jar in maven dependencies, then it should be added in Maven Dependencies automatically.

Do you get any specific error while building the project? if yes then can you please share the error trace.

Also have a look at Maven Dependency Scope

Also, verify your local maven repository - M2_HOME\tigase\tigase-xmltools\3.3.6\ and check if the jar is installed here properly.

Upvotes: 0

Related Questions