android - 本地Maven存储库需要sudo通过Gradle解决 Artifact

标签 android maven gradle android-maven-plugin

我最近已经从maven-android-plugin迁移到基于Gradle的Android构建系统的v1.1。在进行了与hamcrest(以及相关的泛型 hell )相关的许多更改之后,我使基于Robolectric的单元测试在gradle下运行...但是仅当我使用sudo运行test gradle命令时。

运行类似./gradlew testWithGoogleMapsDebug的命令后我得到的错误

Unable to resolve artifact: Missing:
Caused by: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:

我已经检查了本地.m2存储库的权限,并chmod -R 777将存储库的根目录查看是否有任何影响(没有影响)。

我怀疑那里有人知道发生了什么,但是我有点卡住了!

...这是完整的踪迹;
Unable to resolve artifact: Missing:
----------
1) org.ccil.cowan.tagsoup:tagsoup:jar:1.2

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.ccil.cowan.tagsoup -DartifactId=tagsoup -Dversion=1.2 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.ccil.cowan.tagsoup -DartifactId=tagsoup -Dversion=1.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) org.apache.maven:super-pom:pom:2.0
    2) org.ccil.cowan.tagsoup:tagsoup:jar:1.2

2) org.json:json:jar:20080701

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.json -DartifactId=json -Dversion=20080701 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.json -DartifactId=json -Dversion=20080701 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) org.apache.maven:super-pom:pom:2.0
    2) org.json:json:jar:20080701

3) org.robolectric:android-all:jar:4.3_r2-robolectric-0

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=4.3_r2-robolectric-0 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.robolectric -DartifactId=android-all -Dversion=4.3_r2-robolectric-0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) org.apache.maven:super-pom:pom:2.0
    2) org.robolectric:android-all:jar:4.3_r2-robolectric-0

----------

...这是应用程序build.gradle,其中删除了敏感信息;
apply plugin: 'com.android.application'

android {
    compileSdkVersion 17
    buildToolsVersion "21.1.2"

    defaultConfig {
        // Keep original packaging package path.
        applicationId "my.app.id"
        minSdkVersion 11
        targetSdkVersion 19
        versionCode 25
        versionName "2.4.0"
        multiDexEnabled true
    }

    sourceSets {
        androidTest.setRoot('src/test')
    }

    signingConfigs {
        debug {
            storeFile file("debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }

        release {
            // Release signing detail.
        }
    }

    buildTypes {
        debug {
            debuggable true
            signingConfig signingConfigs.debug
            pseudoLocalesEnabled true
        }

        release {
            minifyEnabled false
            signingConfig signingConfigs.release
        }
    }

    productFlavors {
        withGoogleMaps {
            // Flavour-based config
        }

        withOsm {
            // Flavour-based config
        }
    }

    lintOptions {
        abortOnError false
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

repositories {
    mavenLocal()
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    compile project(':viewPagerIndicator')
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'joda-time:joda-time:2.7'
    compile 'de.keyboardsurfer.android.widget:crouton:1.8.5@aar'
    compile 'com.squareup.dagger:dagger:1.2.1'
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.google.guava:guava:18.0'
    compile 'com.github.amlcurran.showcaseview:library:5.1.1-SNAPSHOT'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'

    withGoogleMapsCompile 'com.google.android.gms:play-services-location:7.0.0'
    withGoogleMapsCompile 'com.google.android.gms:play-services-maps:7.0.0'
    withOsmCompile 'org.osmdroid:osmdroid-android:4.1'
    withOsmCompile 'org.osmdroid:osmbonuspack:4.4'
    withOsmCompile 'org.slf4j:slf4j-android:1.7.7'

    // Test dependencies.
    testCompile 'org.hamcrest:hamcrest-core:1.3'
    testCompile 'org.robolectric:robolectric:2.4'
    testCompile('org.mockito:mockito-core:1.9.5') {
        exclude group: 'org.hamcrest'
    }
    testCompile 'junit:junit:4.12'
    testCompile 'com.google.guava:guava:18.0'

    provided 'com.squareup.dagger:dagger-compiler:1.2.1'
}

configurations {
    // Avoid gradle warnings.
    all*.exclude module: 'commons-logging'
    all*.exclude module: 'httpclient'
}

...并且我正在运行Maven 3.1.1;
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 16:22:22+0100)
Maven home: /Users/me/Dropbox/Maven
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.1", arch: "x86_64", family: "mac"

最佳答案

所以...运行带有--info标志的构建,突出显示gradle正在尝试在硬盘驱动器的根目录下创建.m2文件夹。它没有这样做的权限(为什么?!)。

因此,“WTF”时刻就是为什么在gradle构建下运行单元测试时,它在驱动器的根部需要另一个.m2存储库的原因。迷失了...

关于android - 本地Maven存储库需要sudo通过Gradle解决 Artifact ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30088103/

相关文章:

intellij-idea - 如何使用 Intellij 为我的 gradle 项目设置本地托管端口?

android - 升级到 Gradle 2.6

java - Gson 缺少对象 ArrayList 的类型参数

android - 如何为按钮添加带渐变的波纹效果?

java - java.lang.NoSuchMethodError : com. fasterxml.jackson.databind.ObjectWriter.forType 错误 [Jasperreports] [Spring MVC]

gradle - 不要在 Gradle 中使用来自传递依赖的更高版本的库

android - Firebase 分析、自定义事件值

android - 无法通过设备管理 API 锁定设备

java - spring-boot-maven-plugin - 在随机端口启动 JMX

Maven:Surefire --dry-run?