0

From my network i can't access https://repo.maven.apache.org/maven2 repository, so i have to point proxy like http://nexus.companyproxy.com:8099/nexus/content/groups/public My configuration contains only this

repositories { 
   maven("http://nexus.companyproxy.com:8099/nexus/content/groups/public") 
}  

but when I run gradle with —debug I see many errors Caused by:

org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.3.41/kotlin-c...

After this unsuccessful requests it download dependency from proper repository (proxy), but why i can't avoid such problem?

Seldon
  • 43
  • 5
  • I'm not sure if is thing of the syntax: ```repositories { maven { url 'http://repo.mycompany.com/maven2' } } ``` That's the way used in the docs: https://docs.gradle.org/current/userguide/declaring_repositories.html – sirandy Oct 17 '19 at 21:35
  • org.gradle.kotlin.dsl.RepositoryHandlerExtensions `fun RepositoryHandler.maven(url: Any) = maven { it.setUrl(url) }` So my syntax is correct – Seldon Oct 18 '19 at 06:22

1 Answers1

0

Your question is old, but I had the same issue last days and google redirect me to your post.

In the logs I can see that Gradle uses my local artifactory, then it switches to the default remote repository:

15:04:47  2022-02-17T15:04:47.572+0100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Download http://artifactory.mycompany.local/artifactory/maven/org/mockito/mockito-core/maven-metadata.xml'
15:04:47  2022-02-17T15:04:47.572+0100 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Download http://artifactory.mycompany.local/artifactory/maven/org/mockito/mockito-core/maven-metadata.xml' completed
15:04:47  2022-02-17T15:04:47.576+0100 [DEBUG] [org.gradle.api.internal.artifacts.repositories.maven.MavenMetadataLoader] parsing maven-metadata: org.gradle.internal.resource.local.DefaultLocallyAvailableExternalResource@5568cd26
15:04:47  2022-02-17T15:04:47.585+0100 [DEBUG] [org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor] Constructing external resource: https://repo.maven.apache.org/maven2/org/mockito/mockito-core/maven-metadata.xml
...
15:06:24  2022-02-17T15:06:21.731+0100 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.12.215] failed: connect timed out
...
15:06:24  2022-02-17T15:06:21.731+0100 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 2m 35s

I suppose that Gradle tries to list the versions from all repositories to define the latest version '2.+'. However the connection to the repo.maven.apache.org/maven2 repository is not possible, so the build fails in my case.

My solution was to to change the version from '2.+' to a fixed version in the build.gradle file, i.e.:

    testCompile group: 'org.mockito', name: 'mockito-core', version: '2.+'

to

    testCompile group: 'org.mockito', name: 'mockito-core', version: '2.28.2'
Sirius
  • 303
  • 2
  • 8