我已将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存储库)。
如何强制这种依赖关系(如果以后还会出现其他依赖关系,则强制所有依赖关系)仅使用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”存储库,并覆盖了我在项目的build.gradle
文件中设置的存储库;我该如何避免呢?)
答案 0 :(得分:0)
如果声明了mavenLocal回购,它应该可以正常工作。我想知道您使用的IdeaPlugin是否做得令人讨厌,例如暂时删除该Maven本地存储库。您可以使用以下挂钩检查并跟踪对存储库的更改:
repositories.whenObjectAdded { repo ->
...
}
repositories.whenObjectRemoved { repo ->
...
}