gradle 在 mavenLocal 仓库中找不到 jar
gradle not finding jar in mavenLocal repo
我依赖 spring-beans;4.0.0.RELEASE,我使用
安装到我的 mavenLocal 缓存中
mvn install:install-file -Dfile=/Users/jric/Downloads/spring-beans-4.0.0.RELEASE.jar -DpomFile=/Users/jric/Downloads/spring-beans-4.0.0.RELEASE.pom
,
但是 gradle-1.11 没有找到依赖项,没有太多解释。我确实找到了这个看起来相关的堆栈跟踪:
11:26:35.432 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver] Discarding resolve failure.
java.lang.NullPointerException
at org.gradle.api.internal.artifacts.repositories.resolver.MavenLocalResolver.isOrphanedPom(MavenLocalResolver.java:49)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenLocalResolver.findMetaDataArtifact(MavenLocalResolver.java:42)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:165)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.getDependency(MavenResolver.java:83)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LocalModuleVersionRepository.getLocalDependency(LocalModuleVersionRepository.java:44)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.CachedRepository.getLocalDependency(CachedRepository.java:67)
这里有一些可能更相关的数据:
SCML-JRichardson:share jric$ ls /Users/jric/.m2/repository/org/springframework/spring-beans/
4.0.0.RELEASE maven-metadata-local.xml
SCML-JRichardson:share jric$ cat /Users/jric/.m2/repository/org/springframework/spring-beans/maven-metadata-local.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<versioning>
<release>4.0.0.RELEASE</release>
<versions>
<version>4.0.0.RELEASE</version>
</versions>
<lastUpdated>20150307021047</lastUpdated>
</versioning>
</metadata>
SCML-JRichardson:share jric$ ls /Users/jric/.m2/repository/org/springframework/spring-beans/4.0.0.RELEASE/
_maven.repositories spring-beans-4.0.0.RELEASE.jar spring-beans-4.0.0.RELEASE.pom
Gradle有一个特殊的语句可以在本地Maven仓库中查找:mavenLocal()。确保在全局存储库部分调用它:
repositories {
mavenLocal() // <- Here
mavenCentral()
}
如果它不起作用,请确保您没有无意中将它添加到构建脚本部分。这会将依赖项添加到您的构建环境而不是您的代码,这通常不是您想要的。
buildscript { // <- Probably not what you mean
repositories {
mavenLocal()
mavenCentral()
}
}
我依赖 spring-beans;4.0.0.RELEASE,我使用
安装到我的 mavenLocal 缓存中mvn install:install-file -Dfile=/Users/jric/Downloads/spring-beans-4.0.0.RELEASE.jar -DpomFile=/Users/jric/Downloads/spring-beans-4.0.0.RELEASE.pom
,
但是 gradle-1.11 没有找到依赖项,没有太多解释。我确实找到了这个看起来相关的堆栈跟踪:
11:26:35.432 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver] Discarding resolve failure.
java.lang.NullPointerException
at org.gradle.api.internal.artifacts.repositories.resolver.MavenLocalResolver.isOrphanedPom(MavenLocalResolver.java:49)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenLocalResolver.findMetaDataArtifact(MavenLocalResolver.java:42)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:165)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.getDependency(MavenResolver.java:83)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LocalModuleVersionRepository.getLocalDependency(LocalModuleVersionRepository.java:44)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.CachedRepository.getLocalDependency(CachedRepository.java:67)
这里有一些可能更相关的数据:
SCML-JRichardson:share jric$ ls /Users/jric/.m2/repository/org/springframework/spring-beans/
4.0.0.RELEASE maven-metadata-local.xml
SCML-JRichardson:share jric$ cat /Users/jric/.m2/repository/org/springframework/spring-beans/maven-metadata-local.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<versioning>
<release>4.0.0.RELEASE</release>
<versions>
<version>4.0.0.RELEASE</version>
</versions>
<lastUpdated>20150307021047</lastUpdated>
</versioning>
</metadata>
SCML-JRichardson:share jric$ ls /Users/jric/.m2/repository/org/springframework/spring-beans/4.0.0.RELEASE/
_maven.repositories spring-beans-4.0.0.RELEASE.jar spring-beans-4.0.0.RELEASE.pom
Gradle有一个特殊的语句可以在本地Maven仓库中查找:mavenLocal()。确保在全局存储库部分调用它:
repositories {
mavenLocal() // <- Here
mavenCentral()
}
如果它不起作用,请确保您没有无意中将它添加到构建脚本部分。这会将依赖项添加到您的构建环境而不是您的代码,这通常不是您想要的。
buildscript { // <- Probably not what you mean
repositories {
mavenLocal()
mavenCentral()
}
}