Coverage Report - org.apache.maven.artifact.transform.DefaultArtifactTransformationManager
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultArtifactTransformationManager
100%
19/19
100%
10/10
2,25
 
 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.Iterator;
 32  
 import java.util.List;
 33  
 
 34  11
 public class DefaultArtifactTransformationManager
 35  
     implements ArtifactTransformationManager, Initializable
 36  
 {
 37  
     private List artifactTransformations;
 38  
     
 39  
         public void initialize() throws InitializationException {
 40  
                 // TODO this is a hack until plexus can fix the ordering of the arrays
 41  11
                 Object obj[] = artifactTransformations.toArray();
 42  44
                 for (int x = 0; x < obj.length; x++)
 43  
                 {
 44  33
                         if (obj[x].getClass().getName().indexOf("Snapshot") != -1) {
 45  11
                                 artifactTransformations.remove(obj[x]);
 46  11
                                 artifactTransformations.add(obj[x]);
 47  
                         }
 48  
                 }
 49  11
         }
 50  
     
 51  
     public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
 52  
         throws ArtifactResolutionException, ArtifactNotFoundException
 53  
     {
 54  13
         for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
 55  
         {
 56  39
             ArtifactTransformation transform = (ArtifactTransformation) i.next();
 57  39
             transform.transformForResolve( artifact, remoteRepositories, localRepository );
 58  
         }
 59  13
     }
 60  
 
 61  
     public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
 62  
         throws ArtifactInstallationException
 63  
     {
 64  1
         for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
 65  
         {
 66  3
             ArtifactTransformation transform = (ArtifactTransformation) i.next();
 67  3
             transform.transformForInstall( artifact, localRepository );
 68  
         }
 69  1
     }
 70  
 
 71  
     public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
 72  
                                         ArtifactRepository localRepository )
 73  
         throws ArtifactDeploymentException
 74  
     {
 75  1
         for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
 76  
         {
 77  3
             ArtifactTransformation transform = (ArtifactTransformation) i.next();
 78  3
             transform.transformForDeployment( artifact, remoteRepository, localRepository );
 79  
         }
 80  1
     }
 81  
 
 82  
 
 83  
 
 84  
 }