【问题标题】:Build Github Package as Maven using Jitpack使用 Jitpack 将 Github 包构建为 Maven
【发布时间】:2015-06-26 18:16:45
【问题描述】:

有人可以指导我如何使用Jitpack 构建 github 项目。

我尝试按照此说明进行操作,但总是出错。我分叉了一个项目并在其上添加了一些更改,因此我需要获取当前的提交 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

【问题讨论】:

  • 你遇到了什么错误?
  • 类似'无法解析 com.github.username:repo:commitId' 我尝试更新代码并再次运行。现在gradle进程不会停止
  • 我想我会手动导入这个。我不知道我是否得到它,但似乎 gradle 正在同步将近一个小时并且没有返回任何消息。
  • @MightyMilk 您尝试使用的实际 GitHub 项目是什么?

标签: git maven github


【解决方案1】:

在这种情况下,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:v0.7.2.4@aar'
}

构建插件的存储库位于buildscripts 下,但普通依赖存储库仅位于repositories { 下。

【讨论】:

  • 我明白了。好的,让我试试这个。谢谢
  • 顺便说一句,如果我使用短提交 ID 作为版本,这仍然适用吗?我得到一个错误工件未找到
  • 无法解决:com.github.mightymilk:material-dialogs:v0.7.2.4 :(
  • 有时使用 '--refresh-dependencies' 运行 gradle 会有所帮助
  • @polasairam 似乎对我有用。什么错误?
【解决方案2】:

您是在尝试将其他人的 repo 导入到您的 repo 中,还是尝试让其他人可以使用您的 mightymilk/materialdialogs repo 以便他们可以导入它?

假设您正在尝试导入 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
@987654328 @ 带有您想用来访问特定提交的任何 ID; AFAIK git 标签可以工作,但不能保证稳定,散列 稳定,但不是很好。

假设您正在准备自己的 repo 以通过 Jitpack 包含

您使用了错误的说明。 请参阅 https://jitpack.io/docs/BUILDING 了解您的用例说明。

【讨论】:

    【解决方案3】:

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

    【讨论】:

      猜你喜欢
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 2019-04-26
      • 2020-03-21
      • 2021-01-30
      • 2021-07-07
      • 2016-06-25
      • 2018-10-05
      相关资源
      最近更新 更多