【发布时间】:2014-04-15 20:33:52
【问题描述】:
我有两个项目。一个 Maven 和一个 Gradle。该公司还有一个内部 Maven 存储库。我正在尝试设置 Gradle 以使用内部存储库。使用 Intellij 13,当我将 repo 像这样添加到 build.gradle 中的 Gradle 时
build.gradle 文件:
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = 1.5
version = '1.0'
maven {
url "http://nexus.company.com/nexus/repo"
}
mavenLocal()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
.m2/settings.xml 似乎完全被 gradle 忽略了(我尝试不将 maven repo 添加到 build.gradle 文件中,并希望 gradle 会查看 .m2/settings.xml 以找出在哪里从中获取工件)
.m2/settings.xml 文件
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus.company.com/nexus/repo</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>central-repo</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>central-repo</activeProfile>
</activeProfiles>
</settings>
当 repo 为 http://nexus.company.com/nexus/repo 添加时,Intellij 在后台任务中永远旋转,说“处理索引”。没有它,一切都可以正常工作,只是内部工件无法下载。
但是,需要相同工件的 maven 项目会在几秒钟内下载并准备就绪。
我对 gradle 很陌生。我有没有搞错?
【问题讨论】:
-
Gradle 只使用
settings.xml来解析mavenLocal()。否则它不使用 Maven 文件,就像 Maven 不使用 Gradle 文件一样。关于无限索引,我建议向 IntelliJ 提交问题。 -
谢谢。有没有办法确保它是 Intellij 错误?是否有我可以在项目文件夹中运行的命令行工具来查看错误是与 Intellij 还是 Gradle 本身有关?
-
所以,通过添加 maven 内部存储库 url,只需在没有问题的项目文件中进行 gradle 构建。看起来像 Intellij 的问题。我会提交一个错误。谢谢
-
@BVSat 我也有同样的问题,你有没有来自 IDEA 的 bug 跟踪 ID?
-
@brentiumbrent - 是的 - youtrack.jetbrains.com/issue/IDEA-122087
标签: maven intellij-idea gradle maven-3 build.gradle