View Javadoc

1   package org.apache.maven.plugin.dependency.testUtils.stubs;
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 java.io.File;
23  
24  import org.apache.maven.plugin.dependency.fromConfiguration.ArtifactItem;
25  import org.apache.maven.plugin.dependency.utils.markers.UnpackFileMarkerHandler;
26  import org.codehaus.plexus.util.StringUtils;
27  
28  public class StubUnpackFileMarkerHandler
29  	extends UnpackFileMarkerHandler
30  {
31  	public StubUnpackFileMarkerHandler( ArtifactItem artifactItem, File markerFilesDirectory )
32      {
33          super( artifactItem, markerFilesDirectory );
34      }
35  	
36  	protected File getMarkerFile()
37      {
38  		File markerFile = null;
39  		if ( this.artifactItem == null 
40  			|| ( StringUtils.isEmpty( this.artifactItem.getIncludes() )
41  			&&	StringUtils.isEmpty( this.artifactItem.getExcludes() ) ) )
42  		{
43  			markerFile = new StubMarkerFile( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + ".marker" );
44  		}
45  		else
46  		{
47  			int includeExcludeHash = 0;
48  			
49  			if ( StringUtils.isNotEmpty( this.artifactItem.getIncludes() ) )
50  			{
51  				includeExcludeHash += this.artifactItem.getIncludes().hashCode();
52  			}
53  			
54  			if ( StringUtils.isNotEmpty( this.artifactItem.getExcludes() ) )
55  			{
56  				includeExcludeHash += this.artifactItem.getExcludes().hashCode();
57  			}
58  			
59  			markerFile = new StubMarkerFile( this.markerFilesDirectory, this.artifact.getId().replace( ':', '-' ) + includeExcludeHash );
60  		}
61  		
62  		return markerFile;
63      }
64  }