ArchetypeCreationConfigurator configurator = plexus.lookup(ArchetypeCreationConfigurator.class);
Properties config = configurator.configureArchetypeCreation(project, !batch, props, null, languages);
RepositorySystem rsys = plexus.lookup(RepositorySystem.class);
ArchetypeCreationRequest request = new ArchetypeCreationRequest()
.setProject(project)
.setProperties(config)
.setLanguages(languages)
.setFilteredExtensions(filteredExtensions)
.setPreserveCData(preserveCDATA)
.setKeepParent(keepParent)
.setPartialArchetype(partial)
.setLocalRepository(rsys.createDefaultLocalRepository())
.setPackageName(packageName);
if (registryFile == null) {
File dir = vars.get(SHELL_USER_HOME, File.class);
registryFile = new File(dir, ".m2/archetype.xml");
}
request.setArchetypeRegistryFile(registryFile);
if (outputDirectory != null) {
request.setOutputDirectory(outputDirectory);
}
else {
// HACK: Default dir is not rooted
System.setProperty("user.dir", vars.get(SHELL_USER_DIR, File.class).getAbsolutePath());
}
log.debug("Creating archetype");
ArchetypeManager archetypeManager = plexus.lookup(ArchetypeManager.class);
ArchetypeCreationResult result = archetypeManager.createArchetypeFromProject(request);
if (result.getCause() != null) {
throw result.getCause();
}
// HACK: Prompter has some issues, so add a newline
io.out.println();
io.println("Archetype created in: {}", request.getOutputDirectory().getAbsolutePath()); // TODO: i18n
return Result.SUCCESS;
}