NonExtractor.java |
1 /* 2 * Copyright 2005 Paul Hinds 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package org.tp23.antinstaller.selfextract; 17 18import java.io.File; 19 20import org.tp23.antinstaller.InstallException; 21import org.tp23.antinstaller.runtime.ExecInstall; 22import org.tp23.antinstaller.runtime.exe.FilterChain; 23import org.tp23.antinstaller.runtime.exe.FilterFactory; 24 25/** 26 * This class is a replacement for the SelfExtractor that provides a similar 27 * function to the SelfExtractor but avoids the need to extract all the 28 * files prior to running the build. When using this extractor the project 29 * is run from the Jar but It is the Ant builds responsibility to access 30 * resources from within the Jar the Jar itself can be referenced using 31 * the Ant property "antinstaller.jar". The build file is automatically read 32 * from the Jar. 33 * @author Paul Hinds 34 * @version $Id: NonExtractor.java,v 1.4 2006/12/15 21:16:39 teknopaul Exp $ 35 */ 36public class NonExtractor extends SelfExtractor{ 37 38 /** used by AntProjectFilter */ 39 public static final String ANTINSTALLER_JAR_PROPERTY = "antinstaller.jar"; 40 public static final String CONFIG_RESOURCE = "/org/tp23/antinstaller/runtime/exe/nonextractor.fconfig"; 41 42 /** 43 * Run method to use from the command line. This is fired via an entry in the 44 * MANIFEST.MF in the Jar 45 *@param args The command line arguments 46 */ 47 public static void main(String[] args) { 48 try { 49 SelfExtractor extractor = null; 50 extractor = new NonExtractor(); 51 FilterChain chain = FilterFactory.factory(CONFIG_RESOURCE); 52 ExecInstall installExec = new ExecInstall(chain); 53 installExec.parseArgs(args, false); 54 55 // create temporary space for the build to be removed on exit 56 File temp = extractor.makeTempDir(); 57 installExec.setTempRoot(temp); 58 installExec.setInstallRoot(temp); 59 installExec.exec(); 60 } 61 catch (InstallException e) { 62 System.out.println("Can't load filter chain: " + CONFIG_RESOURCE); 63 e.printStackTrace(); 64 } 65 } 66} 67