View Javadoc

1   package org.apache.maven.artifact.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 org.apache.maven.artifact.Artifact;
23  import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
24  import org.apache.maven.artifact.installer.ArtifactInstallationException;
25  import org.apache.maven.artifact.repository.ArtifactRepository;
26  import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
27  import org.apache.maven.artifact.resolver.ArtifactResolutionException;
28  import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
29  import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
30  
31  import java.util.List;
32  
33  public class DefaultArtifactTransformationManager
34      implements ArtifactTransformationManager, Initializable
35  {
36      private List<ArtifactTransformation> artifactTransformations;
37      
38  	public void initialize() throws InitializationException {
39  		// TODO this is a hack until plexus can fix the ordering of the arrays
40  		ArtifactTransformation transforms[] = artifactTransformations.toArray( new ArtifactTransformation[]{} );
41  		for (int x = 0; x < transforms.length; x++)
42  		{
43  			if (transforms[x].getClass().getName().indexOf("Snapshot") != -1) {
44  				artifactTransformations.remove(transforms[x]);
45  				artifactTransformations.add(transforms[x]);
46  			}
47  		}
48  	}
49      
50      public void transformForResolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
51          throws ArtifactResolutionException, ArtifactNotFoundException
52      {
53          for ( ArtifactTransformation transform : artifactTransformations )
54          {
55              transform.transformForResolve( artifact, remoteRepositories, localRepository );
56          }
57      }
58  
59      public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
60          throws ArtifactInstallationException
61      {
62          for ( ArtifactTransformation transform : artifactTransformations )
63          {
64              transform.transformForInstall( artifact, localRepository );
65          }
66      }
67  
68      public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
69                                          ArtifactRepository localRepository )
70          throws ArtifactDeploymentException
71      {
72          for ( ArtifactTransformation transform : artifactTransformations )
73          {
74              transform.transformForDeployment( artifact, remoteRepository, localRepository );
75          }
76      }
77  
78  
79  
80  }