Coverage Report - org.apache.maven.plugin.assembly.artifact.ResolutionManagementInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
ResolutionManagementInfo
79%
31/39
83%
5/6
1,125
 
 1  
 package org.apache.maven.plugin.assembly.artifact;
 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.project.MavenProject;
 24  
 import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
 25  
 
 26  
 import java.util.LinkedHashSet;
 27  
 import java.util.Set;
 28  
 
 29  
 /**
 30  
  * Helper class used to accumulate scopes and modules (with binaries included) that are used in an assembly, for the
 31  
  * purposes of creating an aggregated managed-version map with dependency version conflicts resolved.
 32  
  * 
 33  
  * @author jdcasey
 34  
  */
 35  
 class ResolutionManagementInfo
 36  
 {
 37  
     private boolean resolutionRequired;
 38  
 
 39  9
     private final ScopeArtifactFilter scopeFilter = new ScopeArtifactFilter();
 40  
 
 41  
     private boolean resolvedTransitively;
 42  
 
 43  9
     private final Set<MavenProject> enabledProjects = new LinkedHashSet<MavenProject>();
 44  
 
 45  9
     private final Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
 46  
 
 47  
     ResolutionManagementInfo( final MavenProject currentProject )
 48  9
     {
 49  9
         enabledProjects.add( currentProject );
 50  9
     }
 51  
 
 52  
     boolean isResolutionRequired()
 53  
     {
 54  9
         return resolutionRequired;
 55  
     }
 56  
 
 57  
     void setResolutionRequired( final boolean resolutionRequired )
 58  
     {
 59  12
         this.resolutionRequired = resolutionRequired;
 60  12
     }
 61  
 
 62  
     boolean isResolvedTransitively()
 63  
     {
 64  3
         return resolvedTransitively;
 65  
     }
 66  
 
 67  
     void setResolvedTransitively( final boolean resolvedTransitively )
 68  
     {
 69  12
         this.resolvedTransitively = this.resolvedTransitively || resolvedTransitively;
 70  12
     }
 71  
 
 72  
     ScopeArtifactFilter getScopeFilter()
 73  
     {
 74  57
         return scopeFilter;
 75  
     }
 76  
 
 77  
     void enableCompileScope()
 78  
     {
 79  9
         scopeFilter.setIncludeCompileScope( true );
 80  9
         scopeFilter.setIncludeProvidedScope( true );
 81  9
         scopeFilter.setIncludeSystemScope( true );
 82  9
     }
 83  
 
 84  
     void enableProvidedScope()
 85  
     {
 86  0
         scopeFilter.setIncludeProvidedScope( true );
 87  0
     }
 88  
 
 89  
     void enableRuntimeScope()
 90  
     {
 91  0
         scopeFilter.setIncludeRuntimeScope( true );
 92  0
         scopeFilter.setIncludeCompileScope( true );
 93  0
     }
 94  
 
 95  
     void enableTestScope()
 96  
     {
 97  3
         scopeFilter.setIncludeTestScope( true );
 98  3
         scopeFilter.setIncludeCompileScope( true );
 99  3
         scopeFilter.setIncludeProvidedScope( true );
 100  3
         scopeFilter.setIncludeSystemScope( true );
 101  3
         scopeFilter.setIncludeRuntimeScope( true );
 102  3
     }
 103  
 
 104  
     void enableSystemScope()
 105  
     {
 106  6
         scopeFilter.setIncludeSystemScope( true );
 107  6
     }
 108  
 
 109  
     void enableProjectResolution( final MavenProject project )
 110  
     {
 111  9
         if ( !enabledProjects.contains( project ) )
 112  
         {
 113  9
             enabledProjects.add( project );
 114  
         }
 115  9
     }
 116  
 
 117  
     Set<MavenProject> getEnabledProjects()
 118  
     {
 119  3
         return enabledProjects;
 120  
     }
 121  
 
 122  
     Set<Artifact> getArtifacts()
 123  
     {
 124  0
         return artifacts;
 125  
     }
 126  
 
 127  
     void addArtifacts( final Set<Artifact> a )
 128  
     {
 129  12
         artifacts.addAll( a );
 130  12
     }
 131  
 
 132  
     void addArtifact( final Artifact a )
 133  
     {
 134  0
         artifacts.add( a );
 135  0
     }
 136  
 }