Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Github Package as Maven using Jitpack

Tags:

git

github

maven

can someone please guide me on how to build github projects using Jitpack.

I tried to follow this instruction and always got an error. I forked a project and added some changes on it so I need to get the current commit id as version.

To get a GitHub project into your build:

Step 1. Add the JitPack maven repository to your build file

    url "https://jitpack.io"

Step 2. Add the dependency in the form:

    Group: com.github.Username
    Artifact: Repository Name
    Version: Release tag or commit id

That's it! The first time you request a project JitPack checks out the code, builds it and sends the Jar files back to you.

Here is my gradle file

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://download.crashlytics.com/maven' }
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        classpath 'com.jakewharton.hugo:hugo-plugin:1.1.+'
        classpath 'com.stanfy.spoon:spoon-gradle-plugin:0.10.+'
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    }
}


dependencies {
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:22.0.0'

    //THIS ONE SEEMS NOT TO WORK BASE ON THE INSTRUCTION
    compile ('com.github.username:repo:commitId')
}

this is the project

like image 970
Mighty Milk Avatar asked Apr 20 '15 06:04

Mighty Milk


2 Answers

The JitPack repository shouldn't be under buildscripts in this case. It should be just under repositories:

buildscript {
 // same as you have but without jitpack.io
}

repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:22.0.0'

    compile 'com.github.mightymilk:material-dialogs:v0.7.2.4'
    // or if you just want the 'aar':
    //compile 'com.github.mightymilk:material-dialogs:v0.7.2.4@aar'
}

Repositories for build plugins are placed under buildscripts but normal dependency repositories are just placed under repositories {.

like image 78
metrimer Avatar answered Oct 21 '22 17:10

metrimer


Are you trying to import somebody else's repo into yours, or are you trying to make your mightymilk/materialdialogs repo available to other people so they can import it?

Assuming you are trying to import mattdesl/lwjgl-basics:

The error is here: //THIS ONE SEEMS NOT TO WORK BASE ON THE INSTRUCTION compile ('com.github.username:repo:commitId') You need to replace:
username with the user name on GitHub (e.g. mattdesl)
repo with the name of the repository you're accessing (e.g. lwjgl-basics)
commitId with whatever ID you want to use to access a specific commit; AFAIK git tags will work but aren't guaranteed to be stable, a hash will be stable though not as nice.

Assuming you are preparing your own repo for inclusion through Jitpack

You went to the wrong set of instructions. See https://jitpack.io/docs/BUILDING for the instructions for your use case.

like image 41
Toolforger Avatar answered Oct 21 '22 17:10

Toolforger