/* * [DropGenJar.java] * * Summary: Prepare jar manifest for jar.exe when genjar fails. * * Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2014-09-04 initial version */ package com.mindprod.repair; import com.mindprod.commandline.CommandLine; import com.mindprod.common18.EIO; import com.mindprod.filter.AllButSVNDirectoriesFilter; import com.mindprod.filter.ExtensionListFilter; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; import static java.lang.System.*; /** * Prepare jar manifest for jar.exe when genjar fails. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2014-09-04 initial version * @since 2014-09-04 */ public class DropGenJar { /** * Compute file growth * * @param file Java source file to tidy */ private static void processOneFile( final File file ) throws IOException { final BufferedReader bis = EIO.getBufferedReader( file, 64 * 1024, EIO.UTF8 ); final File outxml; if ( file.getParent().endsWith( EIO.getCoreName( file ) ) ) { // jar for whole package outxml = new File( file.getParent(), "forjarexe.xml" ); } else { // aux jar outxml = new File( file.getParent(), "for" + EIO.getCoreName( file ) + "jarexe.xml" ); } final BufferedWriter bos = EIO.getBufferedWriter( outxml, 64 * 1024, EIO.UTF8 ); bos.write( "\n" ); while ( true ) { final String lookName = bis.readLine(); // META-INF/MANIFEST.MF // com/mindprod/common18/BigDate.class if ( lookName == null ) { break; } if ( lookName.equals( "META-INF/MANIFEST.MF" ) ) { continue; } // ignore of package leg declarations // META-INF/ // META-INF/MANIFEST.MF // com/ // com/mindprod/ // com/mindprod/commandline/ if ( lookName.endsWith( "/" ) ) { continue; } // bos.write( "\n" ); } bos.write( "\n" ); bis.close(); bos.close(); out.println( EIO.getCanOrAbsPath( outxml ) + " generated" ); } /** * Compute forxxxxjarexe.xml from xxxx.look. * * @param args list of *.look file to procses, possibly dirs, also -s option. * * @throws java.io.IOException if cannot read or write source files. */ public static void main( final String[] args ) throws IOException { final CommandLine files = new CommandLine( args, new AllButSVNDirectoriesFilter(), new ExtensionListFilter( "look" ) ); for ( File file : files ) { processOneFile( file ); } // end for } }