Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2012 Red Hat, Inc. and/or its affiliates.
  * Licensed under the Eclipse Public License version 1.0, available at
 package org.jboss.forge.maven.locators;
Locate a Maven project starting in the current directory, and progressing up the chain of parent directories until a project is found, or the root directory is found. If a project is found, return the referring to the directory containing that project, or return null if no projects were found.

Lincoln Baxter, III
public class MavenProjectLocator implements ProjectLocator
    private final ProjectFactory factory;
    private final Instance<MavenCoreFacetcoreFacetInstance;
    public MavenProjectLocator(final ProjectFactory factory, @Any final Instance<MavenCoreFacetcoreFacet)
        this. = factory;
        this. = coreFacet;
    public Project createProject(final DirectoryResource dir)
        Project result = new ProjectImpl(dir);
        MavenCoreFacet maven = .get();
        if (!maven.isInstalled())
            throw new IllegalStateException("Could not create Maven project [MavenCoreFacet could not be installed.]");
        return result;
    public boolean containsProject(final DirectoryResource dir)
        Resource<?> pom = dir.getChild("pom.xml");
        return pom.exists();
New to GrepCode? Check out our FAQ X