Coverage Report - org.apache.maven.project.DefaultMavenProjectHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultMavenProjectHelper
0 %
0/36
0 %
0/4
1,4
 
 1  
 package org.apache.maven.project;
 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.handler.ArtifactHandler;
 24  
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 25  
 import org.apache.maven.model.Resource;
 26  
 import org.apache.maven.project.artifact.AttachedArtifact;
 27  
 
 28  
 import java.io.File;
 29  
 import java.util.List;
 30  
 
 31  0
 public class DefaultMavenProjectHelper
 32  
     implements MavenProjectHelper
 33  
 {
 34  
     
 35  
     private ArtifactHandlerManager artifactHandlerManager;
 36  
 
 37  
     public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile )
 38  
     {
 39  0
         String type = artifactType;
 40  
         
 41  0
         ArtifactHandler handler = null;
 42  
         
 43  0
         if ( type != null )
 44  
         {
 45  0
             handler = artifactHandlerManager.getArtifactHandler( artifactType );
 46  
         }
 47  
         
 48  0
         if ( handler == null )
 49  
         {
 50  0
             handler = artifactHandlerManager.getArtifactHandler( "jar" );
 51  
         }
 52  
 
 53  0
         Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, artifactClassifier, handler );
 54  
         
 55  0
         artifact.setFile( artifactFile );
 56  0
         artifact.setResolved( true );
 57  
         
 58  0
         project.addAttachedArtifact( artifact );
 59  0
     }
 60  
 
 61  
     public void attachArtifact( MavenProject project, String artifactType, File artifactFile )
 62  
     {
 63  0
         ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( artifactType );
 64  
         
 65  0
         Artifact artifact = new AttachedArtifact( project.getArtifact(), artifactType, handler );
 66  
         
 67  0
         artifact.setFile( artifactFile );
 68  0
         artifact.setResolved( true );
 69  
         
 70  0
         project.addAttachedArtifact( artifact );
 71  0
     }
 72  
 
 73  
     public void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier )
 74  
     {
 75  0
         Artifact projectArtifact = project.getArtifact();
 76  
         
 77  0
         Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier, projectArtifact.getArtifactHandler() );
 78  
         
 79  0
         artifact.setFile( artifactFile );
 80  0
         artifact.setResolved( true );
 81  
         
 82  0
         project.addAttachedArtifact( artifact );
 83  0
     }
 84  
 
 85  
     public void addResource( MavenProject project, String resourceDirectory, List includes, List excludes )
 86  
     {
 87  0
         Resource resource = new Resource();
 88  0
         resource.setDirectory( resourceDirectory );
 89  0
         resource.setIncludes( includes );
 90  0
         resource.setExcludes( excludes );
 91  
 
 92  0
         project.addResource( resource );
 93  0
     }
 94  
 
 95  
     public void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes )
 96  
     {
 97  0
         Resource resource = new Resource();
 98  0
         resource.setDirectory( resourceDirectory );
 99  0
         resource.setIncludes( includes );
 100  0
         resource.setExcludes( excludes );
 101  
 
 102  0
         project.addTestResource( resource );
 103  0
     }
 104  
 
 105  
 }