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; }