View Javadoc

1   package org.apache.maven.repository.legacy.resolver.transform;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.List;
23  
24  import org.apache.maven.artifact.Artifact;
25  import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
26  import org.apache.maven.artifact.installer.ArtifactInstallationException;
27  import org.apache.maven.artifact.repository.ArtifactRepository;
28  import org.apache.maven.artifact.repository.RepositoryRequest;
29  import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
30  import org.apache.maven.artifact.resolver.ArtifactResolutionException;
31  import org.codehaus.plexus.component.annotations.Component;
32  import org.codehaus.plexus.component.annotations.Requirement;
33  
34  /**
35   * @author Jason van Zyl
36   */
37  @Component( role = ArtifactTransformationManager.class )
38  public class DefaultArtifactTransformationManager
39      implements ArtifactTransformationManager
40  {
41      @Requirement( role = ArtifactTransformation.class, hints = { "release", "latest", "snapshot" } )
42      private List<ArtifactTransformation> artifactTransformations;
43  
44      public void transformForResolve( Artifact artifact, RepositoryRequest request )
45          throws ArtifactResolutionException, ArtifactNotFoundException
46      {
47          for ( ArtifactTransformation transform : artifactTransformations )
48          {
49              transform.transformForResolve( artifact, request );
50          }
51      }
52  
53      public void transformForResolve( Artifact artifact, List<ArtifactRepository> remoteRepositories,
54                                       ArtifactRepository localRepository )
55          throws ArtifactResolutionException, ArtifactNotFoundException
56      {
57          for ( ArtifactTransformation transform : artifactTransformations )
58          {
59              transform.transformForResolve( artifact, remoteRepositories, localRepository );
60          }
61      }
62  
63      public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
64          throws ArtifactInstallationException
65      {
66          for ( ArtifactTransformation transform : artifactTransformations )
67          {
68              transform.transformForInstall( artifact, localRepository );
69          }
70      }
71  
72      public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
73                                          ArtifactRepository localRepository )
74          throws ArtifactDeploymentException
75      {
76          for ( ArtifactTransformation transform : artifactTransformations )
77          {
78              transform.transformForDeployment( artifact, remoteRepository, localRepository );
79          }
80      }
81  
82      public List getArtifactTransformations()
83      {
84          return artifactTransformations;
85      }
86  }