本文整理汇总了Java中org.eclipse.m2e.core.project.IProjectConfigurationManager类的典型用法代码示例。如果您正苦于以下问题:Java IProjectConfigurationManager类的具体用法?Java IProjectConfigurationManager怎么用?Java IProjectConfigurationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProjectConfigurationManager类属于org.eclipse.m2e.core.project包,在下文中一共展示了IProjectConfigurationManager类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.eclipse.m2e.core.project.IProjectConfigurationManager; //导入依赖的package包/类
@Override
public void update(IProject project, IProgressMonitor monitor) throws CoreException {
if (!applies(project)) {
return;
}
JavaLanguageServerPlugin.logInfo("Starting Maven update for "+project.getName());
//TODO collect dependent projects and update them as well? i.e in case a parent project was modified
IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
MavenUpdateRequest request = new MavenUpdateRequest(project, MavenPlugin.getMavenConfiguration().isOffline(), true);
configurationManager.updateProjectConfiguration(request, monitor);
}
示例2: createMavenProject
import org.eclipse.m2e.core.project.IProjectConfigurationManager; //导入依赖的package包/类
/**
* 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();
}
示例3: runJob
import org.eclipse.m2e.core.project.IProjectConfigurationManager; //导入依赖的package包/类
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();
}
示例4: importMSF4JProject
import org.eclipse.m2e.core.project.IProjectConfigurationManager; //导入依赖的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 {
}
}
示例5: DataflowProjectCreator
import org.eclipse.m2e.core.project.IProjectConfigurationManager; //导入依赖的package包/类
private DataflowProjectCreator(IProjectConfigurationManager projectConfigurationManager) {
this.projectConfigurationManager = projectConfigurationManager;
template = DataflowProjectArchetype.STARTER_POM_WITH_PIPELINE;
}
示例6: MavenProjectImporter
import org.eclipse.m2e.core.project.IProjectConfigurationManager; //导入依赖的package包/类
public MavenProjectImporter(IProjectConfigurationManager configurationManager) {
this.configurationManager = configurationManager;
}
示例7: configure
import org.eclipse.m2e.core.project.IProjectConfigurationManager; //导入依赖的package包/类
@Override
public void configure() throws CoreException {
new Job("Configure project") {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask("Configure project natures and builders", IProgressMonitor.UNKNOWN);
try {
final IProjectDescription projectDescription = project.getDescription();
final CodenvyProjectDescriptor projectDescriptor = CodenvyProjectDescriptor.load(getProject());
final String eclipseNature = ECLIPSE_NATURE_MAPPINGS.get(projectDescriptor.type);
if (eclipseNature != null && isNatureWithId(eclipseNature)) {
projectDescription.setNatureIds(concat(projectDescription.getNatureIds(), eclipseNature));
}
final String eclipseBuilder = ECLIPSE_BUILDER_MAPPINGS.get(projectDescriptor.type);
if (eclipseBuilder != null) {
final List<ICommand> builders = new ArrayList<>();
final ICommand command = projectDescription.newCommand();
command.setBuilderName(eclipseBuilder);
builders.add(command);
projectDescription.setBuildSpec(builders.toArray(new ICommand[0]));
}
// save nature and builders added to the project
project.setDescription(projectDescription, monitor);
final String codenvyBuilder = projectDescriptor.builders.get(DEFAULT_PROJECT_BUILDER);
if (MAVEN_BUILDER_NAME.equals(codenvyBuilder)) {
projectDescription.setNatureIds(concat(projectDescription.getNatureIds(), MAVEN_NATURE_ID));
project.setDescription(projectDescription, monitor);
final IProjectConfigurationManager projectConfigurationManager = MavenPlugin.getProjectConfigurationManager();
projectConfigurationManager.updateProjectConfiguration(project, monitor);
}
} catch (CoreException e) {
throw new RuntimeException(e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
return FAMILY_CODENVY.equals(family);
}
}.schedule();
}