Hosting a Maven repository on github - maven

I have a fork of a small open sourced library that I'm working on github. I'd like to make it available to other developers via maven, but I don't want to run my own Nexus server, and because it's a fork I can't easily deploy it to oss.sonatype.org.
What I'd like to do is to deploy it to github so that others can access it using maven. What's the best way to do this?

The best solution I've been able to find consists of these steps:
Create a branch called mvn-repo to host your maven artifacts.
Use the github site-maven-plugin to push your artifacts to github.
Configure maven to use your remote mvn-repo as a maven repository.
There are several benefits to using this approach:
Maven artifacts are kept separate from your source in a separate branch called mvn-repo, much like github pages are kept in a separate branch called gh-pages (if you use github pages)
Unlike some other proposed solutions, it doesn't conflict with your gh-pages if you're using them.
Ties in naturally with the deploy target so there are no new maven commands to learn. Just use mvn deploy as you normally would
The typical way you deploy artifacts to a remote maven repo is to use mvn deploy, so let's patch into that mechanism for this solution.
First, tell maven to deploy artifacts to a temporary staging location inside your target directory. Add this to your pom.xml:
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
</plugins>
Now try running mvn clean deploy. You'll see that it deployed your maven repository to target/mvn-repo. The next step is to get it to upload that directory to GitHub.
Add your authentication information to ~/.m2/settings.xml so that the github site-maven-plugin can push to GitHub:
<!-- NOTE: MAKE SURE THAT settings.xml IS NOT WORLD READABLE! -->
<settings>
<servers>
<server>
<id>github</id>
<username>YOUR-USERNAME</username>
<password>YOUR-PASSWORD</password>
</server>
</servers>
</settings>
(As noted, please make sure to chmod 700 settings.xml to ensure no one can read your password in the file. If someone knows how to make site-maven-plugin prompt for a password instead of requiring it in a config file, let me know.)
Then tell the GitHub site-maven-plugin about the new server you just configured by adding the following to your pom:
<properties>
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
<github.global.server>github</github.global.server>
</properties>
Finally, configure the site-maven-plugin to upload from your temporary staging repo to your mvn-repo branch on Github:
<build>
<plugins>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.11</version>
<configuration>
<message>Maven artifacts for ${project.version}</message> <!-- git commit message -->
<noJekyll>true</noJekyll> <!-- disable webpage processing -->
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory> <!-- matches distribution management repository url above -->
<branch>refs/heads/mvn-repo</branch> <!-- remote branch name -->
<includes><include>**/*</include></includes>
<repositoryName>YOUR-REPOSITORY-NAME</repositoryName> <!-- github repo name -->
<repositoryOwner>YOUR-GITHUB-USERNAME</repositoryOwner> <!-- github username -->
</configuration>
<executions>
<!-- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase -->
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
The mvn-repo branch does not need to exist, it will be created for you.
Now run mvn clean deploy again. You should see maven-deploy-plugin "upload" the files to your local staging repository in the target directory, then site-maven-plugin committing those files and pushing them to the server.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DaoCore 1.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
[INFO] --- maven-deploy-plugin:2.5:deploy (default-deploy) # greendao ---
Uploaded: file:///Users/mike/Projects/greendao-emmby/DaoCore/target/mvn-repo/com/greendao-orm/greendao/1.3-SNAPSHOT/greendao-1.3-20121223.182256-3.jar (77 KB at 2936.9 KB/sec)
Uploaded: file:///Users/mike/Projects/greendao-emmby/DaoCore/target/mvn-repo/com/greendao-orm/greendao/1.3-SNAPSHOT/greendao-1.3-20121223.182256-3.pom (3 KB at 1402.3 KB/sec)
Uploaded: file:///Users/mike/Projects/greendao-emmby/DaoCore/target/mvn-repo/com/greendao-orm/greendao/1.3-SNAPSHOT/maven-metadata.xml (768 B at 150.0 KB/sec)
Uploaded: file:///Users/mike/Projects/greendao-emmby/DaoCore/target/mvn-repo/com/greendao-orm/greendao/maven-metadata.xml (282 B at 91.8 KB/sec)
[INFO]
[INFO] --- site-maven-plugin:0.7:site (default) # greendao ---
[INFO] Creating 24 blobs
[INFO] Creating tree with 25 blob entries
[INFO] Creating commit with SHA-1: 0b8444e487a8acf9caabe7ec18a4e9cff4964809
[INFO] Updating reference refs/heads/mvn-repo from ab7afb9a228bf33d9e04db39d178f96a7a225593 to 0b8444e487a8acf9caabe7ec18a4e9cff4964809
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.595s
[INFO] Finished at: Sun Dec 23 11:23:03 MST 2012
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
Visit github.com in your browser, select the mvn-repo branch, and verify that all your binaries are now there.
Congratulations!
You can now deploy your maven artifacts to a poor man's public repo simply by running mvn clean deploy.
There's one more step you'll want to take, which is to configure any poms that depend on your pom to know where your repository is. Add the following snippet to any project's pom that depends on your project:
<repositories>
<repository>
<id>YOUR-PROJECT-NAME-mvn-repo</id>
<url>https://github.com/YOUR-USERNAME/YOUR-PROJECT-NAME/raw/mvn-repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
Now any project that requires your jar files will automatically download them from your github maven repository.
Edit: to avoid the problem mentioned in the comments ('Error creating commit: Invalid request. For 'properties/name', nil is not a string.'), make sure you state a name in your profile on github.

Don't use GitHub as a Maven Repository.
Edit: This option gets a lot of down votes, but no comments as to why. This is the correct option regardless of the technical capabilities to actually host on GitHub. Hosting on GitHub is wrong for all the reasons outlined below and without comments I can't improve the answer to clarify your issues.
Best Option - Collaborate with the Original Project
The best option is to convince the original project to include your changes and stick with the original.
Alternative - Maintain your own Fork
Since you have forked an open source library, and your fork is also open source, you can upload your fork to Maven Central (read Guide to uploading artifacts to the Central Repository) by giving it a new groupId and maybe a new artifactId.
Only consider this option if you are willing to maintain this fork until the changes are incorporated into the original project and then you should abandon this one.
Really consider hard whether a fork is the right option. Read the myriad Google results for 'why not to fork'
Reasoning
Bloating your repository with jars increases download size for no benefit
A jar is an output of your project, it can be regenerated at any time from its inputs, and your GitHub repo should contain only inputs.
Don't believe me? Then check Google results for 'dont store binaries in git'.
GitHub's help Working with large files will tell you the same thing. Admittedly jar's aren't large but they are larger than the source code and once a jar has been created by a release they have no reason to be versioned - that is what a new release is for.
Defining multiple repos in your pom.xml slows your build down by Number of Repositories times Number of Artifacts
Stephen Connolly says:
If anyone adds your repo they impact their build performance
as they now have another repo to check artifacts against... It's not a big
problem if you only have to add one repo... But the problem grows and the next
thing you know your maven build is checking 50 repos for every artifact and
build time is a dog.
That's right! Maven needs to check every artifact (and its dependencies) defined in your pom.xml against every Repository you have defined, as a newer version might be available in any of those repositories.
Try it out for yourself and you will feel the pain of a slow build.
The best place for artifacts is in Maven Central, as its the central place for jars, and this means your build will only ever check one place.
You can read some more about repositories at Maven's documentation on Introduction to Repositories

You can use JitPack (free for public Git repositories) to expose your GitHub repository as a Maven artifact. Its very easy. Your users would need to add this to their pom.xml:
Add repository:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
Add dependency:
<dependency>
<groupId>com.github.User</groupId>
<artifactId>Repo name</artifactId>
<version>Release tag</version>
</dependency>
As answered elsewhere the idea is that JitPack will build your GitHub repo and will serve the jars. The requirement is that you have a build file and a GitHub release.
The nice thing is that you don't have to handle deployment and uploads. Since you didn't want to maintain your own artifact repository its a good match for your needs.

Since 2019 you can now use the new functionality called Github package registry.
Basically the process is:
generate a new personal access token from the github settings
add repository and token info in your settings.xml
deploy using
mvn deploy -Dregistry=https://maven.pkg.github.com/yourusername -Dtoken=yor_token

Another alternative is to use any web hosting with webdav support. You will need some space for this somewhere of course but it is straightforward to set up and a good alternative to running a full blown nexus server.
add this to your build section
<extensions>
<extension>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<groupId>org.apache.maven.wagon</groupId>
<version>2.2</version>
</extension>
</extensions>
Add something like this to your distributionManagement section
<repository>
<id>release.repo</id>
<url>dav:http://repo.jillesvangurp.com/releases/</url>
</repository>
Finally make sure to setup the repository access in your settings.xml
add this to your servers section
<server>
<id>release.repo</id>
<username>xxxx</username>
<password>xxxx</password>
</server>
and a definition to your repositories section
<repository>
<id>release.repo</id>
<url>http://repo.jillesvangurp.com/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
Finally, if you have any standard php hosting, you can use something like sabredav to add webdav capabilities.
Advantages: you have your own maven repository
Downsides: you don't have any of the management capabilities in nexus; you need some webdav setup somewhere

As an alternative, Bintray provides free hosting of maven repositories. That's probably a good alternative to Sonatype OSS and Maven Central if you absolutely don't want to rename the groupId. But please, at least make an effort to get your changes integrated upstream or rename and publish to Central. It makes it much easier for others to use your fork.

If you have only aar or jar file itself, or just don't want to use plugins - I've created a simple shell script. You can achieve the same with it - publishing your artifacts to Github and use it as public Maven repo.

I'd like to add another alternative, a Gradle plugin I've been working on lately: magik.
Basically it allows to publish directly on a github repository acting as a maven repository.

I came here looking to do the same thing, unlitmately host my Maven repository for free, but after more research I ended up here:
https://jfrog.com/start-free/
The setup was quite strightforward, has a good free tier which will serve me for the forseeable future, and has additional (paid for) upgrades which may well come in handy in the future.
So far I am very pleased indeed !

Related

How to make Maven deploy using a different, ad-hoc group Id?

Some background:
I have copied the master branch of an external github repository, not owned by me, into a personal repository
This repo contains a Java project and uses Maven for building and compilation
The group ID defined in all pom.xml files is org.mylibrary (let's assume)
When deploying to Artifactory, the deployment is done to myrepo/org/mylibrary/...
I'd like to deploy instead to:
myrepo/org/myorganization/mylibrary
but I would like to avoid editing all the pom.xml files, and replacing all lines containing:
<groupId>org.mylibrary</groupId>
with:
<groupId>org.myorganization.mylibrary</groupId>.
I'm configuring the deployment via the distributionManagement element:
<distributionManagement>
<repository>
<name>releases</name>
<id>deployment.credentials</id>
<url>https://artifactory.lab.myorg.org/artifactory/myrepo</url>
</repository>
</distributionManagement>
What's a clean way of solving this? Replacing the groupId definition in all pom.xml files does the trick, but, as said, that's something I want to avoid.
Thanks!
When deploying to any repository, Artifactory utilizes the layout that is configured for this repository. By default, for Maven repositories, Artifactory uses the "maven-default" layout.
I would recommend you to first add your requested layout and then configure your repository with the newly created layout.
I hope this information is found helpful.

How to force Maven to use a specific repository (and only that)?

I am setting up a local Nexus repository and am trying to convince my local Maven setup to access that repo as the one and only. That Nexus repo has a group maven-central defined that (quoting from the Nexus manual:) "...accesses the Central Repository, formerly known as Maven Central." and is also supposed to cache the downloaded data.
I thus entered my local Nexus repo into my [home]\.m2\settings.xml like this:
...
<profile>
<id>alwaysActiveProfile</id>
<repositories>
<repository>
<id>RepoSynoProxy</id>
<name>Nexus Repo on Synology NAS</name>
<url>http://192.168.1.15:8081/repository/maven-central/</url>
</repository>
</repositories>
</profile>
</profiles>
...
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
</activeProfiles>
...
But for some strange reason, when I run Maven it starts downloading everything from https://repo.maven.apache.org/maven2/ instead of from the local URL, as I would have expected:
...
[INFO] Downloading from : http://192.168.1.15:8081/repository/maven-central/junit/junit/3.8.1/junit-3.8.1.pom
[INFO] Downloading from : https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom (998 B at 7.3 kB/s)
[INFO] Downloading from : http://192.168.1.15:8081/repository/maven-central/junit/junit/3.8.1/junit-3.8.1.jar
[INFO] Downloading from : https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar (121 kB at 1.4 MB/s)
...
My questions thus:
First: any idea anyone, why the requests to http://192.168.1.15:8081/repository/maven-central/... obviously don't work? I am using a freshly downloaded and installed Nexus v3.18.0 here. The Maven-central proxy is already predefined and I have nothing special configured. Apparently that doesn't work "out-of-the-box".
Second: where does Maven have the URL https://repo.maven.apache.org/maven2/... from that it is using as alternative? Is that hardcoded into Maven as fall-back if a repo doesn't work? Can one suppress that so that it ONLY accesses the repo defined in settings.xml?
You need to configure a mirror in the settings.xml that will override the repository definitions in the superpom and in other pom files: https://help.sonatype.com/display/NXRM3/Maven+Repositories#MavenRepositories-ConfiguringApacheMaven

How to publish all jar for an existing project in a nexus/sonartype?

I have a maven project, and I have already all my dependencies in my local host. I want to push all these dependencies into nexus/sonartype.
I don't want to push my jar one by one by uploading via nexus interface.
So I copied the content of my maven repository ($MAVEN_HOME/repository) into {nexus-data}/storage/public
Nexus have to recalculate index after restarting?
You might want to use Distribution Management -
<distributionManagement>
<repository>
<id>some-artifactory</id>
<name>Artifactory Name</name>
<url>http://your.artifactory.address/releases</url>
</repository>
<snapshotRepository>
<id>other-artifactory</id>
<name>Other Artifactory Name</name>
<url>http://your.artifactory.address/snapshots</url>
</snapshotRepository>
</distributionManagement>
Repository
Where as the repositories element specifies in the POM the location
and manner in which Maven may download remote artifacts for use by the
current project, distributionManagement specifies where (and how) this
project will get to a remote repository when it is deployed. The
repository elements will be used for snapshot distribution if the
snapshotRepository is not defined.
So I copied the content of my maven repository ($MAVEN_HOME/repository) into {nexus-data}/storage/public
Don't do that. In Nexus 3, Nexus doesn't use raw files so relying on this approach isn't going to work for you anyway.
You should be using distribution management as described by #nullpointer. If you can't for some reason, you could write a script to use Nexus' REST API to upload many artifacts. That's more useful when you aren't building using Maven. For example, maybe you have a whole pile of legacy jar files to upload.

How do I force Maven to use my local repository rather than going out to remote repos to retrieve artifacts?

I’m using Maven 3.3.3 with Java 8 on Mac Yosemite. I have a multi-module project.
<modules>
<module>first-module</module>
<module>my-module</module>
…
</modules>
When I build my one of my child modules, for example, “my-module” from above, using “mvn clean install”, the build attempts to download the child module artifacts from a remote repository I have defined in my ~/.m2/settings.xml file. Output is below
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-module 87.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://download.java.net/maven/2/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml
Downloaded: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml (788 B at 0.9 KB/sec)
Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first-module-87.0.0-20151104.200545-4.pom
How do I force Maven to check my local ~/.m2/repository first before trying to download from the remote repositories? Below is where I have my remote repositories defined in my ~/.m2/settings.xml file …
<profile>
<id>releases</id>
<activation>
<property>
<name>!releases.off</name>
</property>
</activation>
<repositories>
<repository>
<id>releases</id>
<url>https://my.remoterepository.com/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>snapshots</id>
<activation>
<property>
<name>!snapshots.off</name>
</property>
</activation>
<repositories>
<repository>
<id>snapshots</id>
<url>https://my.remoterepository.com/nexus/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
Edit: In response to the answer saying that the download occurs when the artifact is not there, below is the terminal output in which I prove the file was there in my repo but Maven is trying to download it anyway ...
Daves-MacBook-Pro-2:my-module davea$ ls -al ~/.m2/repository/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first-module-87.0.0-SNAPSHOT.jar
-rw-r--r-- 1 davea staff 10171 Nov 5 10:22 /Users/davea/.m2/repository/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first-module-87.0.0-SNAPSHOT.jar
Daves-MacBook-Pro-2:my-module davea$ mvn clean install
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.mainco.subco:my-module:jar:87.0.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-antrun-plugin # org.mainco.subco:my-module:[unknown-version], /Users/davea/Documents/sb_workspace/my-module/pom.xml, line 678, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-module 87.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://download.java.net/maven/2/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml
Downloaded: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml (788 B at 0.8 KB/sec)
Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first-module-87.0.0-20151106.043202-8.pom
Downloaded: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first- module-87.0.0-20151106.043202-8.pom (3 KB at 21.9 KB/sec)
Downloading: http://download.java.net/maven/2/org/mainco/subco/subco/87.0.0-SNAPSHOT/maven-metadata.xml
Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/subco/87.0.0-SNAPSHOT/maven-metadata.xml
The dependency has a snapshot version. For snapshots, Maven will check the local repository and if the artifact found in the local repository is too old, it will attempt to find an updated one in the remote repositories. That is probably what you are seeing.
Note that this behavior is controlled by the updatePolicy directive in the repository configuration (which is daily by default for snapshot repositories).
Use mvn --help and you can see the options list.
There is an option like -nsu,--no-snapshot-updates Suppress SNAPSHOT updates
So use command mvn install -nsu can force compile with local repository.
To truly force maven to only use your local repo, you can run with mvn <goals> -o. The -o tells maven to let you work "offline", and it will stay off the network.
Follow below steps:
Ensure to delete all the contents of the jar folder located in your local except the jar that you want to keep.
For example files like .repositories, .pom, .sha1, .lastUpdated etc.
Execute mvn clean install -o command
This will help to use local repository jar files rather than connecting to any repository.
Maven always checks your local repository first, however,your dependency needs to be installed in your repo for maven to find it.
Run mvn install in your dependency module first, and then build your dependent module.
In my case I had a multi module project just like you. I had to change a group Id of one of the external libraries my project was depending on as shown below.
From:
<dependencyManagement>
<dependency>
<groupId>org.thirdparty</groupId>
<artifactId>calculation-api</artifactId>
<version>2.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependencyManagement>
To:
<dependencyManagement>
<dependency>
<groupId>org.thirdparty.module</groupId>
<artifactId>calculation-api</artifactId>
<version>2.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependencyManagement>
Pay attention to the <groupId> section. It turned out that I was forgetting to modifiy the corresponding section of the submodules that define this dependency in their pom files.
It drove me very crazy because the module was available locally.
Even when considering all answers above you might still run into issues that will terminate your maven offline build with an error. Especially, you may experience a warning as follwos:
[WARNING] The POM for org.apache.maven.plugins:maven-resources-plugin:jar:2.6 is missing, no dependency information available
The warning will be immediately followed by further errors and maven will terminate.
For us the safest way to build offline with a maven offline cache created following the hints above is to use following maven offline parameters:
mvn -o -llr -Dmaven.repo.local=<path_to_your_offline_cache> ...
Especially, option -llr prevents you from having to tune your local cache as proposed in answer #4.
Also take care that parameter <localRepositoryin> in your settings.xml points to the correct folder of your local Maven repository.
The -o option didn't work for me because the artifact is still in development and not yet uploaded and maven (3.5.x) still tries to download it from the remote repository because it's the first time, according to the error I get.
However this fixed it for me: https://maven.apache.org/general.html#importing-jars
After this manual install there's no need to use the offline option either.
UPDATE
I've just rebuilt the dependency and I had to re-import it: the regular mvn clean install was not sufficient for me
I had the exact same problem. Running mvn clean install instead of mvn clean compile resolved it.
The difference only occurs when using multi-maven-project since the project dependencies are uploaded to the local repository by using install.
use <classpathentry kind="var" path="M2_REPO/your jar location
without creating any environment veriable
just to give my 2 cents. For me, it was only necessary to find the jar inside the ~/.m2/repository directory and use its version. So, after using
cd local-dependency/
mvn install
the local-dependency jar will be in the .m2/repository/com/your-organization/local-dependency/
~$ tree ~/.m2/repository/com/your-organization/local-dependency/
/home/felipe/.m2/repository/com/your-organization/local-dependency/
├── 0.1-SNAPSHOT
│   ├── maven-metadata-local.xml
│   ├── _remote.repositories
│   ├── local-dependency-0.1-SNAPSHOT.jar
│   ├── local-dependency-0.1-SNAPSHOT.pom
│   └── resolver-status.properties
└── maven-metadata-local.xml
then use it as a local dependency
<dependency>
<groupId>com.your-organization</groupId>
<artifactId>local-dependency</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>

How to store jars in github based maven repo

Ive setup a github repo to store custom archetypes, and I can start a new project off these archetypes (on separate vm) using something like
mvn archetype:generate -Dcatalog=https://raw.github.etc./archetype-catalog.xml
now i'm trying to store some 3rd party jars remotely in the same repo and reference them from a pom.xml as dependancies
First I installed the jar locally with
mvn install:install-file ..params..
the repo structure I have goes like:
https://github.com/myappco/myrepo
|
|___releases
| |
(group id)adobe.flex.messaging (ie. adobe/flex/messaging)
common
1.0
(common-1.0.jar)
* trying to make this work
|___snapshots
|
(group id)com.acme.archetypes (ie. com/acme/archetypes)
my-archetype
1.0-SNAPSHOT
* archetype resolved ok
archetype-catalog.xml
The settings in my project:
<dependency>
<groupId>adobe.flex.messaging</groupId>
<artifactId>common</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<repositories>
<repository>
<id>orb-snapshots</id>
<url>https://github.com/myappco/myrepo/releases</url>
</repository>
</repositories>
I think I must be doing something dumb, because I can archetype:generate from the github repo archetype-catalog.xml. Can anyone see what I messed up?
Ta
You need to deploy your artifacts in github using mvn deploy. You would need to have set up github appropriately - perhaps similar to what is mentioned in Hosting Maven Repos on Github.

Resources