public class MavenProjectLocator implements ProjectLocator
{
@Override
public Project createProject(final DirectoryResource dir)
{
Project project = new AbstractProject()
{
@Override
public boolean supports(ProjectFacet type)
{
return true;
}
@Override
public DirectoryResource getProjectRoot()
{
return dir;
}
@Override
public String toString()
{
return dir.toString();
}
};
List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>();
result.add(MavenFacetImpl.class);
result.add(MavenMetadataFacet.class);
result.add(MavenPackagingFacet.class);
result.add(MavenDependencyFacet.class);
result.add(MavenResourceFacet.class);
MavenFacetImpl mavenFacetImpl = new MavenFacetImpl();
mavenFacetImpl.setOrigin(project);
if (!project.install(mavenFacetImpl))
{
throw new IllegalStateException("Could not install Maven into Project located at ["
+ dir.getFullyQualifiedName() + "]");
}