robolectric-gradle-plugin icon indicating copy to clipboard operation
robolectric-gradle-plugin copied to clipboard

local maven/gradle Proxy settings won't work in robolectric execution.

Open marslo opened this issue 6 years ago • 0 comments

Due to our build machine situation. There's no internet connection. All plugins, dependencies and packages come from intranet cache/repo server. we are using the Artifactory for it.

So, when I tried to test by using: $ gradle --full-stacktrace --refresh-dependencies clean assembleRelease testDebugUnitTest --debug --info

Error shows as below:

...
Successfully started process 'Gradle Test Executor 1'
Initialized native services in: /home/myadmin/.gradle/native
Gradle Test Executor 1 started executing tests.

com.myfeature.ApiSignUnitTest > apiSign_isCorrect STANDARD_ERROR
    Downloading: org/robolectric/android-all/8.0.0_r4-robolectric-r1/android-all-8.0.0_r4-robolectric-r1.pom from repository sonatype at https://oss.sonatype.org/content/groups/public/
    Error transferring file: Connection timed out (Connection timed out)

com.myfeature.ApiSignUnitTest > apiSign_isCorrect STANDARD_OUT
    [WARNING] Unable to get resource 'org.robolectric:android-all:pom:8.0.0_r4-robolectric-r1' from repository sonatype (https://oss.sonatype.org/content/groups/public/): Error transferring file: Connection timed out (Connection timed out)

com.myfeature.ApiSignUnitTest > apiSign_isCorrect STANDARD_ERROR
    Downloading: org/robolectric/android-all/8.0.0_r4-robolectric-r1/android-all-8.0.0_r4-robolectric-r1.pom from repository central at http://repo1.maven.org/maven2
    Error transferring file: Connection timed out (Connection timed out)

com.myfeature.ApiSignUnitTest > apiSign_isCorrect STANDARD_OUT
    [WARNING] Unable to get resource 'org.robolectric:android-all:pom:8.0.0_r4-robolectric-r1' from repository central (http://repo1.maven.org/maven2): Error transferring file: Connection timed out (Connection timed out)
...
com.myfeature.ApiSignUnitTest > apiSign_isCorrect FAILED
    Unable to resolve artifact: Missing:
    ----------
    1) org.robolectric:android-all:jar:8.0.0_r4-robolectric-r1

      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=8.0.0_r4-robolectric-r1 -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=8.0.0_r4-robolectric-r1 -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:8.0.0_r4-robolectric-r1

    ----------
    1 required artifact is missing.

    for artifact:
      org.apache.maven:super-pom:pom:2.0

    from the specified remote repositories:
      central (http://repo1.maven.org/maven2),
      sonatype (https://oss.sonatype.org/content/groups/public/)

        Caused by:
        org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
        ----------
        1) org.robolectric:android-all:jar:8.0.0_r4-robolectric-r1

          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=8.0.0_r4-robolectric-r1 -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=8.0.0_r4-robolectric-r1 -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:8.0.0_r4-robolectric-r1

        ----------
        1 required artifact is missing.

        for artifact:
          org.apache.maven:super-pom:pom:2.0

        from the specified remote repositories:
          central (http://repo1.maven.org/maven2),

2 tests completed, 1 failed
          sonatype (https://oss.sonatype.org/content/groups/public/)

The build.gradle as below:

buildscripts {
    repositories {
        maven {
            url 'http://my.artifactory.com/artifactory/gradle'
        }
    }
}
...
allprojects {
    repositories {
        maven {
            url 'http://my.artifactory.com/artifactory/gradle'
        }
    }
}
...
android {
    testCompile "org.robolectric:robolectric:3.6.1"
}
...

The ~/.gradle/gradle.properties:

org.gradle.daemon=false
org.gradle.jvmargs=-Xmx2048M
systemProp.http.proxyHost=192.168.1.2
systemProp.http.proxyPort=123
systemProp.https.proxyHost=192.168.1.2
systemProp.https.proxyPort=123
systemProp.http.nonProxyHosts=*.mycompany.com|localhost
systemProp.https.nonProxyHosts=*.mycompany.com|localhost
artifactory_contextUrl=http://my.artifactory.com/artifactory
systemProp.sonar.host.url=http://my.sonar.com
systemProp.sonar.login=xxxxxxxxxxxxxxxxxxxxxxxxxx

robolectric in ~/.gradle:

$ find ~/.gradle -name "*robolectric*"
/home/myadmin/.gradle/caches/modules-2/files-2.1/org.robolectric
/home/myadmin/.gradle/caches/modules-2/files-2.1/org.robolectric/android-all/8.0.0_r4-robolectric-r1
/home/myadmin/.gradle/caches/modules-2/files-2.1/org.robolectric/android-all/8.0.0_r4-robolectric-r1/30f97bebb50be3a1af9e12cb999360e1cdd2aaa5/android-all-8.0.0_r4-robolectric-r1.jar
/home/myadmin/.gradle/caches/modules-2/files-2.1/org.robolectric/android-all/8.0.0_r4-robolectric-r1/b6f839c158ec9d0044c95f1db5a540a9f5f248e3/android-all-8.0.0_r4-robolectric-r1.pom
/home/myadmin/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric
/home/myadmin/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric/3.6.1/26cfb22e682110716ccd516da2f2851016b3efae/robolectric-3.6.1.jar
/home/myadmin/.gradle/caches/modules-2/files-2.1/org.robolectric/robolectric/3.6.1/cb01d1161d258693d5efe1a8fbc1e6185cecb76e/robolectric-3.6.1.pom
/home/myadmin/.gradle/caches/modules-2/metadata-2.23/descriptors/org.robolectric
/home/myadmin/.gradle/caches/modules-2/metadata-2.23/descriptors/org.robolectric/android-all/8.0.0_r4-robolectric-r1
/home/myadmin/.gradle/caches/modules-2/metadata-2.23/descriptors/org.robolectric/robolectric

The proxy settings:

$ echo $http_proxy
http://192.168.1.2:123
$ echo $https_proxy
http://192.168.1.2:123
$ echo $ftp_proxy
http://192.168.1.2:123

The connection situation:

$ curl https://oss.sonatype.org/content/groups/public/  | head -15
<html>
  <head>
    <title>Index of /groups/public</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <link rel="icon" type="image/png" href="https://oss.sonatype.org/favicon.png">
    <!--[if IE]>
    <link rel="SHORTCUT ICON" href="https://oss.sonatype.org/favicon.ico"/>
    <![endif]-->

    <link rel="stylesheet" href="https://oss.sonatype.org/static/css/Sonatype-content.css?2.14.8-01" type="text/css" media="screen" title="no title" charset="utf-8">
  </head>
  <body>
    <h1>Index of /groups/public</h1>

$ curl http://repo1.maven.org/maven2 | head -10
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   313  100   313    0     0    944      0 --:--:-- --:--:-- --:--:--   942
<html>
<head><title>302 Moved Temporarily</title></head>
<body>
<h1>302 Moved Temporarily</h1>
<ul>
<li>Code: Found</li>
<li>Message: Resource Found</li>
<li>RequestId: 198001E6C2630EF9</li>
<li>HostId: maq+i8mADh4Zv5phhVTStg2dukFigpgJTPBsNGiLvR4rpwTShYenqCt1XdSGWREUhTIcmD0L/VU=</li>
</ul>

Maven settings.xml for Artifactory:

$ grep artifactory ~/.m2/settings.xml
          <url>http://my.artifactory.com/artifactory/libs-release</url>
          <url>http://my.artifactory.com/artifactory/libs-snapshot</url>
          <url>http://my.artifactory.com/artifactory/libs-release</url>
          <url>http://my.artifactory.com/artifactory/libs-snapshot</url>
      <id>artifactory</id>
    <activeProfile>artifactory</activeProfile>

marslo avatar Apr 11 '18 09:04 marslo