Skip to content

Commit

Permalink
[JENKINS-8383] Maven 2.2 Project does not return a BuilderConfiguration,
Browse files Browse the repository at this point in the history
only resolve parent artifact for Maven 3+

Originally-Committed-As: b82d07712e5003cebace29e5d25fdc61f1751390
  • Loading branch information
Stephan Pauxberger committed Oct 12, 2011
1 parent 02a08e0 commit 3022895
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/main/java/hudson/maven/reporters/MavenFingerprinter.java
Expand Up @@ -160,32 +160,13 @@ private void recordParents(MavenBuildProxy build, MavenProject pom) throws IOExc
}

private ArtifactRepository getLocalRepository(String mavenVersion, MavenProject parent) {
if (mavenVersion.startsWith("2.0")) return null;

if (mavenVersion.startsWith("2.")) {
return getMaven22LocalRepository(parent);
}
if (mavenVersion.startsWith("2.")) return null;

// Maven 3
return parent.getProjectBuildingRequest()
.getLocalRepository();
}


private ArtifactRepository getMaven22LocalRepository(MavenProject parent) {
ProjectBuilderConfiguration projectBuilderConfiguration;
try {
// Since maven-plugin is compiled against maven-core-3x, we need to retrieve
// this maven 2 object via reflection
Method method = MavenProject.class.getMethod("getProjectBuilderConfiguration");
projectBuilderConfiguration = (ProjectBuilderConfiguration) method.invoke(parent);
return projectBuilderConfiguration.getLocalRepository();
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Could not retrieve BuilderConfigration", e);
return null;
}
}

private void record(Collection<Artifact> artifacts, Map<String,String> record) throws IOException, InterruptedException {
for (Artifact a : artifacts)
record(a,record);
Expand Down

0 comments on commit 3022895

Please sign in to comment.