Reorganizes the recipes in a more reasonable way.
The recipes are now structured into multipe subfolder and split into more distinct files, so the names are more appropriate and are better at hinting which items the actually contain. It also extends the RecipeResourceCopier to now handle the folder recursively and extract all subdirectories and their files. "import=" is currently requiring a relative path to the root directory of the recipes. This would require a larger rewrite/refactoring, thus it is kept for now until a potentially later changer. This reverts splitting the oredict entries into their own directory and moves them back into the recipes folder, as it currently is causing a couple of issues like not being able to resolve the aliases or is not working indev. But to keep it seperate it is now its own recipe file. Fixes #1791 Reverts #1635
This commit is contained in:
@@ -88,22 +88,60 @@ public class RecipeResourceCopier
|
||||
Preconditions.checkNotNull( destination );
|
||||
Preconditions.checkArgument( destination.isDirectory() );
|
||||
|
||||
final String[] listing = this.getResourceListing( this.getClass(), this.root );
|
||||
this.copyTo( destination, this.root );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {RecipeResourceCopier#copyTo(File)}
|
||||
*
|
||||
* @param destination destination folder to which the recipes are copied to
|
||||
* @param directory the folder to copy.
|
||||
*
|
||||
* @throws URISyntaxException {@see #getResourceListing}
|
||||
* @throws IOException {@see #getResourceListing} and if copying the detected resource to file is not possible
|
||||
*/
|
||||
private void copyTo( File destination, String directory ) throws URISyntaxException, IOException
|
||||
{
|
||||
assert destination != null;
|
||||
assert directory != null;
|
||||
|
||||
final String[] listing = this.getResourceListing( this.getClass(), directory );
|
||||
for( String list : listing )
|
||||
{
|
||||
if( list.endsWith( ".recipe" ) || list.endsWith( ".html" ) )
|
||||
{
|
||||
final InputStream inStream = this.getClass().getResourceAsStream( '/' + this.root + list );
|
||||
final File outFile = new File( destination, list );
|
||||
if( !outFile.exists() )
|
||||
{
|
||||
if( inStream != null )
|
||||
{
|
||||
FileUtils.copyInputStreamToFile( inStream, outFile );
|
||||
inStream.close();
|
||||
}
|
||||
}
|
||||
this.copyFile( destination, directory, list );
|
||||
}
|
||||
else if( !list.contains( "." ) )
|
||||
{
|
||||
final File subDirectory = new File( destination, list );
|
||||
FileUtils.forceMkdir( subDirectory );
|
||||
this.copyTo( subDirectory, directory + list + "/" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies a single file inside a folder to the destination.
|
||||
*
|
||||
* @param destination folder to which the file is copied to
|
||||
* @param directory the directory containing the file
|
||||
* @param fileName the fily to copy
|
||||
*
|
||||
* @throws IOException if copying the file is not possible
|
||||
*/
|
||||
private void copyFile( File destination, String directory, String fileName ) throws IOException
|
||||
{
|
||||
assert destination != null;
|
||||
assert fileName != null;
|
||||
|
||||
final InputStream inStream = this.getClass().getResourceAsStream( '/' + directory + fileName );
|
||||
final File outFile = new File( destination, fileName );
|
||||
|
||||
if( !outFile.exists() && inStream != null )
|
||||
{
|
||||
FileUtils.copyInputStreamToFile( inStream, outFile );
|
||||
inStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user