org.eclipse.m2e.core.project.ProjectImportConfiguration Java Examples

The following examples show how to use org.eclipse.m2e.core.project.ProjectImportConfiguration. 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: ImportUtil.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static IProject importExistingMavenProjects(IPath path, String projectName) throws Exception {
	File root = path.toFile();
	String location = path.toOSString();
	MavenModelManager modelManager = MavenPlugin.getMavenModelManager();
	LocalProjectScanner scanner = new LocalProjectScanner(root, location, false, modelManager);
	scanner.run(new NullProgressMonitor());
	List<MavenProjectInfo> infos = new ArrayList<MavenProjectInfo>();
	infos.addAll(scanner.getProjects());
	for(MavenProjectInfo info : scanner.getProjects()){
		infos.addAll(info.getProjects());
	}
	ImportMavenProjectsJob job = new ImportMavenProjectsJob(infos, new ArrayList<IWorkingSet>(), new ProjectImportConfiguration());
	job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
	job.schedule();
	IProject project = waitForProject(projectName);
	return project;
}
 
Example #2
Source File: DataflowProjectCreatorTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testRun_propagatesCoreException()
    throws OperationCanceledException, InterruptedException, CoreException {
  IProjectConfigurationManager manager = mock(IProjectConfigurationManager.class);
  CoreException exception = new CoreException(StatusUtil.error(this, "test error message"));
  doThrow(exception).when(manager).createArchetypeProjects(
      any(IPath.class), any(Archetype.class), anyString(), anyString(), anyString(), anyString(),
      any(Properties.class), any(ProjectImportConfiguration.class), any(IProgressMonitor.class));

  DataflowProjectCreator creator = new DataflowProjectCreator(manager);
  creator.setMavenGroupId("com.example");
  creator.setMavenArtifactId("some-artifact-id");
  creator.setPackage("com.example");
  creator.setArchetypeVersion("123.456.789");
  try {
    creator.run(new NullProgressMonitor());
    fail();
  } catch (InvocationTargetException ex) {
    assertEquals(exception, ex.getCause());
  }
}
 
Example #3
Source File: ExportServiceAction.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
protected ITalendProcessJavaProject createServiceJavaProject() {
    IProgressMonitor monitor = new NullProgressMonitor();

    // temp model.
    Model model = new Model();
    model.setModelVersion("4.0.0"); //$NON-NLS-1$
    model.setGroupId(PomIdsHelper.getJobGroupId(serviceItem.getProperty()));
    model.setArtifactId(PomIdsHelper.getJobArtifactId(serviceItem.getProperty())); // $NON-NLS-1$
    model.setVersion(PomIdsHelper.getProjectVersion());
    model.setPackaging(TalendMavenConstants.PACKAGING_JAR);

    // always use temp model to avoid classpath problem
    final ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration();
    IProject root = ResourcesPlugin.getWorkspace().getRoot()
            .getProject(ProjectManager.getInstance().getCurrentProject().getTechnicalLabel());
    try {
        return createSimpleProject(monitor, root, model, importConfiguration);
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return null;
}
 
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: ImportMavenSarlProjectsJob.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Constructor.
 *
 * @param projects the projects to import.
 * @param workingSets the working sets into which the projects should be added.
 * @param importConfiguration the import configuration.
 */
ImportMavenSarlProjectsJob(
		Collection<MavenProjectInfo> projects,
		List<IWorkingSet> workingSets,
		ProjectImportConfiguration importConfiguration) {
	super(Messages.MavenImportWizard_job);
	this.projects = projects;
	this.workingSets = workingSets;
	this.importConfiguration = importConfiguration;
}
 
Example #6
Source File: AdvancedSettingsComponent.java    From aem-eclipse-developer-tools with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new component.
 * 
 * @param wizardPage
 */
public AdvancedSettingsComponent(final Composite parent,
        final ProjectImportConfiguration propectImportConfiguration,
        final boolean enableProjectNameTemplate,
        SimplerParametersWizardPage wizardPage) {
    super(parent, ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE
            | ExpandableComposite.EXPANDED);
    this.wizardPage = wizardPage;
    setText("Advanced");
    final Composite advancedComposite = new Composite(this, SWT.NONE);
    setClient(advancedComposite);
    addExpansionListener(new ExpansionAdapter() {
        public void expansionStateChanged(ExpansionEvent e) {
            Shell shell = parent.getShell();
            Point minSize = shell.getMinimumSize();
            shell.setMinimumSize(shell.getSize().x, minSize.y);
            shell.pack();
            parent.layout();
            shell.setMinimumSize(minSize);
        }
    });
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginLeft = 11;
    gridLayout.numColumns = 2;
    advancedComposite.setLayout(gridLayout);
    createAdvancedSection(advancedComposite);
}
 
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;
}
 
Example #8
Source File: ImportMavenSarlProjectsJob.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Replies the import configuration.
 *
 * @return the import configuration.
 */
protected ProjectImportConfiguration getImportConfiguration() {
	return this.importConfiguration;
}