Java Code Examples for org.eclipse.m2e.core.MavenPlugin#getProjectConfigurationManager()

The following examples show how to use org.eclipse.m2e.core.MavenPlugin#getProjectConfigurationManager() . 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: MavenBuildSupport.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public MavenBuildSupport() {
	this.configurationManager = MavenPlugin.getProjectConfigurationManager();
	this.projectManager = MavenPluginActivator.getDefault().getMavenProjectManagerImpl();
	this.digestStore = JavaLanguageServerPlugin.getDigestStore();
	this.registry = MavenPlugin.getMavenProjectRegistry();
	this.shouldCollectProjects = true;
}
 
Example 2
Source File: GwtMavenTestingUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Convert the standard Java project to a Maven project. This will remove the Default GWT sdk and
 * instead use a GWT Maven sdk distribution. Using the Maven classpath container will allow for
 * adding a specific GWT version easily.
 *
 * TODO Embue the WebAppCreator factory or create a Maven web app factory with Maven creation
 * options.
 */
public static void createMavenProject(IProject project, String withGwtSdkVersion) throws Exception {
  // Remove the default GWT sdk container from classpath, instead use Maven
  IJavaProject javaProject = JavaCore.create(project);
  IClasspathEntry[] entriesWithGwtContainer = javaProject.getRawClasspath();
  IClasspathEntry[] entriesWithOutGwtContainer =
      new IClasspathEntry[entriesWithGwtContainer.length - 1];
  int b = 0;
  for (int a = 0; a < entriesWithGwtContainer.length; a++) {
    String path = entriesWithGwtContainer[a].getPath().toString();
    if (!path.contains(GWTRuntimeContainer.CONTAINER_ID)) {
      entriesWithOutGwtContainer[b] = entriesWithGwtContainer[a];
      b++;
    }
  }
  // Removing the GWT SDK classpath entry from project
  javaProject.setRawClasspath(entriesWithOutGwtContainer, new NullProgressMonitor());
  JobsUtilities.waitForIdle();

  // Provide a pom.xml for a bare-bones configuration to convert standard project to Maven nature
  URL url = GwtTestingPlugin.getDefault().getBundle().getResource("resources/pom.xml");
  InputStream pomxmlStream = url.openStream();
  pomxmlStream = changeGwtSdkVersionInPom(pomxmlStream, withGwtSdkVersion);
  ResourceUtils.createFile(project.getFullPath().append("pom.xml"), pomxmlStream);

  // Turn on the Maven nature
  NatureUtils.addNature(project, MAVEN2_NATURE_ID);
  JobsUtilities.waitForIdle();

  // Maven update project will add the Maven dependencies to the classpath
  IProjectConfigurationManager projectConfig = MavenPlugin.getProjectConfigurationManager();
  projectConfig.updateProjectConfiguration(project, new NullProgressMonitor());
  JobsUtilities.waitForIdle();
}
 
Example 3
Source File: MavenEnablingWebAppCreatorParicipant.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void runJob() {
  Job job = new Job("Importing Maven Project") {
    @Override
    protected IStatus run(IProgressMonitor monitor) {
      // Turn on the Maven nature
      try {
        NatureUtils.addNature(javaProject.getProject(), MavenUtils.MAVEN2_NATURE_ID);
      } catch (CoreException e1) {
        e1.printStackTrace();
        return Status.CANCEL_STATUS;
      }

      Activator.log("MavenEnablingWebAppCreatorParicipant: Turning on Maven Nature");

      // Maven update project will add the Maven dependencies to the classpath
      IProjectConfigurationManager projectConfig = MavenPlugin.getProjectConfigurationManager();
      try {
        projectConfig.updateProjectConfiguration(javaProject.getProject(), monitor);
      } catch (CoreException e) {
        // TODO(${user}): Auto-generated catch block
        e.printStackTrace();
      }
      return Status.OK_STATUS;
    }
  };
  job.schedule();
}
 
Example 4
Source File: MSF4JProjectImporter.java    From msf4j with Apache License 2.0 5 votes vote down vote up
public void importMSF4JProject(MSF4JProjectModel msf4jProjectModel, String projectName, File pomFile,
		IProgressMonitor monitor) throws CoreException {
	String operationText;
	Set<MavenProjectInfo> projectSet = null;
	if (pomFile.exists()) {

		IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
		MavenModelManager mavenModelManager = MavenPlugin.getMavenModelManager();
		LocalProjectScanner scanner = new LocalProjectScanner(
				ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), //
				projectName, false, mavenModelManager);
		operationText = "Scanning maven project.";
		monitor.subTask(operationText);
		try {
			scanner.run(new SubProgressMonitor(monitor, 15));
			projectSet = configurationManager.collectProjects(scanner.getProjects());
			for (MavenProjectInfo projectInfo : projectSet) {
				if (projectInfo != null) {
					saveMavenParentInfo(projectInfo);
				}
			}
			ProjectImportConfiguration configuration = new ProjectImportConfiguration();
			operationText = "importing maven project.";
			monitor.subTask(operationText);
			if (projectSet != null && !projectSet.isEmpty()) {
				List<IMavenProjectImportResult> importResults = configurationManager.importProjects(projectSet,
						configuration, new SubProgressMonitor(monitor, 60));
			}
		} catch (InterruptedException | IOException | XmlPullParserException e) {
			Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
			MessageDialog errorDialog = new MessageDialog(shell, ERROR_TAG, null,
					"Unable to import the project, Error occurred while importing the generated project.",
					MessageDialog.ERROR, new String[] { OK_BUTTON }, 0);
			errorDialog.open();
		}

	} else {
	}
}
 
Example 5
Source File: DataflowProjectCreator.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
public static DataflowProjectCreator create() {
  return new DataflowProjectCreator(MavenPlugin.getProjectConfigurationManager());
}
 
Example 6
Source File: MavenProjectImporter.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public MavenProjectImporter() {
	this.configurationManager = MavenPlugin.getProjectConfigurationManager();
	this.digestStore = JavaLanguageServerPlugin.getDigestStore();
}
 
Example 7
Source File: ExportServiceAction.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
private ITalendProcessJavaProject createSimpleProject(IProgressMonitor monitor, IProject p, Model model,
        ProjectImportConfiguration importConfiguration) throws CoreException {
    final String[] directories = getFolders();

    ProjectConfigurationManager projectConfigurationManager = (ProjectConfigurationManager) MavenPlugin
            .getProjectConfigurationManager();

    String projectName = p.getName();
    monitor.beginTask(NLS.bind(Messages.ProjectConfigurationManager_task_creating, projectName), 5);

    monitor.subTask(Messages.ProjectConfigurationManager_task_creating_workspace);

    ITalendProcessJavaProject javaProject = TalendJavaProjectManager.getTalendJobJavaProject(serviceItem.getProperty());
    // ITalendProcessJavaProject javaProject =
    // TalendJavaProjectManager.getTalendCodeJavaProject(ERepositoryObjectType.PROCESS);

    p.open(monitor);
    monitor.worked(1);

    // hideNestedProjectsFromParents(Collections.singletonList(p));

    monitor.worked(1);

    monitor.subTask(Messages.ProjectConfigurationManager_task_creating_pom);
    IFile pomFile = p.getFile(TalendMavenConstants.POM_FILE_NAME);
    if (!pomFile.exists()) {
        MavenPlugin.getMavenModelManager().createMavenModel(pomFile, model);
    }
    monitor.worked(1);

    monitor.subTask(Messages.ProjectConfigurationManager_task_creating_folders);
    for (int i = 0; i < directories.length; i++) {
        ProjectConfigurationManager.createFolder(p.getFolder(directories[i]), false);
    }
    monitor.worked(1);

    monitor.subTask(Messages.ProjectConfigurationManager_task_creating_project);
    projectConfigurationManager.enableMavenNature(p, importConfiguration.getResolverConfiguration(), monitor);
    monitor.worked(1);

    // if (this.pomFile == null) {
    // this.pomFile = pomFile;
    // }

    return javaProject;
}