org.eclipse.m2e.core.project.IMavenProjectFacade Java Examples
The following examples show how to use
org.eclipse.m2e.core.project.IMavenProjectFacade.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IgnoreMavenTargetFolderContribution.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public boolean isRejected(IFolder folder) { IMavenProjectFacade mavenProjectFacade = MavenPlugin.getMavenProjectRegistry().getProject(folder.getProject()); if (mavenProjectFacade == null) { return false; } IPath outputLocation = mavenProjectFacade.getOutputLocation(); if (outputLocation == null) { return false; } else if (folder.getFullPath().equals(outputLocation)) { return true; } IPath testOutputLocation = mavenProjectFacade.getTestOutputLocation(); if (testOutputLocation == null) { return false; } else if (folder.getFullPath().equals(testOutputLocation)) { return true; } return false; }
Example #2
Source File: MavenBuildSupport.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public void collectProjects(Collection<IProject> projects, IProject project, IProgressMonitor monitor) { if (!project.isOpen() || !ProjectUtils.isMavenProject(project)) { return; } projects.add(project); IMavenProjectFacade projectFacade = registry.create(project, monitor); if (projectFacade != null && "pom".equals(projectFacade.getPackaging())) { List<String> modules = projectFacade.getMavenProjectModules(); for (String module : modules) { IPath pomPath = ResourcesPlugin.getWorkspace().getRoot().getFullPath().append(module).append("pom.xml"); IFile pom = ResourcesPlugin.getWorkspace().getRoot().getFile(pomPath); if (pom.exists()) { IProject p = pom.getProject(); if (p.isOpen()) { collectProjects(projects, p, monitor); } } } } }
Example #3
Source File: MavenProjectConfigurator.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@Override public AbstractBuildParticipant getBuildParticipant(final IMavenProjectFacade projectFacade, MojoExecution execution, final IPluginExecutionMetadata executionMetadata) { Activator.log("MavenProjectConfigurator.getBuildParticipant for Maven invoked"); // Run the execution generate-module for maven2 plugin // Don't run on war for gwt maven plugin1 MojoExecutionBuildParticipant build = null; MavenProject mavenProject = projectFacade.getMavenProject(); if (mavenProject != null && isGwtMavenPlugin2(mavenProject)) { Activator.log("MavenProjectConfigurator.getBuildParticipant adding build participant for generate-module."); build = new MojoExecutionBuildParticipant(execution, true, true); } return build; }
Example #4
Source File: DataflowMavenModel.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
public DataflowMavenModel fromProject(IProject project) throws CoreException { Preconditions.checkNotNull(project); if (!DataflowJavaProjectNature.hasDataflowNature(project)) { String errorMessage = String.format( "Tried to create the Dataflow dependency of a non-Dataflow project %s", project.getName()); DataflowCorePlugin.logWarning(errorMessage); throw new IllegalArgumentException(errorMessage); } IMavenProjectFacade facade = projectRegistry.getProject(project); IFile pomFile = facade.getPom(); return fromIFile(pomFile); }
Example #5
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
@Override public void configureRawClasspath(ProjectConfigurationRequest request, IClasspathDescriptor classpath, IProgressMonitor monitor) throws CoreException { final SubMonitor subm = SubMonitor.convert(monitor, 4); final IMavenProjectFacade facade = request.getMavenProjectFacade(); final SARLConfiguration config = readConfiguration(request, subm.newChild(1)); subm.worked(1); removeSarlLibraries(classpath); subm.worked(2); configureSarlProject(facade, config, classpath, true, subm); }
Example #6
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
private void configureSarlProject(IMavenProjectFacade facade, SARLConfiguration config, IClasspathDescriptor classpath, boolean addTestFolders, IProgressMonitor monitor) throws CoreException { final SubMonitor subm = SubMonitor.convert(monitor, 2); addSourceFolders(facade, config, classpath, addTestFolders, subm.newChild(1)); subm.worked(1); addPreferences(facade, config, addTestFolders, subm.newChild(1)); subm.worked(1); }
Example #7
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("checkstyle:magicnumber") public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { final IMavenProjectFacade facade = request.getMavenProjectFacade(); // --- ECLIPSE PLUGIN --------------------------------------------------------------- // Special case of tycho plugins, for which the {@link #configureRawClasspath} // and {@link #configureClasspath} were not invoked. // ---------------------------------------------------------------------------------- final boolean isEclipsePlugin = isEclipsePluginPackaging(facade); final SubMonitor subMonitor; subMonitor = SubMonitor.convert(monitor, 3); final IProject project = request.getProject(); final SARLConfiguration config = readConfiguration(request, subMonitor.newChild(1)); subMonitor.worked(1); forceMavenCompilerConfiguration(facade, config); subMonitor.worked(1); // --- ECLIPSE PLUGIN --------------------------------------------------------------- if (isEclipsePlugin) { // In the case of Eclipse bundle, the face to the Java project must be created by hand. final IJavaProject javaProject = JavaCore.create(project); final IClasspathDescriptor classpath = new ClasspathDescriptor(javaProject); configureSarlProject(facade, config, classpath, false, subMonitor.newChild(1)); subMonitor.worked(1); } // ---------------------------------------------------------------------------------- io.sarl.eclipse.natures.SARLProjectConfigurator.addSarlNatures( project, subMonitor.newChild(1)); subMonitor.worked(1); }
Example #8
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
private static void forceMavenCompilerConfiguration(IMavenProjectFacade facade, SARLConfiguration config) { final Properties props = facade.getMavenProject().getProperties(); setVersion(props, "maven.compiler.source", config.getInputCompliance(), //$NON-NLS-1$ SARLVersion.MINIMAL_JDK_VERSION_FOR_SARL_COMPILATION_ENVIRONMENT, SARLVersion.INCOMPATIBLE_JDK_VERSION_FOR_SARL_COMPILATION_ENVIRONMENT); setVersion(props, "maven.compiler.target", config.getOutputCompliance(), //$NON-NLS-1$ SARLVersion.MINIMAL_JDK_VERSION_FOR_SARL_COMPILATION_ENVIRONMENT, SARLVersion.INCOMPATIBLE_JDK_VERSION_FOR_SARL_COMPILATION_ENVIRONMENT); final String encoding = config.getEncoding(); if (encoding != null && !encoding.isEmpty()) { props.setProperty("maven.compiler.encoding", encoding); //$NON-NLS-1$ } }
Example #9
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
private static IFolder ensureFolderExists(IMavenProjectFacade facade, IPath path, boolean derived, IProgressMonitor monitor) throws CoreException { final IFolder folder = facade.getProject().getFolder(path.makeRelativeTo(facade.getProject().getFullPath())); assert folder != null; if (!folder.exists()) { M2EUtils.createFolder(folder, derived || folder.isDerived(), monitor); } return folder; }
Example #10
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
private static IPath makeProjectRelativePath(IMavenProjectFacade facade, File file) { assert file != null; final IProject project = facade.getProject(); if (!file.isAbsolute()) { return Path.fromOSString(file.getPath()); } return MavenProjectUtils.getProjectRelativePath(project, file.getAbsolutePath()); }
Example #11
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
private static IPath makeFullPath(IMavenProjectFacade facade, File file) { assert file != null; final IProject project = facade.getProject(); final IPath path; if (!file.isAbsolute()) { path = Path.fromOSString(file.getPath()); } else { path = MavenProjectUtils.getProjectRelativePath(project, file.getAbsolutePath()); } return project.getFullPath().append(path); }
Example #12
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 5 votes |
/** Invoked to add the preferences dedicated to SARL, JRE, etc. * * @param facade the Maven face. * @param config the configuration. * @param addTestFolders indicates if the test folders should be considered. * @param monitor the monitor. * @throws CoreException if cannot add the source folders. */ @SuppressWarnings("static-method") protected void addPreferences( IMavenProjectFacade facade, SARLConfiguration config, boolean addTestFolders, IProgressMonitor monitor) throws CoreException { final IPath outputPath = makeProjectRelativePath(facade, config.getOutput()); final IPath testOutputPath = addTestFolders ? makeProjectRelativePath(facade, config.getTestOutput()) : null; // Set the SARL preferences SARLPreferences.setSpecificSARLConfigurationFor( facade.getProject(), outputPath, testOutputPath); }
Example #13
Source File: MavenProjectSREProviderFactory.java From sarl with Apache License 2.0 | 5 votes |
@Override public ProjectSREProvider getProjectSREProvider(IProject project) { try { if (project.hasNature(IMavenConstants.NATURE_ID) && project.hasNature(JavaCore.NATURE_ID) && project.hasNature(SARLEclipseConfig.NATURE_ID)) { final IMavenProjectFacade facade = MavenPluginActivator.getDefault() .getMavenProjectManager().getProject(project); if (facade == null) { return null; } final IJavaProject javaProject = JavaCore.create(project); final IClasspathEntry[] classpath = javaProject.getResolvedClasspath(true); if (classpath == null) { return null; } for (final IClasspathEntry dep : classpath) { final IPath depPath = dep.getPath(); if (SARLRuntime.isPackedSRE(depPath)) { return new MavenProjectSREProvider( facade.getArtifactKey().toString() + ":" + depPath.lastSegment(), //$NON-NLS-1$ depPath); } } } } catch (CoreException e) { SARLMavenEclipsePlugin.getDefault().log(e); } return null; }
Example #14
Source File: GwtFacetDetector.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Not applicable, it will always use version 1. */ @Override public IProjectFacetVersion findFacetVersion(IMavenProjectFacade arg0, Map<?, ?> arg1, IProgressMonitor arg2) throws CoreException { return null; }
Example #15
Source File: WtpMavenProjectConfigurator.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public AbstractBuildParticipant getBuildParticipant(IMavenProjectFacade projectFacade, MojoExecution execution, IPluginExecutionMetadata executionMetadata) { GwtMavenPlugin.logInfo("WtpMavenProjectConfigurator.getBuildParticipant invoked"); return super.getBuildParticipant(projectFacade, execution, executionMetadata); }
Example #16
Source File: MyMvnSourceContainerBrowser.java From m2e.sourcelookup with Eclipse Public License 1.0 | 5 votes |
private static List<IJavaProject> getPossibleAdditions0(final ISourceLookupDirector director) { final List<IProject> mavenProjects = new ArrayList<IProject>(); for (final IMavenProjectFacade mavenProject : MavenPlugin.getMavenProjectRegistry().getProjects()) { mavenProjects.add(mavenProject.getProject()); } final List<IJavaProject> javaProjects = new ArrayList<IJavaProject>(); final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); try { for (final IJavaProject javaProject : JavaCore.create(root).getJavaProjects()) { if (mavenProjects.contains(javaProject.getProject())) { javaProjects.add(javaProject); } } } catch (final JavaModelException e) { final IStatus status = new Status(IStatus.ERROR, SourceLookupPlugin.getInstance().getBundle().getSymbolicName(), "Can't retrieve Java projects.", e); SourceLookupPlugin.getInstance().getLog().log(status); } for (final ISourceContainer container : director.getSourceContainers()) { if (container.getType().getId().equals(MyMvnSourceContainerTypeDelegate.TYPE_ID)) { javaProjects.remove(((MyMvnSourceContainer) container).getJavaProject()); } } return javaProjects; }
Example #17
Source File: DataflowDependencyManager.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private Model getModelFromProject(IProject project) { IMavenProjectFacade facade = mavenProjectRegistry.getProject(project); if (facade != null) { IFile pom = facade.getPom(); try { return maven.readModel(pom.getContents()); } catch (CoreException e) { return null; } } return null; }
Example #18
Source File: FlexMavenPackagedProjectStagingDelegate.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private static IPath getFinalArtifactPath(IProject project) throws CoreException { IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry(); IMavenProjectFacade projectFacade = projectManager.create(project, new NullProgressMonitor()); MavenProject mavenProject = projectFacade.getMavenProject(new NullProgressMonitor()); String buildDirectory = mavenProject.getBuild().getDirectory(); String finalName = mavenProject.getBuild().getFinalName(); String finalArtifactPath = buildDirectory + "/" + finalName + "." + mavenProject.getPackaging(); return new Path(finalArtifactPath); }
Example #19
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 4 votes |
@Override public void configureClasspath(IMavenProjectFacade facade, IClasspathDescriptor classpath, IProgressMonitor monitor) throws CoreException { // }
Example #20
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 4 votes |
@Override public AbstractBuildParticipant getBuildParticipant( IMavenProjectFacade projectFacade, MojoExecution execution, IPluginExecutionMetadata executionMetadata) { return new BuildParticipant(isEclipsePluginPackaging(projectFacade)); }
Example #21
Source File: SARLProjectConfigurator.java From sarl with Apache License 2.0 | 2 votes |
/** Replies if the given project facade is pointing an Eclipe plugin. * * @param facade the maven project facade. * @return {@code true} if the facade is for an Eclipse plugin. * @since 0.11 */ public boolean isEclipsePluginPackaging(IMavenProjectFacade facade) { return ECLIPSE_PLUGIN_PACKAGING.equalsIgnoreCase(facade.getPackaging()); }