Discussions

News: Manage Local Maven Dependency

  1. Manage Local Maven Dependency (6 messages)

    Manage Local Maven Dependency

    Recently, I came across an issue while running build for Maven pom.xml. I am using Hibernate Shards project in my product, and updated pom.xml with following:


                <dependency>
                      <groupId>hibernate</groupId>
                      <artifactId>shards</artifactId>
                      <version>3.0.0B2</version>
                </dependency>


    Though when I ran the pom.xml with the above xml snippet, it was not able to find the hibernate shards jar file in the Maven repository and could not download it.
    I searched the Maven repository for hibernate shards file, but could not find it. Maven repository is available here - http://mvnrepository.com/

    Solution
    When a pom.xml file is run using “mvn install” command, as part of the build, Maven fetches the jar files from the Maven repository on the internet.  These jar files are stored under a folder called “.m2” under the users folder.
    In this case, since the Hibernate Shards file is not available in the Maven repository, we have to manually run Maven command to install this jar file under the “.m2” folder. So here’s the command,

    mvn install:install-file -Dfile=c:\Downloads\hibernate-shards-3.0.0.beta2.jar -DgroupId=hibernate            -DartifactId=shards -Dversion=3.0.0B2 -Dpackaging=jar -DgeneratePom=true


    Now when the pom.xml build file is run with “mvn install” command, the build runs successfully, since the local “.m2” folder repository is checked for hibernate shards jar file.
    http://itsitspace.blogspot.com/2011/03/manage-local-maven-dependency.html

    Threaded Messages (6)

  2. that's easy[ Go to top ]

    just delete all the poms and get rid maven.

  3. Host a Maven Repository[ Go to top ]

    Hi,

    I am not sure whether we should discuss this Maven issue in this newsletter.

    Your proposed solution will have the downside that the build isn't reproducable on another machine.

    You should think about hosting an own repository like Nexus.

    There you should deploy these artifacts which aren't accessible on public repos.

     

    Kind regards,

     

    Christian

     

  4. re: Host a Maven Repository[ Go to top ]

    Right. And deploying to a maven repository (as opposed to your local repo) is explained here: http://maven.apache.org/plugins/maven-deploy-plugin/usage.html

    (also part of the core documentation)

  5. Host a Maven Repository[ Go to top ]

    Yes it is!

    Why don't use a repository manager like Nexus or Artifactory or Archiva?

    There are many advanteges in using  an Artifactory (or Nexus or Archiva) repository!

    The first one is to save your pom file from defining tons of external repository links:
     you can publish the configuration file used with Artifactory or Nexus (i.e. it merely contains the collection of all the external repository links) and remove them from your pom file, in this way you clean your  pom file from the external resources.

    Another advantage is: caching actifacts in a browsable site that could be easly backuped..etc..etc...

    Thus, use one of the available maven repository managers!

    Moreover the procedure illustrated in the post is the trivial one, should not be used for large (and serious) projects.

     

  6. maven 101[ Go to top ]

    This is hardly an obscure Maven feature, but one of the core plugins described in http://maven.apache.org/plugins/maven-install-plugin/usage.html

    Just remember to RTFM ;)

  7. Manage Local Maven Dependency[ Go to top ]

    It looks like you should just add thr right repository to your pom: http://www.mvnbrowser.com/artifact-details.html?groupId=hibernate&artifactId=shards