~ubuntu-branches/ubuntu/utopic/maven-enforcer/utopic

« back to all changes in this revision

Viewing changes to enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BannedDependencies.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-12 22:30:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: package-import@ubuntu.com-20110912223016-e2pk04avoq8bur7t
Tags: 1.0-1
* Team upload
* New upstream release.
* Add more Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.apache.maven.plugins.enforcer;
 
2
 
1
3
/*
2
4
 * Licensed to the Apache Software Foundation (ASF) under one
3
5
 * or more contributor license agreements.  See the NOTICE file
16
18
 * specific language governing permissions and limitations
17
19
 * under the License.
18
20
 */
19
 
package org.apache.maven.plugins.enforcer;
20
21
 
21
22
import java.util.HashSet;
22
23
import java.util.Iterator;
31
32
import org.apache.maven.plugin.logging.Log;
32
33
import org.codehaus.plexus.util.StringUtils;
33
34
 
34
 
// TODO: Auto-generated Javadoc
35
35
/**
36
36
 * This rule checks that lists of dependencies are not included.
37
 
 * 
 
37
 *
38
38
 * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
39
 
 * @version $Id: BannedDependencies.java 675992 2008-07-11 15:42:48Z hboutemy $
 
39
 * @version $Id: BannedDependencies.java 1028164 2010-10-28 01:40:06Z brianf $
40
40
 */
41
41
public class BannedDependencies
42
42
    extends AbstractBanDependencies
60
60
 
61
61
    /*
62
62
     * (non-Javadoc)
63
 
     * 
 
63
     *
64
64
     * @see org.apache.maven.plugin.enforcer.AbstractBanDependencies#checkDependencies(java.util.Set)
65
65
     */
66
66
    protected Set checkDependencies( Set theDependencies, Log log )
84
84
 
85
85
    /**
86
86
     * Checks the set of dependencies against the list of patterns.
87
 
     * 
 
87
     *
88
88
     * @param thePatterns the patterns
89
89
     * @param dependencies the dependencies
90
90
     * @return a set containing artifacts matching one of the patterns or <code>null</code>
128
128
 
129
129
    /**
130
130
     * Compares the parsed array of substrings against the artifact.
131
 
     * 
 
131
     * The pattern should follow the format "groupId:artifactId:version:type:scope"
 
132
     *
132
133
     * @param pattern the array of patterns
133
134
     * @param artifact the artifact
134
135
     * @return <code>true</code> if the artifact matches one of the patterns
162
163
                {
163
164
                    result =
164
165
                        AbstractVersionEnforcer.containsVersion( VersionRange.createFromVersionSpec( pattern[2] ),
165
 
                                                                 new DefaultArtifactVersion( artifact.getVersion() ) );
 
166
                                                                 new DefaultArtifactVersion( artifact.getBaseVersion() ) );
166
167
                }
167
168
                catch ( InvalidVersionSpecificationException e )
168
169
                {
171
172
            }
172
173
        }
173
174
 
 
175
        if ( result && pattern.length > 3 )
 
176
        {
 
177
            String type = artifact.getType();
 
178
            if ( type == null || type.equals( "" ) )
 
179
            {
 
180
                type = "jar";
 
181
            }
 
182
            result = pattern[3].equals( "*" ) || type.equals( pattern[3] );
 
183
        }
 
184
 
 
185
        if ( result && pattern.length > 4 )
 
186
        {
 
187
            String scope = artifact.getScope();
 
188
            if ( scope == null || scope.equals( "" ) )
 
189
            {
 
190
                scope = "compile";
 
191
            }
 
192
            result = pattern[4].equals( "*" ) || scope.equals( pattern[4] );
 
193
        }
 
194
 
174
195
        return result;
175
196
    }
176
197
 
177
198
    /**
178
199
     * Gets the excludes.
179
 
     * 
 
200
     *
180
201
     * @return the excludes
181
202
     */
182
203
    public List getExcludes()
186
207
 
187
208
    /**
188
209
     * Sets the excludes.
189
 
     * 
 
210
     *
190
211
     * @param theExcludes the excludes to set
191
212
     */
192
213
    public void setExcludes( List theExcludes )
196
217
 
197
218
    /**
198
219
     * Gets the includes.
199
 
     * 
 
220
     *
200
221
     * @return the includes
201
222
     */
202
223
    public List getIncludes()
206
227
 
207
228
    /**
208
229
     * Sets the includes.
209
 
     * 
 
230
     *
210
231
     * @param theIncludes the includes to set
211
232
     */
212
233
    public void setIncludes( List theIncludes )