From 837eb821f1063dd12c84cef82f44e0efc9b2585e Mon Sep 17 00:00:00 2001 From: Igor Fedorenko Date: Wed, 16 Dec 2009 00:34:19 +0000 Subject: [PATCH] [MNG-4494] allow custom ArtifactRepository configuration and implementation Issue id: MNG-4494 git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@891083 13f79535-47bb-0310-9956-ffa450edef68 --- .../layout/ArtifactRepositoryLayout.java | 1 + .../layout/ArtifactRepositoryLayout2.java | 31 +++++++++++++++++++ .../DefaultArtifactRepositoryFactory.java | 13 +++++++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout2.java diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout.java index d317b2aed0..492f0cec59 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout.java @@ -22,6 +22,7 @@ package org.apache.maven.artifact.repository.layout; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; /** @author jdcasey */ public interface ArtifactRepositoryLayout diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout2.java b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout2.java new file mode 100644 index 0000000000..63bd607a4b --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout2.java @@ -0,0 +1,31 @@ +package org.apache.maven.artifact.repository.layout; + +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public interface ArtifactRepositoryLayout2 + extends ArtifactRepositoryLayout +{ + + ArtifactRepository newMavenArtifactRepository( String id, String url, ArtifactRepositoryPolicy snapshots, + ArtifactRepositoryPolicy releases ); +} diff --git a/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java b/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java index ad190157b2..52303152b9 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java @@ -26,6 +26,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @@ -124,7 +125,17 @@ public class DefaultArtifactRepositoryFactory releases.setChecksumPolicy( globalChecksumPolicy ); } - ArtifactRepository repository = new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases ); + ArtifactRepository repository; + if ( repositoryLayout instanceof ArtifactRepositoryLayout2 ) + { + repository = + ( (ArtifactRepositoryLayout2) repositoryLayout ).newMavenArtifactRepository( id, url, snapshots, + releases ); + } + else + { + repository = new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases ); + } return repository; }