Search in sources :

Example 16 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project m2e-nar by maven-nar.

the class AbstractDependencyMojo method resolveEclipseProject.

private EclipseNarLayout resolveEclipseProject(final Artifact artifact, final ConfiguratorContext context, IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
    final IMavenProjectRegistry projectManager = context.getProjectManager();
    if (!Artifact.SCOPE_COMPILE.equals(artifact.getScope()) && !Artifact.SCOPE_TEST.equals(artifact.getScope())) {
        return null;
    }
    IMavenProjectFacade dependency = projectManager.getMavenProject(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion());
    if (dependency == null || dependency.getFullPath(artifact.getFile()) == null) {
        return null;
    }
    if (dependency.getProject().equals(facade.getProject())) {
        return null;
    }
    getLog().debug("Found dependency project " + dependency.getProject().getName());
    EclipseNarLayout layout = new EclipseNarLayout(getLog());
    layout.setProject(dependency);
    List<NarExecution> narExecutions = MavenUtils.buildCompileNarExecutions(context, dependency, monitor);
    getLog().debug("Found " + narExecutions.size() + " compile executions");
    com.github.sdedwards.m2e_nar.internal.model.NarBuildArtifact artifactSettings = null;
    for (NarExecution narSettings : narExecutions) {
        for (com.github.sdedwards.m2e_nar.internal.model.NarBuildArtifact settings : narSettings.getArtifactSettings()) {
            layout.addArtifactName(settings.getType(), settings.getArtifactName());
            artifactSettings = settings;
        }
    }
    if (artifactSettings != null) {
        for (String includePath : artifactSettings.getCSettings().getIncludePaths()) {
            layout.addIncludeDirectory(new File(includePath));
        }
        for (String includePath : artifactSettings.getCppSettings().getIncludePaths()) {
            layout.addIncludeDirectory(new File(includePath));
        }
        return layout;
    }
    return null;
}
Also used : IMavenProjectRegistry(org.eclipse.m2e.core.project.IMavenProjectRegistry) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) File(java.io.File) NarExecution(com.github.sdedwards.m2e_nar.internal.model.NarExecution)

Example 17 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project m2e-nar by maven-nar.

the class AbstractTestBuild method validateCdtProject.

private void validateCdtProject(IProject project) {
    final MavenProjectManager projectManager = MavenPluginActivator.getDefault().getMavenProjectManager();
    final IMavenProjectFacade facade = projectManager.getProject(project);
    assertNotNull(facade);
}
Also used : IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) MavenProjectManager(org.eclipse.m2e.core.internal.project.registry.MavenProjectManager)

Example 18 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project azure-tools-for-java by Microsoft.

the class MavenExecuteAction method setProjectConfiguration.

private void setProjectConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IContainer basedir) {
    IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
    IFile pomFile = basedir.getFile(new Path(IMavenConstants.POM_FILE_NAME));
    IMavenProjectFacade projectFacade = projectManager.create(pomFile, false, new NullProgressMonitor());
    if (projectFacade != null) {
        ResolverConfiguration configuration = projectFacade.getResolverConfiguration();
        String selectedProfiles = configuration.getSelectedProfiles();
        if (selectedProfiles != null && selectedProfiles.length() > 0) {
            workingCopy.setAttribute(MavenLaunchConstants.ATTR_PROFILES, selectedProfiles);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) IMavenProjectRegistry(org.eclipse.m2e.core.project.IMavenProjectRegistry) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

Example 19 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project azure-tools-for-java by Microsoft.

the class MavenUtils method getMavenProject.

@NotNull
private static MavenProject getMavenProject(@NotNull IFile pom) throws Exception {
    final IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
    final NullProgressMonitor monitor = new NullProgressMonitor();
    if (projectManager == null) {
        throw new Exception(CANNOT_GET_REG);
    }
    final IMavenProjectFacade mavenFacade = projectManager.create(pom, true, monitor);
    if (mavenFacade == null) {
        throw new Exception(CANNOT_CREATE_FACADE);
    }
    final MavenProject mavenProject = mavenFacade.getMavenProject(monitor);
    if (mavenProject == null) {
        throw new Exception(CANNOT_GET_MAVEN_PROJ);
    }
    final ResolverConfiguration configuration = mavenFacade.getResolverConfiguration();
    configuration.setResolveWorkspaceProjects(true);
    return mavenProject;
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) IMavenProjectRegistry(org.eclipse.m2e.core.project.IMavenProjectRegistry) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) CoreException(org.eclipse.core.runtime.CoreException) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Example 20 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project bndtools by bndtools.

the class MavenWorkspaceRepository method mavenProjectChanged.

@Override
public void mavenProjectChanged(MavenProjectChangedEvent[] events, IProgressMonitor monitor) {
    if (events == null)
        return;
    for (MavenProjectChangedEvent event : events) {
        final IMavenProjectFacade oldProject = event.getOldMavenProject();
        Iterator<Entry<String, IMavenProjectFacade>> entries = bsnMap.entrySet().iterator();
        while (entries.hasNext()) {
            Entry<String, IMavenProjectFacade> entry = entries.next();
            if (entry.getValue().equals(oldProject)) {
                String bsn = entry.getKey();
                bsnMap.remove(bsn);
                break;
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) MavenProjectChangedEvent(org.eclipse.m2e.core.project.MavenProjectChangedEvent)

Aggregations

IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)54 MavenProject (org.apache.maven.project.MavenProject)21 IProject (org.eclipse.core.resources.IProject)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)19 CoreException (org.eclipse.core.runtime.CoreException)18 IPath (org.eclipse.core.runtime.IPath)16 IFile (org.eclipse.core.resources.IFile)13 File (java.io.File)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 Path (org.eclipse.core.runtime.Path)10 IStatus (org.eclipse.core.runtime.IStatus)9 Test (org.junit.Test)9 MavenPlugin (org.eclipse.m2e.core.MavenPlugin)6 Plugin (org.apache.maven.model.Plugin)5 IFolder (org.eclipse.core.resources.IFolder)5 ICallable (org.eclipse.m2e.core.embedder.ICallable)5 IMavenExecutionContext (org.eclipse.m2e.core.embedder.IMavenExecutionContext)5 FacetedMavenProject (com.liferay.ide.maven.core.FacetedMavenProject)4 ArrayList (java.util.ArrayList)4 IMavenProjectRegistry (org.eclipse.m2e.core.project.IMavenProjectRegistry)4