/* * [Verifyjarexe.java] * * Summary: Check forxxxjarexe.xml files to ensure contain main class. * * 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.common18.ST; import com.mindprod.filter.AllButSVNDirectoriesFilter; import com.mindprod.filter.StartAndEndsWithFilter; import com.mindprod.hunkio.HunkIO; import java.io.File; import java.io.IOException; import static java.lang.System.*; /** * Check forxxxjarexe.xml files to ensure contain main class. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2014-09-04 initial version * @since 2014-09-04 */ public class Verifyjarexe { private static final boolean DEBUGGING = false; /** * Compute file growth * * @param file Java source file to tidy */ private static void processOneFile( final File file ) throws IOException { final String big = HunkIO.readEntireFile( file, EIO.UTF8 ).toLowerCase(); final String parent = file.getParent().replace( '\\', '/' ); final int place = parent.lastIndexOf( '/' ); final String project = parent.substring( place + 1 ); final String wholePackage = "com/mindprod/" + project + "/**/*.class"; final String main; // guess main class if ( file.getName().equals( "forjarexe.xml" ) ) { main = "com/mindprod/" + project + "/" + project + ".class"; } else { // name is forxxxxjarexe.xml String name = ST.chopTrailingString( ST.chopLeadingString( file.getName(), "for" ), "jarexe.xml" ); main = "com/mindprod/" + project + "/" + name + ".class"; } if ( DEBUGGING ) { out.println( "seeking " + main + " or " + wholePackage ); } if ( !big.contains( main.toLowerCase() ) && !big.contains( wholePackage.toLowerCase() ) ) { out.println( ">>> missing " + main + " from " + EIO.getCanOrAbsPath( file ) ); } } /** * 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 StartAndEndsWithFilter( new String[] { "for" }, new String[] { "jarexe.xml" }, null, null, null, null ) ); for ( File file : files ) { processOneFile( file ); } // end for } }