Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install jar with dependencies to maven repository (Android gcm-server push library)

I work on an industrialized large maven project, and on an application module, I need to be able to send push notifications to Android (with new Google Cloud Messaging).

It seems google provide themselves the server-side library to send the notifications, and according to the mailing list they do not provide any maven repository.

The first step mentionned in the google documentation is:

Copy the gcm-server.jar file from the SDK's gcm-server/dist directory to your server classpath.

I'm not going to do that so i've added the jar to my local repository and will add it to our enterprise Nexus.

mvn install:install-file
 -Dfile=gcm-server.jar
 -Dsources=gcm-server-sources.jar
 -DgroupId=com.google.android.gcm
 -DartifactId=gcm-server
 -Dversion=r3
 -DgeneratePom=true
 -Dpackaging=jar

But i've just noticed that the library has dependencies (simple-json, mockito and junit). It's not precised if they are runtime or tests but i guess only simple-json is used at runtime. I think retrieving the GCM dependency from our Nexus should also permit to retrieve the transitive dependencies like this simple-json lib right?

Thus what am i supposed to do? Should i create on my own a pom file for a project i don't own, and then import the project to my maven repository with -DpomFile=my-custom-pom.xml?

Thanks

like image 978
Sebastien Lorber Avatar asked Aug 16 '12 14:08

Sebastien Lorber


People also ask

How do I deploy my jar in my remote repository?

To deploy a 3rd party JAR use the deploy:deploy-file goal under maven-deploy-plugin. First, the wagon-provider(wagon-ftp, wagon-file, etc..) must be placed to your ${maven. home}/lib .

How do I manually download Maven dependencies?

Summary. You can use the Maven Dependency Plugin to download dependencies. Run mvn dependency:copy-dependencies , to download all your dependencies and save them in the target/dependency folder. You can change the target location by setting the property outputDirectory .


3 Answers

Finally i've ended creating my own pom.

I've created a maven repository on github here: https://github.com/slorber/gcm-server-repository

Thus anyone can download this jar with maven and also its transitive dependencies.

I've added the files/commands so that you know how i've done.

Add repository:

<repository>
    <id>gcm-server-repository</id>
    <url>https://raw.githubusercontent.com/slorber/gcm-server-repository/master/releases/</url>
</repository>

And dependency:

<dependency>
    <groupId>com.google.android.gcm</groupId>
    <artifactId>gcm-server</artifactId>
    <version>1.0.2</version>
</dependency>
like image 104
Sebastien Lorber Avatar answered Oct 28 '22 07:10

Sebastien Lorber


See https://groups.google.com/forum/#!msg/android-gcm/oukjcHpbLj4/lql_IzpjmUkJ%5B1-25%5D.

It seems that google simply doesn't publish this jar in any maven repository. You have two options:

  1. Include all (transitively) dependent jars in your repository
  2. (like you said) Create your own pom file

I would go for the second option. It's not that hard.

like image 3
Tom Avatar answered Oct 28 '22 05:10

Tom


Works using:

 <dependency>
        <groupId>com.google.android.gcm</groupId>
        <artifactId>gcm-server</artifactId>
        <version>1.0.2</version>
 </dependency>

And

<repository>
        <id>gcm-server-repository</id>
        <url>https://github.com/slorber/gcm-server-repository/raw/master/releases/</url>
</repository>
like image 3
Andrés Canavesi Avatar answered Oct 28 '22 07:10

Andrés Canavesi