Maven
  1. Maven
  2. MNG-4494

Custom repository layout should be able to participate in repository instance creation

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0-alpha-5
    • Fix Version/s: 3.0-alpha-6
    • Component/s: None
    • Labels:
      None
    • Complexity:
      Intermediate
    • Patch Submitted:
      Yes
    • Number of attachments :
      0

      Description

      Custom repository layout, like p2, for example, may require special ArtifactRepository implementation and/or configuration to work along with regular maven repositories. To support this, custom repository layout implementations should be able to act as ArtifactRepository instance factories. Below is proposed trivial fix, but I'll try to commit this myself, assuming I can figure out what's wrong with my svn access.

      Index: maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java
      ===================================================================
      --- maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java	(revision 890982)
      +++ maven-compat/src/main/java/org/apache/maven/repository/legacy/repository/DefaultArtifactRepositoryFactory.java	(working copy)
       -26,6 +26,7 @@
       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 @@
                   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;
           }
      Index: maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout.java
      ===================================================================
      --- maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout.java	(revision 890982)
      +++ maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout.java	(working copy)
       -22,6 +22,7 @@
       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
      Index: maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout2.java
      ===================================================================
      --- maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout2.java	(revision 0)
      +++ maven-artifact/src/main/java/org/apache/maven/artifact/repository/layout/ArtifactRepositoryLayout2.java	(revision 0)
       -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 );
      +}
      

      Original problem and corresponding build failure: https://issues.sonatype.org/browse/TYCHO-324

        Activity

        Hide
        Igor Fedorenko added a comment -

        Implemented in r891083.

        Show
        Igor Fedorenko added a comment - Implemented in r891083.

          People

          • Assignee:
            Igor Fedorenko
            Reporter:
            Igor Fedorenko
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: