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;
}
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);
}
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);
}
}
}
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;
}
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;
}
}
}
}
Aggregations