/* * [StompOneProject.java] * * Summary: Handles Stomps all files and Scripts for one Project. Cross-checks and fixes too. * * 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 2007-05-12 initial version. */ package com.mindprod.zzz; import com.mindprod.common18.Build; import com.mindprod.prices.AppCat; import java.io.File; import java.util.EnumSet; import java.util.HashSet; import static com.mindprod.prices.AppCat.JWS; import static java.lang.System.*; /** * Handles Stomps all files and Scripts for one Project. Cross-checks and fixes too. *

* Version History: * * @author Roedy Green, Canadian Mind Products * @version 1.1 2009-05-02 major refactor into simpler inheritance * @since 2007-05-12 */ class StompOneProject extends ProjectInfo { /** * true if want extra debugging output */ private static final boolean DEBUGGING = false; /** * used to detect duplicate projects */ private static final HashSet prevProjects = new HashSet<>( 300 ); /** * Create a new project * * @param mainClass e.g. FontShower, that name is lower case becomes a segment of the package name, and also * the directory segment where the project lives. * @param version version of the program the version is 1.7 * @param jdkVersion version of the JDK ideally desired * @param description one sentence of what this project does. * @param appCat APPLET,APPLICATION, "JWS", HYBRID, "utility", "documentation" , "servlet", or alias * @param signing SIGNED or UNSIGNED describing if digitally signed * @param jniUse USES_JNI32 if uses usesJni32, NO_JNI otherwise. * @param zipUse DISTRIBUTE_ZIP if post source code, NO_ZIP otherwise. * @param padType which version of PAD we use, or none. * @param forgive indiscretions we can forgive this project for * @param extraPackages additional packages that will appear in zip, but not in jars. * could also be done with forzip.xml * @param altMainClasses alternate main classes, just class name without package. */ @SuppressWarnings( { "SameParameterValue" } ) StompOneProject( final String mainClass, final double version, final double jdkVersion, final String description, final AppCat appCat, final Signing signing, final JniUse jniUse, final ZipUse zipUse, final PADType padType, final EnumSet forgive, final String[] extraPackages, final String... altMainClasses ) { super( mainClass, version, jdkVersion, Build.THIS_COPYRIGHT_YEAR, description, appCat, signing, jniUse, zipUse, padType, forgive, extraPackages, altMainClasses ); if ( prevProjects.contains( mainClass ) ) { err.println( "Duplicate project " + mainClass ); } else { prevProjects.add( mainClass ); } } /** * create the project directory where most of the other files go. */ void createProjectDirectory() { // create all legs of name //noinspection ResultOfMethodCallIgnored new File( winAbsoluteProjectDir ).mkdirs(); } /** * delete obsolete files as stomping done. Does not generate a bat file to delete files. */ void deleteObsoletes() { File dir = new File( winAbsoluteProjectDir ); if ( appCat != JWS ) { // keep if is a JWS app new File( dir, projectLower + ".jnlp" ).delete(); } new File( dir, projectLower + ".pad.html" ).delete(); new File( dir, projectLower + ".paddesc.html" ).delete(); new File( dir, "build.bat" ).delete(); new File( dir, "build2.xml" ).delete(); new File( dir, "compile.bat" ).delete(); new File( dir, "distribute.bat" ).delete(); new File( dir, "forjar.list" ).delete(); new File( dir, "forzip.list" ).delete(); new File( dir, "jt.btm" ).delete(); new File( dir, "just.bat" ).delete(); new File( dir, "main.mft" ).delete(); new File( dir, "manifest.txt" ).delete(); new File( dir, "recompile.bat" ).delete(); new File( dir, "rejar.bat" ).delete(); new File( dir, "rejt.bat" ).delete(); new File( dir, "rejt.btm" ).delete(); new File( dir, "try.bat" ).delete(); new File( dir, "wipe.bat" ).delete(); } /** * do everything for this project, generate all files */ void stomp() { // We don't print out project, or it makes it to hard to find error messages in the torrent. if ( DEBUGGING ) { out.println( projectLower + "," + projectHumanName + "," + appCat.getCssClass() ); } this.createProjectDirectory(); final CrossCheckProject ext = new CrossCheckProject( this ); ext.ensureAllFilesPresent(); // do cross checks later. this.deleteObsoletes(); ext.doAllCrossFileChecks(); // need to propagate calculated firstCopyright year back to main object. this.firstCopyrightYear = ext.firstCopyrightYear; new MkAuxFiles( this ).mkAllAuxFiles(); new FixPads( this ).fixAllPads(); new MkAnt( this ).mkAllAntFiles(); new MkDesc( this ).mkDescsBtm(); } }