private void generateArchetype(ArchetypeGenerationRequest request, ArtifactRepository localRepository, String basedir) throws Exception {
assert request != null;
if (!isArchetypeDefined(request)) {
throw new ArchetypeNotDefined("The archetype is not defined");
}
List<ArtifactRepository> repos=new ArrayList<ArtifactRepository>();
ArtifactRepository remoteRepo=null;
if (request.getArchetypeRepository() != null) {
remoteRepo=archetypeRegistryManager.createRepository(request.getArchetypeRepository(), request.getArchetypeArtifactId() + "-repo");
repos.add(remoteRepo);
}
if (!archetypeArtifactManager.exists(request.getArchetypeGroupId(), request.getArchetypeArtifactId(), request.getArchetypeVersion(), remoteRepo, localRepository, repos)) {
throw new UnknownArchetype("The desired archetype does not exist (" + request.getArchetypeGroupId() + ":" + request.getArchetypeArtifactId() + ":" + request.getArchetypeVersion() + ")");
}
if (archetypeArtifactManager.isFileSetArchetype(request.getArchetypeGroupId(), request.getArchetypeArtifactId(), request.getArchetypeVersion(), remoteRepo, localRepository, repos)) {
processFileSetArchetype(request, remoteRepo, localRepository, basedir, repos);
}
else if (archetypeArtifactManager.isOldArchetype(request.getArchetypeGroupId(), request.getArchetypeArtifactId(), request.getArchetypeVersion(), remoteRepo, localRepository, repos)) {
processOldArchetype(request, remoteRepo, localRepository, basedir, repos);
}
else {
throw new ArchetypeGenerationFailure("The defined artifact is not an archetype");
}
}