4

我已经使用默认配置在我的本地主机上设置了一个Archiva实例。我尝试了几种不同的 Gradle 配置来解析档案实例,但似乎都没有。

  1. 使用 mavenRepo
  2. 行家
  3. 使用 Ivy 并仅指定工件模式(当我使用 Ivy 时有效)

构建.gradle

subprojects {
    apply plugin: 'java'
    apply plugin: 'maven'

    repositories {
        mavenRepo url: 'http://localhost:8080/archiva', artifactUrls: [
            'http://localhost:8080/archiva/repository/internal',
            'http://localhost:8080/archiva/repository/snapshot'
        ]
        maven { url 'http://localhost:8080/archiva' }
        ivy {
            artifactPattern 'http://localhost:8080/archiva/repository/internal/[organisation]/[artifact]/[revision]/[artifact](-[revision]).[ext]'
        }
        mavenCentral()
    }

    dependencies {
        testCompile group: 'junit', name: 'junit', version: '4.10'
    }
}

dependsOnChildren()

我不认为发布任何/所有子项目 gradle 文件是相关的,但如果您认为有必要,我可以。

我在这里缺少什么吗?gradle 对 localhost url 的处理方式是否与非 localhost 不同(因为mavenCentral正在解析依赖项)?我需要做什么才能让 Gradle 解析为 Maven 存储库的本地实例?

编辑: @Peter Niederwieser

:/> gradle build
> Loading > Resolving dependencies ':projects:project-plugin-framework:classpat
:projects:compileJava UP-TO-DATE
:projects:processResources UP-TO-DATE
:projects:classes UP-TO-DATE
:projects:jar UP-TO-DATE
:projects:assemble UP-TO-DATE
:projects:compileTestJava UP-TO-DATE
:projects:processTestResources UP-TO-DATE
:projects:testClasses UP-TO-DATE
:projects:test UP-TO-DATE
:projects:check UP-TO-DATE
:projects:build UP-TO-DATE
:projects:project-plugin-framework:compileJava UP-TO-DATE
:projects:project-plugin-framework:processResources UP-TO-DATE
:projects:project-plugin-framework:classes UP-TO-DATE
:projects:project-plugin-framework:jar UP-TO-DATE
:projects:project:compileJava UP-TO-DATE
:projects:project:processResources UP-TO-DATE
:projects:project:classes UP-TO-DATE
:projects:project:jar UP-TO-DATE
:projects:project:assemble UP-TO-DATE
:projects:project:compileTestJava UP-TO-DATE
:projects:project:processTestResources UP-TO-DATE
:projects:project:testClasses UP-TO-DATE
> Building > :projects:project:test > Resolving dependencies ':projects:mag
:projects:project:test

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':projects:project:tes
tRuntime'.
> Could not find group:jspf, module:jspf.core, version:1.0.2.
  Required by:
      Project.projects:project:0.0.1
      Project.projects:project:0.0.1 > Project.projects:project-pl
ugin-framework:0.0.1
> Could not find any version that matches group:erichschroeter, module:applib, v
ersion:latest.integration.
  Required by:
      Project.projects:project:0.0.1
      Project.projects:project:0.0.1 > Project.projects:project-pl
ugin-framework:0.0.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 12.61 secs
4

1 回答 1

6

该问题必须处理 Gradle 的缓存以及我最初将工件上传到Archiva存储库的问题。

当您在 Archiva 中上传工件时,您可以选择生成 Maven 2 POM,而我没有这样做。结果,当 Gradle 去解决 Archiva 存储库中的依赖关系时,它没有找到我认为它正在寻找的 POM,因此无法解决依赖关系。

该问题已通过删除.gradle/caches目录并简单地调用build从头开始解决。

于 2012-02-21T17:42:01.553 回答