问题
I have setup an Archiva instance on my localhost using the default configuration. I have tried several different Gradle configs to resolve to the archiva instance, but none seem to work.
- using mavenRepo
- maven
- using Ivy and only specifying the artifact pattern (which worked when I used Ivy)
build.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()
I didn't think it was pertinent post any/all the subproject gradle files, but if you think it is necessary I can.
Is there something I'm missing here? Does gradle treat localhost urls differently than non-localhost (because the mavenCentral
dependencies are being resolved)? What do I have to do to get Gradle to resolve to a local instance of a Maven repo?
EDIT: @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
回答1:
The issue had to deal with Gradle's cache and my initial upload of the artifacts to the Archiva repo.
When you upload artifacts in Archiva you are given a choice to generate a Maven 2 POM, and I did not do that. As a result when Gradle went to resolve the dependencies in the Archiva repo, it didn't find the POMs that I assume it was looking for and thus couldn't resolve the dependencies.
The issue was solved by deleting the .gradle/caches
directory and simply calling build
to start from scratch.
来源:https://stackoverflow.com/questions/9378872/gradle-not-resolving-maven-repo-on-localhost