Jenkins Gradle插件未使用本地maven存储库

时间:2016-12-10 13:14:14

标签: maven jenkins gradle android-gradle

我正在尝试使用Jenkins构建Android Gradle项目。 Gradle构建无法找到所需的依赖项。我在~/.m2/repository路径有maven存储库。但是,Gradle构建正在/var/lib/jenkins/.m2/repository位置查找依赖项。理想情况下,这应该在~/.m2/repository查找,这是本地存储库的默认路径。

以下是我的Gradle脚本:

apply plugin: 'com.android.library'

dependencies {
    compile 'com.android.support:support-v4:24.2.0'
    compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.1'
}
repositories {
    def androidHome = System.getenv("ANDROID_HOME")
    maven { url "$androidHome/extras/android/m2repository/" }
    mavenLocal()
    mavenCentral()
}

buildscript {
    repositories { mavenCentral() }
}

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    dexOptions {
        incremental true
        preDexLibraries = false
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

Jenkins构建失败并出现以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':myapp.base.module'.
> A problem occurred configuring project ':myapp.dependency.module'.
   > Could not resolve all dependencies for configuration ':myapp.dependency.module:_debugCompile'.
      > Could not find org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.1.
        Searched in the following locations:
            file:/home/pawan/Android/Sdk/extras/android/m2repository/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.1/org.eclipse.paho.client.mqttv3-1.0.1.pom
            file:/home/pawan/Android/Sdk/extras/android/m2repository/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.1/org.eclipse.paho.client.mqttv3-1.0.1.jar
            file:/var/lib/jenkins/.m2/repository/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.1/org.eclipse.paho.client.mqttv3-1.0.1.pom
            file:/var/lib/jenkins/.m2/repository/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.1/org.eclipse.paho.client.mqttv3-1.0.1.jar
            https://repo1.maven.org/maven2/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.1/org.eclipse.paho.client.mqttv3-1.0.1.pom
            https://repo1.maven.org/maven2/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.1/org.eclipse.paho.client.mqttv3-1.0.1.jar
            file:/home/pawan/Android/Sdk/extras/google/m2repository/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.1/org.eclipse.paho.client.mqttv3-1.0.1.pom
            file:/home/pawan/Android/Sdk/extras/google/m2repository/org/eclipse/paho/org.eclipse.paho.client.mqttv3/1.0.1/org.eclipse.paho.client.mqttv3-1.0.1.jar
        Required by:
            build-gradle-projects:myapp.dependency.module:unspecified

我觉得奇怪的是,异常显示Gradle正在/var/lib/jenkins/.m2查找依赖项:org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.1

我确认路径不存在。

0 个答案:

没有答案