2015-04-20 20 views
6

有人可以请指导我如何使用Jitpack构建github项目。使用Jitpack将Github包构建为Maven

我试着按照这条指令,总是出错。我分叉了一个项目并在其上添加了一些更改,因此我需要获取当前的提交ID作为版本。

要获得GitHub的项目到您的构建:

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. 

这里是我的gradle这个文件

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

+0

你会得到什么错误? – NRKirby

+0

类似'无法解析com.github.username:repo:commitId'我尝试并更新代码并再次运行。现在gradle进程不会停止 –

+0

我想我只会手动导入。我不知道我是否已经得到它,但似乎差不多一个小时,Gradle正在同步并且不会返回任何消息。 –

回答

13

的JitPack库不应该buildscripts下在这种情况下。它应该是刚下库:

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:[email protected]' 
} 

库的构建插件都放在buildscripts下,但在正常的依赖库都只是放在repositories {下。

+0

我明白了。好的,让我试试这个。谢谢 –

+0

顺便说一句,如果我使用短提交ID作为版本,这仍然适用?我得到一个错误神器没有找到 –

+0

无法解决:com.github.mightymilk:材料对话框:v0.7.2.4 :( –

2

您是否试图将别人的回购项目导入您的回购项目,或者您是否试图让您的mightymilk/materialdialogs回购可供其他人使用,以便他们可以导入?

假设你要导入mattdesl/lwjgl-basics

的错误是在这里: //THIS ONE SEEMS NOT TO WORK BASE ON THE INSTRUCTION compile ('com.github.username:repo:commitId') 你需要更换:
username与用户名在GitHub上(例如mattdesl
repo的名称您正在访问的存储库(例如,lwjgl-basics
commitId使用您想要用来访问特定提交的任何ID; AFAIK git标签可以工作,但不能保证稳定,散列稳定,虽然不是很好。

假设你通过Jitpack

准备自己列入回购你走错了指令集。 有关您的用例说明,请参阅https://jitpack.io/docs/BUILDING

0

从gradle中删除依赖项'compile ......',只需添加存储库并将MPandroid图表jar文件粘贴到libs文件夹中即可。这对我有效。