Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ThatOneTallKid/727a605d1e204aa4180d4570ffb6b901 to your computer and use it in GitHub Desktop.

Select an option

Save ThatOneTallKid/727a605d1e204aa4180d4570ffb6b901 to your computer and use it in GitHub Desktop.

How to use github as a maven repository

Clone your original project to a new local repository (change ORGANIZATION-NAME and PROJECT-NAME)

git clone https://github.com/ORGANIZATION-NAME/PROJECT-NAME.git PROJECT-NAME-maven2

Go to the clonned repository (use your PROJECT-NAME-maven2)

cd PROJECT-NAME-maven2

Create a branch for maven files

git branch maven2

Switch to this new branch

git checkout maven2

Remove project original files, this branch is just for releases

rm -R ALL-PROJECT-FILES

run mvn install for jar creation (change GROUP, ARTIFACT-NAME, ARTIFACT-VERSION, PATH-TO-THE-JAR and PATH-TO-EXISTING-POM)

mvn install:install-file -DgroupId=GROUP -DartifactId=ARTIFACT-NAME -Dversion=ARTIFACT-VERSION \\
-Dfile=PATH-TO-THE-JAR -Dpackaging=jar -DlocalRepositoryPath=. -DcreateChecksum=true \\
-DpomFile=PATH-TO-EXISTING-POM

Use -DgeneratePom=true instead of -DpomFile=PATH-TO-EXISTING-POM to create POM

Add all files to be commited

git add .

Commit these changes

git commit -m "Released version ARTIFACT-VERSION"

Push this commit

git push origin maven2

Now maven structure for you project can be reached by github raw data address

https://github.com/ORGANIZATION-NAME/PROJECT-NAME/raw/maven2

On gradle you can add this repository on 'repositories'

maven { url "https://github.com/ORGANIZATION-NAME/PROJECT-NAME/raw/maven2" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment