private static void createMavenProject ( File targetDirectory , CreationBean creationBean ) throws IOException { // Create the directory structure File rootDir = new File ( targetDirectory , Constants . MAVEN_SRC_MAIN_MODEL ) ; String [ ] directoriesToCreate = creationBean . isReusableRecipe ( ) ? RR_DIRECTORIES : ALL_DIRECTORIES ; for ( String s : directoriesToCreate ) { File dir = new File ( rootDir , s ) ; Utils . createDirectory ( dir ) ; } // Create a POM? InputStream in ; if ( Utils . isEmptyOrWhitespaces ( creationBean . getCustomPomLocation ( ) ) ) in = ProjectUtils . class . getResourceAsStream ( "/pom-skeleton.xml" ) ; else in = new FileInputStream ( creationBean . getCustomPomLocation ( ) ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; Utils . copyStreamSafely ( in , out ) ; String tpl = out . toString ( "UTF-8" ) . replace ( TPL_NAME , creationBean . getProjectName ( ) ) . replace ( TPL_POM_GROUP , creationBean . getGroupId ( ) ) . replace ( TPL_POM_PLUGIN_VERSION , creationBean . getPluginVersion ( ) ) . replace ( TPL_VERSION , creationBean . getProjectVersion ( ) ) . replace ( TPL_POM_ARTIFACT , creationBean . getArtifactId ( ) ) . replace ( TPL_DESCRIPTION , creationBean . getProjectDescription ( ) ) ; File pomFile = new File ( targetDirectory , "pom.xml" ) ; Utils . copyStream ( new ByteArrayInputStream ( tpl . getBytes ( StandardCharsets . UTF_8 ) ) , pomFile ) ; // Create the descriptor in = ProjectUtils . class . getResourceAsStream ( "/application-skeleton.props" ) ; out = new ByteArrayOutputStream ( ) ; Utils . copyStreamSafely ( in , out ) ; tpl = out . toString ( "UTF-8" ) . replace ( TPL_NAME , creationBean . getProjectName ( ) ) . replace ( TPL_DESCRIPTION , "${project.description}" ) ; // If for some reason, the project version is already a Maven expression, // keep it untouched. Such a thing may cause troubles with a real POM, // as versions should not reference properties. But it may be used for tests anyway. if ( ! creationBean . getProjectVersion ( ) . contains ( "$" ) ) tpl = tpl . replace ( TPL_VERSION , "${project.version}" ) ; else tpl = tpl . replace ( TPL_VERSION , creationBean . getProjectVersion ( ) ) ; // Create the rest of the project completeProjectCreation ( rootDir , tpl , creationBean ) ; }
Creates a Maven project for Roboconf .