protected final GeneratedFile getTargetFile ( final String artifactName , final String filename , final String logInfo ) { final Folder folder = getGeneratorConfig ( ) . findTargetFolder ( artifactName ) ; final File dir = folder . getCanonicalDir ( ) ; final File file = new File ( dir , filename ) ; // Make sure the folder exists if ( ! dir . exists ( ) ) { if ( folder . isCreate ( ) ) { dir . mkdirs ( ) ; } else { throw new IllegalStateException ( "Directory '" + dir + "' does not exist, but configuration does not allow creation: " + "<folder name=\"" + folder . getName ( ) + "\" create=\"false\" ... />" ) ; } } // Make sure the parent directory for the file exists if ( ! file . getParentFile ( ) . exists ( ) ) { file . getParentFile ( ) . mkdirs ( ) ; } if ( file . exists ( ) && ! folder . overrideAllowed ( file ) ) { // Skip file because override is not allowed return new GeneratedFile ( file , logInfo , true ) ; } return new GeneratedFile ( file , logInfo ) ; }
Returns the target file for a given artifact type and filename . This method takes care about eventually creating non existing directories or protect existing files to be overridden .