View Javadoc

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