From f5ad9a458ad46e2ed5b0ef54160db21fd542c5b9 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Mon, 11 Oct 2010 21:01:06 +0000 Subject: [PATCH] o Fixed lazy repo creation to cache result repo git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1021505 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/project/MavenProject.java | 64 ++++++++++++------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java index 768d0ce65f..adafa6f41a 100644 --- a/maven-core/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-core/src/main/java/org/apache/maven/project/MavenProject.java @@ -1844,43 +1844,59 @@ public class MavenProject protected ArtifactRepository getReleaseArtifactRepository() { - if ( getDistributionManagement() != null && getDistributionManagement().getRepository() != null ) + if ( releaseArtifactRepository == null ) { - try - { - ArtifactRepository repo = - repositorySystem.buildArtifactRepository( getDistributionManagement().getRepository() ); - repositorySystem.injectProxy( projectBuilderConfiguration.getRepositorySession(), Arrays.asList( repo ) ); - repositorySystem.injectAuthentication( projectBuilderConfiguration.getRepositorySession(), - Arrays.asList( repo ) ); - setReleaseArtifactRepository( repo ); - } - catch ( InvalidRepositoryException e ) + if ( getDistributionManagement() != null && getDistributionManagement().getRepository() != null ) { + try + { + ArtifactRepository repo = + repositorySystem.buildArtifactRepository( getDistributionManagement().getRepository() ); + repositorySystem.injectProxy( projectBuilderConfiguration.getRepositorySession(), + Arrays.asList( repo ) ); + repositorySystem.injectAuthentication( projectBuilderConfiguration.getRepositorySession(), + Arrays.asList( repo ) ); + setReleaseArtifactRepository( repo ); + } + catch ( InvalidRepositoryException e ) + { + if ( logger != null ) + { + logger.debug( "Failed to create release distribution repository for " + getId(), e ); + } + } } } - + return releaseArtifactRepository; } protected ArtifactRepository getSnapshotArtifactRepository() { - if ( getDistributionManagement() != null && getDistributionManagement().getSnapshotRepository() != null ) + if ( snapshotArtifactRepository == null ) { - try - { - ArtifactRepository repo = - repositorySystem.buildArtifactRepository( getDistributionManagement().getSnapshotRepository() ); - repositorySystem.injectProxy( projectBuilderConfiguration.getRepositorySession(), Arrays.asList( repo ) ); - repositorySystem.injectAuthentication( projectBuilderConfiguration.getRepositorySession(), - Arrays.asList( repo ) ); - setSnapshotArtifactRepository( repo ); - } - catch ( InvalidRepositoryException e ) + if ( getDistributionManagement() != null && getDistributionManagement().getSnapshotRepository() != null ) { + try + { + ArtifactRepository repo = + repositorySystem.buildArtifactRepository( getDistributionManagement().getSnapshotRepository() ); + repositorySystem.injectProxy( projectBuilderConfiguration.getRepositorySession(), + Arrays.asList( repo ) ); + repositorySystem.injectAuthentication( projectBuilderConfiguration.getRepositorySession(), + Arrays.asList( repo ) ); + setSnapshotArtifactRepository( repo ); + } + catch ( InvalidRepositoryException e ) + { + if ( logger != null ) + { + logger.debug( "Failed to create snapshot distribution repository for " + getId(), e ); + } + } } } - + return snapshotArtifactRepository; }