public class Packageify
extends java.lang.Object
Program arguments: (path to folder with all java files) (package definition txt file) (output folder) Example of package definition file: AnimatedSprite;com.marcusman.graphics Game;com.marcusman GameObject;com.marcusman.utils GUI;com.marcusman.graphics.gui GUIButton;com.marcusman.graphics.gui KeyBoardListener;com.marcusman.input Map;com.marcusman.logic MouseEventListener;com.marcusman.input Player;com.marcusman.logic Rectangle;com.marcusman.utils RenderHandler;com.marcusman.graphics SDKButton;com.marcusman.graphics.gui Sprite;com.marcusman.graphics SpriteSheet;com.marcusman.graphics Tiles;com.marcusman.logic
Modifier and Type | Field and Description |
---|---|
private java.io.File |
definitionFile |
private java.io.File |
inputFolder |
private java.io.File |
outputFolder |
private java.util.ArrayList<PackagedFile> |
packagedFiles |
Constructor and Description |
---|
Packageify(java.lang.String[] args)
Packageify the given directory with the description given above.
|
Modifier and Type | Method and Description |
---|---|
private void |
copyNonJavaFiles()
Copy all non-java files from the inputDir to the outputDir.
|
private void |
createPackagedFilesList()
Initialize and fill in our packagedFiles ArrayList with the information
provided in the individual lines of the definition file.
|
private java.lang.String |
getPackagedImports(PackagedFile consideredFile,
java.lang.String fileString)
Find the usage of other packaged files in this one and return a string of imports
if any given packaged file is in use.
|
static void |
main(java.lang.String[] args) |
private void |
putFilesIntoPackageFolders()
Copy all of the java files in the input directory into the output directory under
their package directories and put the package definition at the top of the file.
|
private void |
validateFiles()
Validate that all 3 files and directories (inputFolder, definitionFile, and outputFile) exist
or are accessible.
|
private java.io.File inputFolder
private java.io.File definitionFile
private java.io.File outputFolder
private java.util.ArrayList<PackagedFile> packagedFiles
public Packageify(java.lang.String[] args) throws java.lang.Exception
args
- args[0] = inputFolder args[1] = definitionFile args[2] = outputFolder.java.lang.Exception
- which could be IOException or IllegalArgumentExceptionprivate void copyNonJavaFiles() throws java.io.IOException
java.io.IOException
- if inputFile doesn't exist or copying goes awry.private void putFilesIntoPackageFolders() throws java.io.IOException
java.io.IOException
- if there was a problem reading, writing, or copying files.private java.lang.String getPackagedImports(PackagedFile consideredFile, java.lang.String fileString)
consideredFile
- The packaged file we are considering.fileString
- The packaged file we are considering in string form.private void createPackagedFilesList() throws java.io.IOException
java.io.IOException
- if there is a formatting problem with the file or a read error.private void validateFiles()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception