001 /** 002 * www.jcoverage.com 003 * Copyright (C)2003 jcoverage ltd. 004 * 005 * This file is part of jcoverage. 006 * 007 * jcoverage is free software; you can redistribute it and/or modify 008 * it under the terms of the GNU General Public License as published 009 * by the Free Software Foundation; either version 2 of the License, 010 * or (at your option) any later version. 011 * 012 * jcoverage is distributed in the hope that it will be useful, but 013 * WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * General Public License for more details. 016 * 017 * You should have received a copy of the GNU General Public License 018 * along with jcoverage; if not, write to the Free Software 019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 020 * USA 021 * 022 */ 023 package com.jcoverage.tool.merge; 024 025 import com.jcoverage.coverage.InstrumentationPersistence; 026 import com.jcoverage.coverage.Version; 027 028 import gnu.getopt.Getopt; 029 import gnu.getopt.LongOpt; 030 031 import java.io.File; 032 import java.io.FileInputStream; 033 import java.io.FileNotFoundException; 034 035 import org.apache.log4j.Logger; 036 037 038 public class Main extends InstrumentationPersistence { 039 static final Logger logger=Logger.getLogger(Main.class); 040 041 Main(String[] args) { 042 LongOpt[] longOpts=new LongOpt[2]; 043 longOpts[0]=new LongOpt("instrumentation",LongOpt.REQUIRED_ARGUMENT,null,'i'); 044 longOpts[1]=new LongOpt("output",LongOpt.REQUIRED_ARGUMENT,null,'o'); 045 046 Getopt g=new Getopt(getClass().getName(),args,":i:o:",longOpts); 047 int c; 048 049 File destDir=new File(System.getProperty("user.dir")); 050 051 while((c=g.getopt())!=-1) { 052 switch(c) { 053 case 'i': 054 System.out.println("jcoverage loading: "+g.getOptarg()); 055 try { 056 merge(loadInstrumentation(new FileInputStream(g.getOptarg()))); 057 } catch(FileNotFoundException ex) { 058 logger.warn(ex); 059 } 060 break; 061 062 case 'o': 063 destDir=new File(g.getOptarg()); 064 destDir.mkdirs(); 065 break; 066 } 067 } 068 069 saveInstrumentation(destDir); 070 } 071 072 073 public static void main(String[] args) { 074 System.out.println("jcoverage "+Version.VERSION_STRING+" copyright (c)2003 jcoverage ltd. http://jcoverage.com/"); 075 System.out.println("jcoverage is licensed under the GNU General Public License"); 076 System.out.println("jcoverage comes with ABSOLUTELY NO WARRANTY"); 077 System.out.println("jcoverage instrumentation session merge tool"); 078 new Main(args); 079 } 080 }