本文整理汇总了Java中org.eclipse.m2e.core.project.ProjectImportConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java ProjectImportConfiguration类的具体用法?Java ProjectImportConfiguration怎么用?Java ProjectImportConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectImportConfiguration类属于org.eclipse.m2e.core.project包,在下文中一共展示了ProjectImportConfiguration类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importToWorkspace
import org.eclipse.m2e.core.project.ProjectImportConfiguration; //导入依赖的package包/类
@Override
@SuppressWarnings("restriction")
public void importToWorkspace(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
JavaLanguageServerPlugin.logInfo("Importing Maven project(s)");
MavenConfigurationImpl configurationImpl = (MavenConfigurationImpl)MavenPlugin.getMavenConfiguration();
configurationImpl.setDownloadSources(true);
configurationImpl.setNotCoveredMojoExecutionSeverity(ProblemSeverity.ignore.toString());
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
Set<MavenProjectInfo> files = getMavenProjectInfo(subMonitor.split(5));
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Collection<IProject> projects = new LinkedHashSet<>();
Collection<MavenProjectInfo> toImport = new LinkedHashSet<>();
//Separate existing projects from new ones
for (MavenProjectInfo projectInfo : files) {
File pom = projectInfo.getPomFile();
IContainer container = root.getContainerForLocation(new Path(pom.getAbsolutePath()));
if (container == null) {
toImport.add(projectInfo);
} else {
IProject project = container.getProject();
if (ProjectUtils.isMavenProject(project)) {
projects.add(container.getProject());
} else if (project != null) {
//Project doesn't have the Maven nature, so we (re)import it
toImport.add(projectInfo);
}
}
}
if (!toImport.isEmpty()) {
ProjectImportConfiguration importConfig = new ProjectImportConfiguration();
configurationManager.importProjects(toImport, importConfig, subMonitor.split(95));
}
updateProjects(projects, monitor);
}
示例2: importMSF4JProject
import org.eclipse.m2e.core.project.ProjectImportConfiguration; //导入依赖的package包/类
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 {
}
}
示例3: AdvancedSettingsComponent
import org.eclipse.m2e.core.project.ProjectImportConfiguration; //导入依赖的package包/类
/**
* 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);
}
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-eclipse-developer-tools,代码行数:32,代码来源:AdvancedSettingsComponent.java
示例4: run
import org.eclipse.m2e.core.project.ProjectImportConfiguration; //导入依赖的package包/类
@Override
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException, OperationCanceledException {
if (!isValid()) {
throw new ProjectCreationException(
"Cannot create a project with invalid or incomplete inputs",
"Validation Failures: " + validate());
}
SubMonitor progress = SubMonitor.convert(monitor, 5);
checkCancelled(progress);
ProjectImportConfiguration projectImportConfiguration = new ProjectImportConfiguration();
if (projectNameTemplate != null) {
projectImportConfiguration.setProjectNameTemplate(projectNameTemplate);
}
checkCancelled(progress);
Archetype archetype = new Archetype();
archetype.setGroupId(DataflowMavenCoordinates.GROUP_ID);
archetype.setArtifactId(template.getArtifactId());
Properties archetypeProperties = new Properties();
archetypeProperties.setProperty("targetPlatform", getTargetPlatform());
IPath location = null;
if (customLocation) {
location = org.eclipse.core.filesystem.URIUtil.toPath(projectLocation);
}
Set<ArtifactVersion> archetypeVersions;
if (Strings.isNullOrEmpty(archetypeVersion)) {
// TODO: Configure the creator with a targeted Major Version
archetypeVersions = defaultArchetypeVersions(template, majorVersion);
} else {
archetypeVersions =
Collections.<ArtifactVersion>singleton(new DefaultArtifactVersion(archetypeVersion));
}
List<IProject> projects = Collections.emptyList();
List<CoreException> failures = new ArrayList<>();
MultiStatus status = new MultiStatus(DataflowCorePlugin.PLUGIN_ID, 38,
"Creating dataflow maven archetypes", null);
for (ArtifactVersion attemptedVersion : archetypeVersions) {
checkCancelled(progress);
// TODO: See if this can be done without using the toString method
archetype.setVersion(attemptedVersion.toString());
try {
projects = projectConfigurationManager.createArchetypeProjects(location, archetype,
// TODO: Get the version string from the user as well.
mavenGroupId, mavenArtifactId, "0.0.1-SNAPSHOT", packageString, archetypeProperties,
projectImportConfiguration, progress.newChild(4));
break;
} catch (CoreException ex) {
IStatus child = StatusUtil.error(this, ex.getMessage(), ex);
status.merge(child);
failures.add(ex);
}
}
if (projects.isEmpty()) { // failures only matter if no version succeeded
StatusUtil.setErrorStatus(this, "Error loading dataflow archetypes", status);
for (CoreException failure : failures) {
DataflowCorePlugin.logError(failure, "CoreException while creating new Dataflow Project");
}
} else {
SubMonitor natureMonitor = SubMonitor.convert(progress.newChild(1), projects.size());
for (IProject project : projects) {
try {
DataflowJavaProjectNature.addDataflowJavaNatureToProject(
project, natureMonitor.newChild(1));
setPreferences(project);
} catch (CoreException e) {
DataflowCorePlugin.logError(e,
"CoreException while adding Dataflow Nature to created project %s", project.getName());
}
}
}
monitor.done();
}