UIContext uiContext = context.getUIContext();
Project project = (Project) uiContext.getAttributeMap().get(Project.class);
Archetype chosenArchetype = archetype.getValue();
String coordinate = chosenArchetype.getGroupId() + ":" + chosenArchetype.getArtifactId() + ":"
+ chosenArchetype.getVersion();
DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate);
String repository = chosenArchetype.getRepository();
if (!Strings.isNullOrEmpty(repository))
{
if (repository.endsWith(".xml"))
{
int lastRepositoryPath = repository.lastIndexOf('/');
if (lastRepositoryPath > -1)
repository = repository.substring(0, lastRepositoryPath);
}
if (!repository.isEmpty())
{
depQuery.setRepositories(new DependencyRepository("archetype", repository));
}
}
Dependency resolvedArtifact = resolver.resolveArtifact(depQuery);
FileResource<?> artifact = resolvedArtifact.getArtifact();
MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);