Ernest Duodu Ernest is a developer at IDRSolutions. He focuses mainly on our JavaFX PDF Viewer implementation. He was a speaker at JavaOne 2014, where he did a joint session titled "Lessons learnt developing a NetBeans PDF viewer plugin in JavaFX". Aside programming, he also enjoys a wide variety of hobbies which includes sky-diving, photography, exercising and listening to music.

How to use GitHub hosted Maven artifact in NetBeans IDE

1 min read

In my previous article I wrote, we went through a step by step process of creating a GitHub account and hosting our Maven artifact on it. In this article, I will show you how to use that artifact we hosted on GitHub as a dependency in a new maven project.
At this stage i take it as you already have your artifact already hosted on GitHub. If not, you can follow this article to learn how to do so.

Steps to how to use GitHub hosted Maven artifact in a Maven Project

Create a new Maven Java Application. I will be using NetBeans for this tutorial.

Screen Shot 2015-06-03 at 10.46.54
Give it a Project Name, Group Id and Version, click here to learn more about Maven projects I will call mine TestMven and leave the rest as default.

Screen Shot 2015-06-03 at 11.17.31
Once done, right click on the project and select Open POM. You should see something like this.

<!--?xml version="1.0" encoding="UTF-8"?-->
 
    4.0.0
    com.mycompany
    TestMaven
    1.0-SNAPSHOT
    jar
 
        UTF-8
        1.7
        1.7

Now in your POM, we have to specify where our GitHuB repository is and also all dependencies. To do so, edit the xml below and paste after the closing properties tag.

             {GIT-USERNAME}
            {NAME-OF-GIT-REPOSITORY}
            {GIT-REPOSITORY-URL}
 
 
 
 
 
 
            {GROUP-ID-OF-ARTIFACT}
           {NAME-OF-ARTIFACT}
           {VERSION-NUMBER}
           compile

In my case, this should be

<!--?xml version="1.0" encoding="UTF-8"?-->
 
    4.0.0
    org.jpedalh
    TestMaven
    1.0-SNAPSHOT
    jar
 
        UTF-8
        1.7
        1.7
 
 
 
 
       moshhasa
      maven-test-repo
      https://github.com/moshhasa/maven-test-repo/raw/master/
 
 
 
 
 
      org.jpedal
      FooBar
      1.0
      compile

Now save the Pom file and do a Clean and Build on your project. You should see Maven downloading your artifact from GitHub.This will me saved in your local repository.

Screen Shot 2015-06-03 at 11.46.48
Once done, Open the Dependencies folder in the Projects view and you should see the jar added to your project.

Screen Shot 2015-06-03 at 11.51.55
Now Test Your Dependency.

Screen Shot 2015-06-03 at 12.45.42
Hopefully you have found this quick guide useful. In my next article i will show you how I converted the Ant NetBeans Plugin to Maven Plugin

IDRsolutions develop a Java PDF Viewer and SDK, an Adobe forms to HTML5 forms converter, a PDF to HTML5 converter and a Java ImageIO replacement. On the blog our team post anything interesting they learn about.

Ernest Duodu Ernest is a developer at IDRSolutions. He focuses mainly on our JavaFX PDF Viewer implementation. He was a speaker at JavaOne 2014, where he did a joint session titled "Lessons learnt developing a NetBeans PDF viewer plugin in JavaFX". Aside programming, he also enjoys a wide variety of hobbies which includes sky-diving, photography, exercising and listening to music.

Leave a Reply

Your email address will not be published. Required fields are marked *