1 package org.codehaus.mojo.webstart.pack200; 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 import java.io.FileFilter; 24 import java.io.IOException; 25 import java.util.List; 26 import java.util.Map; 27 28 /** 29 * Tool api for pack200 operations. 30 * 31 * @author tchemit <chemit@codelutin.com> 32 * @since 1.0-beta-2 33 */ 34 public interface Pack200Tool 35 { 36 37 /** 38 * Plexus component role. 39 */ 40 String ROLE = Pack200Tool.class.getName(); 41 42 /** 43 * Extension of a pack file. 44 */ 45 String PACK_EXTENSION = ".pack"; 46 47 /** 48 * Extension of a gz pack file. 49 */ 50 String PACK_GZ_EXTENSION = PACK_EXTENSION + ".gz"; 51 52 /** 53 * Pack a jar. 54 * 55 * @param source the source jar 56 * @param destination the packed jar 57 * @param props the packing properties 58 * @param gzip true if the destination file 59 */ 60 void pack( File source, File destination, Map<String, String> props, boolean gzip ) 61 throws IOException; 62 63 /** 64 * Repack a jar. 65 * 66 * @param source the source jar 67 * @param destination the destination jar (may be the same as the source jar) 68 * @param props the packing properties 69 */ 70 void repack( File source, File destination, Map<String, String> props ) 71 throws IOException; 72 73 /** 74 * Unpack a jar. 75 * 76 * @param source the packed jar 77 * @param destination the unpacked jar 78 * @param props the packing properties 79 */ 80 void unpack( File source, File destination, Map<String, String> props ) 81 throws IOException; 82 83 /** 84 * Packs from the given {@code directory}, all files matched by the filter. 85 * <p/> 86 * If parameter {@code gzip} is setted to {@code true}, then after it gzip packed files. 87 * 88 * @param directory the location of the directory containing files to pack 89 * @param jarFileFilter the filter to determin which files to pack 90 * @param gzip flag to gzip files after pack them 91 * @param passFiles the list of file names to be passed as not pack200 compressed 92 */ 93 void packJars( File directory, FileFilter jarFileFilter, boolean gzip, List<String> passFiles ) 94 throws IOException; 95 96 /** 97 * Pack the given jarfile and return the packed file. 98 * 99 * @param jarFile jar file to pack 100 * @param gzip flag to enable gzip compression 101 * @param passFiles the list of file names to be passed as not pack200 compressed 102 * @return the packed file 103 * @throws IOException 104 */ 105 File packJar( File jarFile, boolean gzip, List<String> passFiles ) 106 throws IOException; 107 108 /** 109 * UnPacks from the given {@code directory}, all files matched by the filter. 110 * 111 * @param directory the location of the directory containing files to unpack 112 * @param pack200FileFilter the fileter to determin which files to unpakc 113 */ 114 void unpackJars( File directory, FileFilter pack200FileFilter ) 115 throws IOException; 116 117 /** 118 * Unpack the given file and return it. 119 * 120 * @param packFile the file to unpack 121 * @return the unpacked file 122 * @throws IOException 123 */ 124 File unpackJar( File packFile ) 125 throws IOException; 126 }