Coverage Report - org.apache.maven.artifact.transform.DefaultArtifactTransformationManager
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultArtifactTransformationManager
100 %
16/16
100 %
10/10
0
 
 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  13
 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  13
                 ArtifactTransformation transforms[] = artifactTransformations.toArray( new ArtifactTransformation[]{} );
 41  52
                 for (int x = 0; x < transforms.length; x++)
 42  
                 {
 43  39
                         if (transforms[x].getClass().getName().indexOf("Snapshot") != -1) {
 44  13
                                 artifactTransformations.remove(transforms[x]);
 45  13
                                 artifactTransformations.add(transforms[x]);
 46  
                         }
 47  
                 }
 48  13
         }
 49  
     
 50  
     public void transformForResolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
 51  
         throws ArtifactResolutionException, ArtifactNotFoundException
 52  
     {
 53  16
         for ( ArtifactTransformation transform : artifactTransformations )
 54  
         {
 55  48
             transform.transformForResolve( artifact, remoteRepositories, localRepository );
 56  
         }
 57  16
     }
 58  
 
 59  
     public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
 60  
         throws ArtifactInstallationException
 61  
     {
 62  1
         for ( ArtifactTransformation transform : artifactTransformations )
 63  
         {
 64  3
             transform.transformForInstall( artifact, localRepository );
 65  
         }
 66  1
     }
 67  
 
 68  
     public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
 69  
                                         ArtifactRepository localRepository )
 70  
         throws ArtifactDeploymentException
 71  
     {
 72  1
         for ( ArtifactTransformation transform : artifactTransformations )
 73  
         {
 74  3
             transform.transformForDeployment( artifact, remoteRepository, localRepository );
 75  
         }
 76  1
     }
 77  
 
 78  
 
 79  
 
 80  
 }