|
|
Re: How to enable maven dependencies programmatically [message #13708 is a reply to message #13666] |
Fri, 01 August 2008 19:21 |
Eclipse User |
|
|
|
Originally posted by: igor.ifedorenko.com
Have a look at
org.maven.ide.eclipse.project.IProjectConfigurationManager#e nableMavenNature
The most basic way to use it is
IProjectConfigurationManager configurationManager =
MavenPlugin.getDefault().getProjectConfigurationManager();
ResolverConfiguration configuration = new ResolverConfiguration();
configurationManager.enableMavenNature(project, configuration, monitor);
chingyichan wrote:
> Hello,
>
> I create a plugin to create the java project which contains the pom.xml
> file. User can make choice to enable maven dependencies.
> How do I do to make it in programmatic way ?
>
|
|
|
Re: How to enable maven dependencies programmatically [message #13749 is a reply to message #13708] |
Sat, 02 August 2008 03:27 |
Eclipse User |
|
|
|
Originally posted by: chingyichan.tw.gmail.com
Igor Fedorenko 提到:
> Have a look at
>
> org.maven.ide.eclipse.project.IProjectConfigurationManager#e nableMavenNature
>
>
> The most basic way to use it is
>
> IProjectConfigurationManager configurationManager =
> MavenPlugin.getDefault().getProjectConfigurationManager();
> ResolverConfiguration configuration = new ResolverConfiguration();
> configurationManager.enableMavenNature(project, configuration, monitor);
>
> chingyichan wrote:
>> Hello,
>>
>> I create a plugin to create the java project which contains the
>> pom.xml file. User can make choice to enable maven dependencies.
>> How do I do to make it in programmatic way ?
>>
Thanks a lot. It work well !
I check out the source code, and extract some codes to make a method:
/**
* enable project maven dependency management
* @param project the project must has pom.xml
* @throws CoreException
*/
private void enableMavenDependencyManagement(IProject project)
throws CoreException {
ResolverConfiguration configuration = new ResolverConfiguration();
configuration.setIncludeModules(false);
configuration.setResolveWorkspaceProjects(true);
configuration.setActiveProfiles("");
boolean hasMavenNature = project.hasNature(IMavenConstants.NATURE_ID);
IProjectConfigurationManager configurationManager = MavenPlugin
.getDefault().getProjectConfigurationManager();
configurationManager.enableMavenNature(project, configuration,
UIUtilz.NULL_PROGRESS_MONITOR);
if (!hasMavenNature) {
configurationManager.updateProjectConfiguration(project,
configuration, MavenPlugin.getDefault()
.getMavenRuntimeManager().getGoalOnUpdate(),
new NullProgressMonitor());
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03152 seconds