View Javadoc

1   package org.codehaus.mojo.javascript.archive;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.io.InputStream;
20  import java.io.IOException;
21  import java.util.Collections;
22  
23  import org.codehaus.plexus.archiver.ArchiverException;
24  import org.codehaus.plexus.archiver.ArchiveFileFilter;
25  import org.codehaus.plexus.archiver.ArchiveFilterException;
26  import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
27  
28  /**
29   * Custom archiver for javascript dependencies, packaged as "jsar" (JavaScript
30   * ARchive), that are simply a jar of scripts and resources.
31   * 
32   * @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
33   * @plexus.component role="org.codehaus.plexus.archiver.UnArchiver"
34   * role-hint="javascript"
35   */
36  public class JavascriptUnArchiver
37      extends ZipUnArchiver
38  {
39      /**
40       *
41       */
42      public JavascriptUnArchiver()
43      {
44          super();
45      }
46  	
47      /**
48       * overwrite the super.extract() to set the default filter.
49       */
50  	public void extract() throws ArchiverException, IOException 
51  	{
52          setArchiveFilters( Collections.singletonList( new ArchiveFileFilter()
53          {
54              public boolean include( InputStream dataStream, String entryName )
55                  throws ArchiveFilterException
56              {
57                  return !entryName.startsWith( "META-INF" );
58              }
59          } ) );
60  		super.extract();
61  	}
62  }