当前位置: 首页 > 知识库问答 >
问题:

在错误的存储库中解析了Gradle依赖项

邢皓
2023-03-14

我已经将我的MavenLocal声明为我试图构建的Gradle项目的存储库:

buildscript {
    repositories {
        mavenLocal()
    }
}

maven缓存已经包含工件,包括工件c:\users\212636336\.m2\repository\com\jetbrains\intellij\idea\ideaiu\2016.2.5(pom和zip)。如果我在另一个Maven项目中添加了依赖关系,那么它将被正确加载:

    <dependencies>
        <dependency>
            <groupId>com.jetbrains.intellij.idea</groupId>
            <artifactId>ideaIU</artifactId>
            <version>2016.2.5</version>
        </dependency>

现在,我以调试和脱机模式-d build运行Gradle。我从MavenLocal获得了一些正确解析的工件,比如:

10:40:17.095 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for classworlds:classworlds:1.1-alpha-2 using repositories [MavenLocal, Gradle Central Plugin Repository]
10:40:17.095 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading file:/C:/Users/212636336/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.pom
10:40:17.096 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading file:/C:/Users/212636336/.m2/repository/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar
10:40:17.096 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Metadata file found for module 'classworlds:classworlds:1.1-alpha-2' in repository 'MavenLocal'.

但是,其中一个工件似乎被放到了另一个存储库中,显然没有找到(因为它是离线的,我必须离线,因为“安全网络访问原因”[我们不质疑这一点……]):

10:40:17.216 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.jetbrains.intellij.idea:ideaIU:2016.2.5 using repositories [maven]

它似乎试图在“Maven”存储库中解决这个问题,而不是“MavenLocal”(和Gradle repo)。

如何强制此依赖项(以及所有依赖项(如果其他依赖项稍后也失败))仅使用MavenLocal回购?

引号周围的更多日志行:

15:09:50.096 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on proj remapped class cache for 7rwuz20xh772cpzs4giq79qsx (C:\Users\212636336\.gradle\caches\4.8\scripts-remapped\build_18iha3p23efgp2pj2dagsrxjv\7rwuz20xh772cpzs4giq79qsx\projae602bbdde29eee3c9aedf6517e613d1).
15:09:50.097 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on proj remapped class cache for 7rwuz20xh772cpzs4giq79qsx (C:\Users\212636336\.gradle\caches\4.8\scripts-remapped\build_18iha3p23efgp2pj2dagsrxjv\7rwuz20xh772cpzs4giq79qsx\projae602bbdde29eee3c9aedf6517e613d1).
15:09:50.097 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on proj remapped class cache for 7rwuz20xh772cpzs4giq79qsx (C:\Users\212636336\.gradle\caches\4.8\scripts-remapped\build_18iha3p23efgp2pj2dagsrxjv\7rwuz20xh772cpzs4giq79qsx\projae602bbdde29eee3c9aedf6517e613d1).
15:09:50.262 [QUIET] [system.out] add repo
15:09:50.262 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Apply script build.gradle to root project 'phpinspectionsea''
15:09:50.262 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Apply script build.gradle to root project 'phpinspectionsea'' completed
15:09:50.263 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 2.809 secs
10:40:17.194 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring IntelliJ IDEA gradle plugin
10:40:17.195 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring patch plugin.xml task
10:40:17.195 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring prepare IntelliJ sandbox task
10:40:17.196 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring prepare IntelliJ sandbox task
10:40:17.196 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring plugin verification task
10:40:17.197 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring run IntelliJ task
10:40:17.198 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring building IntelliJ IDEA plugin task
10:40:17.199 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring publishing IntelliJ IDEA plugin task
10:40:17.199 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring IntelliJ resources task
10:40:17.200 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring IntelliJ compile tasks
10:40:17.202 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Apply plugin org.jetbrains.intellij to root project 'phpinspectionsea''
10:40:17.202 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Apply plugin org.jetbrains.intellij to root project 'phpinspectionsea'' completed
10:40:17.203 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Apply plugin com.palantir.git-version to root project 'phpinspectionsea'' started
10:40:17.206 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Apply plugin com.palantir.git-version to root project 'phpinspectionsea''
10:40:17.207 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Apply plugin com.palantir.git-version to root project 'phpinspectionsea'' completed
10:40:17.211 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Apply script build.gradle to root project 'phpinspectionsea''
10:40:17.211 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Apply script build.gradle to root project 'phpinspectionsea'' completed
10:40:17.212 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 0.379 secs
10:40:17.212 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Configuring IntelliJ IDEA dependency
10:40:17.212 [INFO] [org.jetbrains.intellij.IntelliJPlugin] Using IDE from remote repository
10:40:17.212 [DEBUG] [org.jetbrains.intellij.IntelliJPlugin] Adding IntelliJ IDEA repository: https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases
10:40:17.213 [DEBUG] [org.jetbrains.intellij.IntelliJPlugin] Adding IntelliJ IDEA dependency
10:40:17.213 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Resolve dependencies of :detachedConfiguration1' started
10:40:17.214 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver] Resolving configuration ':detachedConfiguration1'
10:40:17.215 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.ResolvedArtifactCaches] Creating new in-memory cache for repo 'maven' [73520db826dde63c67f6b3554017db77].
10:40:17.215 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder] Visiting configuration com.kalessil.phpStorm.phpInspectionsEA:phpinspectionsea:unspecified(detachedConfiguration1).
10:40:17.216 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.jetbrains.intellij.idea:ideaIU:2016.2.5 using repositories [maven]
10:40:17.217 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.oldresult.TransientConfigurationResultsBuilder] Flushing resolved configuration data in Binary store in C:\Users\212636336\AppData\Local\Temp\gradle3411383493479648862.bin. Wrote root 2.
10:40:17.219 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Resolve dependencies of :detachedConfiguration1'
10:40:17.219 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Resolve dependencies of :detachedConfiguration1' completed
10:40:17.220 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Configure project :'
10:40:17.221 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 417: dispatching class org.gradle.launcher.daemon.protocol.BuildEvent
10:40:17.222 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Configure project :' completed
10:40:17.222 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Configure build'
10:40:17.223 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 417: dispatching class org.gradle.launcher.daemon.protocol.BuildEvent
10:40:17.224 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Configure build' completed
10:40:17.224 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
10:40:17.225 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
10:40:17.225 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
10:40:17.225 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
10:40:17.225 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] A problem occurred configuring root project 'phpinspectionsea'.
10:40:17.225 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not resolve all files for configuration ':detachedConfiguration1'.
10:40:17.225 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]    > Could not resolve com.jetbrains.intellij.idea:ideaIU:2016.2.5.
10:40:17.226 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]      Required by:
10:40:17.226 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]          project :
10:40:17.226 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]       > No cached version of com.jetbrains.intellij.idea:ideaIU:2016.2.5 available for offline mode.

(似乎IntelliJ IDEA IU添加了它的“Maven”repo并覆盖了我在项目的build.gradle文件中设置的repo;我如何避免这种情况?)

共有1个答案

益麻雀
2023-03-14

如果mavenLocal回购被宣布,它应该会运作良好。我想知道您使用的IdeaPlugin是否正在做一些令人讨厌的事情,比如暂时删除maven本地回购。您可以使用以下钩子来检查和跟踪存储库的更改:


repositories.whenObjectAdded { repo ->
   ...
}

repositories.whenObjectRemoved { repo ->
   ...
}

 类似资料:
  • 我正在为我的项目使用Gradle,昨天我在构建项目时遇到了问题,因为https://plugins.gradle.org不起作用。那么有没有办法克隆依赖项

  • 像这样的问题有很多,但是似乎没有一个对我有效或者直接回答我的问题。 我正在使用Jhipster和MongoDB Atlas。Jhipster使用一个名为Mongobee的库,其中使用了一个适用于MongoDB的方法,但不适用于MongoDB Atlas。要启动,Mongobee似乎不再维护。 因此,我找到了某人的建议PR,他们将其发送给Mongobee进行审查,我接受了代码更改,将MongoBe分

  • 我的结构如下: 项目A- 项目B- 编译项目B一切正常: 项目B/build.gradle: ProjectB/settings.gradle: 然而,在编译ProjectA时,它表示找不到ProjectC ProjectA/build.gradle: ProjectA/settings.gradle: 这将显示以下错误: 其中:构建文件ProjectB\build.gradle 出了什么问题:

  • null 使用Jenkins Artifactory插件,我能够将这两个模块的JAR发布到Artifactory,但我的另一个依赖于的项目未能构建,出现以下gradle错误 找不到com.mygroup:lib-api:1.0.0-snapshot lib-api/build.gradle null null 我的理解是,ArtiFactory/Gradle应该足够聪明,能够将解析为最新的时间戳快

  • 我在获取 gradle 时遇到了麻烦,无法找到我放入私有 nexus 存储库中的依赖项。依赖性在maven中,但我似乎也无法让它在那里找到它。我确实把它放进了我的nexus存储库,位置 http://nexus.hq.chris.com/content/repositories/emoji4j/ 建筑格拉德尔·斯尼佩特 有谁知道我如何让 gradle 在 http://nexus.hq.chris