Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2e-dev] How to convert an instance of Project to MavenProject?

I am programming an Eclipse Plug-In. A NewWizard should became a part of it. Its purpose is to simplify the creation of a maven project with predefined parameters. I managed to handle this job so far using the parts of m2e.core.ui to not reinvent the wheel, this snippet shows how the project is created:

final Job job = new AbstactCreateMavenProjectJob("Creating project" + projectName, workingSets)
{
    @Override
    protected List<IProject> doCreateMavenProjects(IProgressMonitor monitor) throws CoreException
    {
        List<IProject> projects = MavenPlugin.getProjectConfigurationManager()
                                             .createArchetypeProjects(location, archetype,  groupId,
                                                                      artifactId, version, javaPackage,
                                                                      properties, importConfiguration, monitor);

        return projects;
    }
};

However I've got some additional requirements. I need to modify two parameters of the created project. It should look kinda like that:

IMavenProjectFacade mPFacade = MavenPlugin.getMavenProjectRegistry().getProject(projects.get(0));
mPFacade.getMavenProject().setVersion(null);
mPFacade.getMavenProject().getParentArtifact().setVersion("2.3.0-SNAPSHOT");

But MavenPlugin.getMavenProjectRegistry().getProjects(); returns an empty array, so getProject() returns null. How to do the conversion and set the parameters properly?


Back to the top