private File getArchetypeFile( ArchetypeGenerationRequest request, ArtifactRepository localRepository ) throws IOException, ArchetypeException, XmlPullParserException, DocumentException { if ( !isArchetypeDefined( request ) ) { throw new ArchetypeNotDefined( "The archetype is not defined" ); } List<ArtifactRepository> repos = new ArrayList<ArtifactRepository>(); ArtifactRepository remoteRepo = null; if ( request != null && request.getArchetypeRepository() != null ) { remoteRepo = createRepository( request.getArchetypeRepository(), request.getArchetypeArtifactId() + "-repo" ); repos.add( remoteRepo ); } if ( !archetypeArtifactManager.exists( request.getArchetypeGroupId(), request.getArchetypeArtifactId(), request.getArchetypeVersion(), remoteRepo, localRepository, repos, request.getProjectBuildingRequest() ) ) { throw new UnknownArchetype( "The desired archetype does not exist (" + request.getArchetypeGroupId() + ":" + request.getArchetypeArtifactId() + ":" + request.getArchetypeVersion() + ")" ); } File archetypeFile = archetypeArtifactManager.getArchetypeFile( request.getArchetypeGroupId(), request.getArchetypeArtifactId(), request.getArchetypeVersion(), remoteRepo, localRepository, repos, request.getProjectBuildingRequest() ); return archetypeFile; }