org.eclipse.m2e.core.MavenPlugin Java Examples

The following examples show how to use org.eclipse.m2e.core.MavenPlugin. 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: MavenUtils.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
public static Artifact resolveArtifact(
    String groupId,
    String artifactId,
    String type,
    String version,
    String classifier,
    List<ArtifactRepository> repositories,
    IProgressMonitor monitor)
    throws CoreException {
  return runOperation(
      monitor,
      (context, system, progress) -> {
        IMaven maven = MavenPlugin.getMaven();
        Artifact artifact = maven.resolve(
            groupId, artifactId, version, type, classifier, repositories, progress);
        return artifact;
      });
}
 
Example #2
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 #3
Source File: ICECloneHandler.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 
 */
protected void fixMavenLifecycleFile() {
	// This is a fix for the errors that occur with the new ICE Build for 
	// certain maven goals.
	String file = MavenPlugin.getMavenConfiguration().getWorkspaceLifecycleMappingMetadataFile();
	try {
		Path path = Paths.get(file);
		if (Files.exists(path)) {
			Files.write(Paths.get(file), lifecycleXML.getBytes());
		} else {
			Files.write(Paths.get(file), lifecycleXML.getBytes(), StandardOpenOption.CREATE_NEW);
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example #4
Source File: MavenUtils.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if an artifact is available in the local repository. The artifact <code>version</code>
 * must be a specific value, cannot be "LATEST".
 */
public static boolean isArtifactAvailableLocally(String groupId, String artifactId,
                                                 String version, String type,
                                                 String classifier) {
  try {
    Preconditions.checkArgument(!MAVEN_LATEST_VERSION.equals(version));
    String artifactPath =
        MavenPlugin.getMaven().getLocalRepository()
            .pathOf(new DefaultArtifact(groupId, artifactId, version, null /* scope */, type,
                                        classifier, new DefaultArtifactHandler(type)));
    return new File(artifactPath).exists();
  } catch (CoreException ex) {
    logger.log(Level.SEVERE, "Could not lookup local repository", ex);
    return false;
  }
}
 
Example #5
Source File: NewGraniteProjectWizard.java    From aem-eclipse-developer-tools with Apache License 2.0 6 votes vote down vote up
private void fixParentProject(IProject p, IProject parentProject)
		throws CoreException {
	IFile existingPom = p.getFile("pom.xml");
	Model model = MavenPlugin.getMavenModelManager().readMavenModel(existingPom);
	Model parent = MavenPlugin.getMavenModelManager().readMavenModel(parentProject.getFile("pom.xml"));
	//Parent oldParent = model.getParent();
	Parent newParent = new Parent();
	newParent.setGroupId(parent.getGroupId());
	newParent.setArtifactId(parent.getArtifactId());
	newParent.setRelativePath(calculateRelativePath(p, parentProject));
	newParent.setVersion(parent.getVersion());
	model.setParent(newParent);
	// outright deletion doesn't work on windows as the process has a ref to the file itself
	// so creating a temp '_newpom_.xml'
	final IFile newPom = p.getFile("_newpom_.xml");
	MavenPlugin.getMavenModelManager().createMavenModel(newPom, model);
	// then copying that content over to the pom.xml
	existingPom.setContents(newPom.getContents(), true,  true, new NullProgressMonitor());
	// and deleting the temp pom
	newPom.delete(true,  false, new NullProgressMonitor());
	
}
 
Example #6
Source File: DependencyUtil.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static File getLocalArtifactFile(ArtifactKey a) {
	// can't use Maven resolve methods since they mark artifacts as not-found even if they could be resolved remotely
	IMaven maven = MavenPlugin.getMaven();
	try {
		ArtifactRepository localRepository = maven.getLocalRepository();
		String relPath = maven.getArtifactPath(localRepository, a.getGroupId(), a.getArtifactId(), a.getVersion(), "jar", //$NON-NLS-1$
				a.getClassifier());
		File file = new File(localRepository.getBasedir(), relPath).getCanonicalFile();
		if (file.canRead() && file.isFile()) {
			return file;
		}
	} catch (CoreException | IOException ex) {
		// fall through
	}
	return null;
}
 
Example #7
Source File: IgnoreMavenTargetFolderContribution.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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 #8
Source File: JCasGenM2ETest.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public void testSimple() throws Exception {
  System.out.println("Using this repository: " + MavenPlugin.getMaven().getLocalRepository());
  
  ResolverConfiguration configuration = new ResolverConfiguration();
  IProject project = importProject("target/projects/jcasgen/simple/pom.xml", configuration);
  waitForJobsToComplete();
  assertNoErrors(project);

  project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
  project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
  waitForJobsToComplete();
  assertNoErrors(project);

  // make sure the Java sources were generated
  String prefix = "target/generated-sources/jcasgen/type/";
  assertTrue(project.getFile(prefix + "span/Sentence.java").isAccessible());
  assertTrue(project.getFile(prefix + "span/Sentence_Type.java").isAccessible());
  assertTrue(project.getFile(prefix + "span/Token.java").isAccessible());
  assertTrue(project.getFile(prefix + "span/Token_Type.java").isAccessible());
  assertTrue(project.getFile(prefix + "relation/Dependency.java").isAccessible());
  assertTrue(project.getFile(prefix + "relation/Dependency_Type.java").isAccessible());

  // make sure the files are all synchronized in the workspace
  int zero = IResource.DEPTH_ZERO;
  assertTrue(project.getFile(prefix + "span/Sentence.java").isSynchronized(zero));
  assertTrue(project.getFile(prefix + "span/Sentence_Type.java").isSynchronized(zero));
  assertTrue(project.getFile(prefix + "span/Token.java").isSynchronized(zero));
  assertTrue(project.getFile(prefix + "span/Token_Type.java").isSynchronized(zero));
  assertTrue(project.getFile(prefix + "relation/Dependency.java").isSynchronized(zero));
  assertTrue(project.getFile(prefix + "relation/Dependency_Type.java").isSynchronized(zero));

  // make sure the generated sources are on the classpath
  Set<String> classpathEntries = new HashSet<String>();
  for (IClasspathEntry cpEntry : JavaCore.create(project).getRawClasspath()) {
    classpathEntries.add(cpEntry.getPath().toPortableString());
  }
  assertTrue(classpathEntries.contains("/simple/src/main/java"));
  assertTrue(classpathEntries.contains("/simple/target/generated-sources/jcasgen"));
}
 
Example #9
Source File: FixMavenLifecycleCloneHandler.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void addPostCloneTasks() {

	// Import all ICE projects
	cloneOperation.addPostCloneTask(new PostCloneTask() {
		@Override
		public void execute(Repository repository, IProgressMonitor monitor) throws CoreException {
			// This is a fix for the errors that occur with the new ICE Build for 
			// certain maven goals.
			String file = MavenPlugin.getMavenConfiguration().getWorkspaceLifecycleMappingMetadataFile();
			try {
				Path path = Paths.get(file);
				if (Files.exists(path)) {
					Files.write(Paths.get(file), lifecycleXML.getBytes());
				} else {
					Files.write(Paths.get(file), lifecycleXML.getBytes(), StandardOpenOption.CREATE_NEW);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	});
	
	// Import all projects
	super.addPostCloneTasks();
}
 
Example #10
Source File: NewMavenSarlProjectWizard.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public boolean performFinish() {
	if (!super.performFinish()) {
		return false;
	}
	final Job job = new WorkspaceJob("Force the SARL nature") { //$NON-NLS-1$
		@SuppressWarnings({ "deprecation", "synthetic-access" })
		@Override
		public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
			final Model model = NewMavenSarlProjectWizard.this.lastModel;
			if (model != null) {
				final Plugin plugin = Iterables.find(model.getBuild().getPlugins(), it -> PLUGIN_ARTIFACT_ID.equals(it.getArtifactId()));
				plugin.setExtensions(true);
				final IWorkspace workspace = ResourcesPlugin.getWorkspace();
				final IWorkspaceRoot root = workspace.getRoot();
				final IProject project = NewMavenSarlProjectWizard.this.importConfiguration.getProject(root, model);
				// Fixing the "extensions" within the pom file
				final IFile pomFile = project.getFile(IMavenConstants.POM_FILE_NAME);
				pomFile.delete(true, new NullProgressMonitor());
				MavenPlugin.getMavenModelManager().createMavenModel(pomFile, model);
				// Update the project
				final SubMonitor submon = SubMonitor.convert(monitor);
				MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(project, submon.newChild(1));
				project.refreshLocal(IResource.DEPTH_ONE, submon.newChild(1));
			}
			return Status.OK_STATUS;
		}
	};
	job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
	job.schedule();
	return true;
}
 
Example #11
Source File: MavenImportUtils.java    From sarl with Apache License 2.0 5 votes vote down vote up
private static AbstractProjectScanner<MavenProjectInfo> getProjectScanner(IWorkspaceRoot workspaceRoot, String projectName) {
	final File root = workspaceRoot.getLocation().toFile();
	final String projectPath = new File(root, projectName).getAbsolutePath();
	final MavenModelManager modelManager = MavenPlugin.getMavenModelManager();
	return new LocalProjectScanner(
			root,
			projectPath,
			false,
			modelManager);
}
 
Example #12
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 #13
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 #14
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 #15
Source File: MyMvnSourceContainerBrowser.java    From m2e.sourcelookup with Eclipse Public License 1.0 5 votes vote down vote up
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 #16
Source File: DependencyUtil.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static File getArtifact(String groupId, String artifactId, String version, String classifier) throws FileNotFoundException, CoreException {
	ArtifactKey key = new ArtifactKey(groupId, artifactId, version, classifier);
	File archive = getLocalArtifactFile(key);
	if (archive == null) {
		Artifact artifact = MavenPlugin.getMaven().resolve(key.getGroupId(), key.getArtifactId(), key.getVersion(), "jar", key.getClassifier(), null, new NullProgressMonitor());
		if (artifact == null) {
			throw new FileNotFoundException("Unable to find " + key);
		}
		archive = getLocalArtifactFile(key);
	}
	return archive;
}
 
Example #17
Source File: MavenUtils.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Perform some Maven-related action that may result in a change to the local Maven repositories,
 * ensuring that required {@link ISchedulingRule scheduling rules} are held.
 */
public static <T> T runOperation(IProgressMonitor monitor, MavenRepositoryOperation<T> operation)
    throws CoreException {
  SubMonitor progress = SubMonitor.convert(monitor, 10);
  ISchedulingRule rule = mavenResolvingRule();
  boolean acquireRule = Job.getJobManager().currentRule() == null;
  if (acquireRule) {
    Job.getJobManager().beginRule(rule, progress.split(2));
  }
  try {
    Verify.verify(
        Job.getJobManager().currentRule().contains(rule),
        "require holding superset of rule: " + rule);
    IMavenExecutionContext context = MavenPlugin.getMaven().createExecutionContext();
    return context.execute(
        (context2, monitor2) -> {
          // todo we'd prefer not to depend on m2e here
          RepositorySystem system = MavenPluginActivator.getDefault().getRepositorySystem();
          return operation.run(context2, system, SubMonitor.convert(monitor2));
        },
        progress.split(8));
  } finally {
    if (acquireRule) {
      Job.getJobManager().endRule(rule);
    }
  }
}
 
Example #18
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 #19
Source File: CreateAppEngineWtpProject.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private static void enableMavenNature(IProject newProject, IProgressMonitor monitor)
    throws CoreException {
  SubMonitor subMonitor = SubMonitor.convert(monitor, 30);

  ResolverConfiguration resolverConfiguration = new ResolverConfiguration();
  MavenPlugin.getProjectConfigurationManager().enableMavenNature(newProject,
      resolverConfiguration, subMonitor.newChild(20));

  // M2E will cleverly set "target/<artifact ID>-<version>/WEB-INF/classes" as a new Java output
  // folder; delete the default old folder.
  newProject.getFolder("build").delete(true /* force */, subMonitor.newChild(2));
}
 
Example #20
Source File: FlexMavenPackagedProjectStagingDelegate.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
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 #21
Source File: BuildPathTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolvingRule() {
  ISchedulingRule rule = BuildPath.resolvingRule(project);
  assertTrue(rule.contains(MavenPlugin.getProjectConfigurationManager().getRule()));
  assertTrue(rule.isConflicting(MavenPlugin.getProjectConfigurationManager().getRule()));
  assertTrue(rule.contains(project.getProject()));
}
 
Example #22
Source File: ImportMavenSarlProjectWizard.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Create the import job.
 *
 * @param projects the projects to import.
 * @return the import job.
 */
protected WorkspaceJob createImportJob(Collection<MavenProjectInfo> projects) {
	final WorkspaceJob job = new ImportMavenSarlProjectsJob(projects, this.workingSets, this.importConfiguration);
	job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
	return job;
}
 
Example #23
Source File: MavenUtils.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
/** Return the m2e scheduling rule used to serialize access to the Maven repository. */
public static ISchedulingRule mavenResolvingRule() {
  return MavenPlugin.getProjectConfigurationManager().getRule();
}
 
Example #24
Source File: MavenUtils.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
public static ArtifactRepository createRepository(String id, String url) throws CoreException {
  return MavenPlugin.getMaven().createArtifactRepository(id, url);
}
 
Example #25
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 #26
Source File: MavenUtilsTest.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Test
public void testMavenResovingRule() {
  assertEquals(
      MavenPlugin.getProjectConfigurationManager().getRule(), MavenUtils.mavenResolvingRule());
}
 
Example #27
Source File: MavenImportUtils.java    From sarl with Apache License 2.0 4 votes vote down vote up
private static void runBugFix(IProject project, IProgressMonitor monitor) throws Exception {
	final SubMonitor submon = SubMonitor.convert(monitor, 2);
   	restorePom(project, submon);
   	MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(project, monitor);
}
 
Example #28
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 #29
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 #30
Source File: DataflowMavenModel.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
public DataflowMavenModelFactory() {
  this(DataflowDependencyManager.create(), MavenPlugin.getMavenProjectRegistry());
}