use of org.eclipse.m2e.core.internal.MavenPluginActivator in project liferay-ide by liferay.
the class NewMavenJSFModuleProjectProvider method createArchetypeProject.
protected IPath createArchetypeProject(NewLiferayJSFModuleProjectOp op, IProgressMonitor monitor) throws CoreException {
IPath projectLocation = null;
String javaPackage = "com.example";
String projectName = op.getProjectName().content();
IPath location = PathBridge.create(op.getLocation().content());
if (location.lastSegment().equals(projectName)) {
// use parent dir since maven archetype will generate new dir under this
// location
location = location.removeLastSegments(1);
}
String groupId = op.getProjectName().content();
String artifactId = op.getProjectName().content();
String version = "1.0.0";
String archetypeArtifactId = op.getArchetype().content();
Archetype archetype = new Archetype();
String[] gav = archetypeArtifactId.split(":");
String archetypeVersion = gav[gav.length - 1];
archetype.setGroupId(gav[0]);
archetype.setArtifactId(gav[1]);
archetype.setVersion(archetypeVersion);
Artifact artifact = AetherUtil.getLatestAvailableArtifact(archetypeArtifactId);
Properties properties = new Properties();
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
if (location == null) {
location = workspaceRoot.getLocation();
}
try {
MavenPluginActivator pluginActivator = MavenPluginActivator.getDefault();
ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
request.setTransferListener(pluginActivator.getMaven().createTransferListener(monitor));
request.setArchetypeGroupId(artifact.getGroupId());
request.setArchetypeArtifactId(artifact.getArtifactId());
request.setArchetypeVersion(artifact.getVersion());
request.setArchetypeRepository(AetherUtil.newCentralRepository().getUrl());
request.setGroupId(groupId);
request.setArtifactId(artifactId);
request.setVersion(version);
request.setPackage(javaPackage);
// the model does not have a package field
request.setLocalRepository(pluginActivator.getMaven().getLocalRepository());
request.setRemoteArtifactRepositories(pluginActivator.getMaven().getArtifactRepositories(true));
request.setProperties(properties);
request.setOutputDirectory(location.toPortableString());
ArchetypeGenerationResult result = _getArchetyper().generateProjectFromArchetype(request);
Exception cause = result.getCause();
if (cause != null) {
throw new CoreException(LiferayCore.createErrorStatus("Unable to create project from archetype."));
}
projectLocation = location.append(artifactId);
if (FileUtil.notExists(projectLocation)) {
throw new CoreException(LiferayCore.createErrorStatus("Can't create gradle JSF project. "));
}
} catch (Exception e) {
throw new CoreException(LiferayCore.createErrorStatus("Failed to create JSF project. ", e));
}
return projectLocation;
}
use of org.eclipse.m2e.core.internal.MavenPluginActivator in project jbosstools-openshift by jbosstools.
the class MavenProjectImportOperation method importToWorkspace.
public List<IProject> importToWorkspace(IProgressMonitor monitor) throws CoreException, InterruptedException {
MavenPluginActivator mavenPlugin = MavenPluginActivator.getDefault();
IProjectConfigurationManager configurationManager = mavenPlugin.getProjectConfigurationManager();
MavenModelManager modelManager = mavenPlugin.getMavenModelManager();
Set<MavenProjectInfo> projectInfos = getMavenProjects(getProjectDirectory(), filters, modelManager, monitor);
ProjectImportConfiguration projectImportConfiguration = new ProjectImportConfiguration();
if (overwriteMavenProjects(projectInfos, projectImportConfiguration, monitor)) {
List<IMavenProjectImportResult> importResults = configurationManager.importProjects(projectInfos, projectImportConfiguration, monitor);
return validate(toProjects(importResults));
} else {
return Collections.emptyList();
}
}
Aggregations