13

I am working on maven based android project. I need to add all jars files of libs folder into maven local repositories because many jars are not available into maven central repositories. For this i am going to use following commands.But my question is how to get group-id,artifact-id from any external jar.
Suppose i am having picasso.jar in this case i don't know version too.

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

Where:<path-to-file>  the path to the file to load
   <group-id>      the group that the file should be registered under
   <artifact-id>   the artifact name for the file
   <version>       the version of the file
   <packaging>     the packaging of the file e.g. jar

Please help me.

Thanks in Advance

DJtiwari
  • 519
  • 1
  • 6
  • 21

3 Answers3

18

The .jars do not have an artifact id. You give them one while mvn installing. For example let's take picasso.jar of your case:

mvn install:install-file
-Dfile=<path-to-your-picasso.jar>
-DgroupId='com.square'
-DartifactId='picasso'
-Dversion=<version-given-by-you-(better using original picasso.jar version)>
-Dpackaging=<packaging>
-DgeneratePom=true

Then while using in your project, you need to add the dependency with this information.

faradaj
  • 3,629
  • 1
  • 22
  • 21
  • Now i am getting pom.xml not found in picasso.jar but it is showing BUILD SUCCESS . I am getting following error while add this jar in my pom.xml. Failure to find com.square:picasso:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository – DJtiwari Aug 11 '14 at 08:56
  • I run mvn install -U then also no Success .Please help me. – DJtiwari Aug 11 '14 at 09:03
  • 1
    mvn install:install-file -Dfile=E:\Development\External_Jars\picasso.jar -DgroupId=com.suquare -DartifactId=picasso -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true – DJtiwari Aug 11 '14 at 11:00
  • your -DgroupId parameter seems wrong. You're passing 'com.suquare' as groupId but it seems like you're using it 'com.square' in your project's pom. – faradaj Aug 11 '14 at 11:18
9

I've created a script that helps you build the pom.xml dependencies tag if you have a folder full of jars.

To discover this information the script does the following:

  1. It first looks inside the jar for META-INF/maven/
  2. then it tries to search for the jar by SHA1 checksum on search.maven.org
  3. then finally it puts a comment in pom.xml with information about the jar manifest to help you in locating the dependency yourself. Of course you may not find the jar anywhere and then you'll have to host it in your own private maven repository.

You can get it here: https://github.com/sjbotha/make-pom/

Sarel Botha
  • 12,419
  • 7
  • 54
  • 59
0

If you have an external JAR file and want to know the groupId and the artifactId of that JAR file, follow the following steps:

  1. Unzip the JAR file.
  2. After extracting, go to pom.properties (example path: META-INF\maven\com.squareup.okhttp3\okhttp\pom.properties)
  3. Inside pom.properties you will get the version, groupId and artifactId.
version=3.11.0
groupId=com.squareup.okhttp3
artifactId=okhttp