use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class MavenGoalAction method _runMavenGoal.
private void _runMavenGoal(IFile pomFile, String goal, IProgressMonitor monitor) throws CoreException {
IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
IMavenProjectFacade projectFacade = projectManager.create(pomFile, false, new NullProgressMonitor());
MavenUIProjectBuilder builder = new MavenUIProjectBuilder(pomFile.getProject());
builder.runMavenGoal(projectFacade, goal, "run", monitor);
}
use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class LiferayPortalMaven method getAppServerPortalDir.
@Override
public IPath getAppServerPortalDir() {
IPath retval = null;
IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(this._lrMvnProject.getProject());
if (projectFacade != null) {
try {
MavenProject mavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
String appServerPortalDir = MavenUtil.getLiferayMavenPluginConfig(mavenProject, ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_PORTAL_DIR);
if (!CoreUtil.isNullOrEmpty(appServerPortalDir)) {
retval = new Path(appServerPortalDir);
}
} catch (CoreException ce) {
}
}
return retval;
}
use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class MavenBundlePluginProject method getOutputBundle.
@Override
public IPath getOutputBundle(boolean cleanBuild, IProgressMonitor monitor) throws CoreException {
IPath outputJar = null;
IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(getProject(), monitor);
MavenProjectBuilder mavenProjectBuilder = new MavenProjectBuilder(getProject());
// IDE-3009 delete the MANIFEST.MF to ensure that it will be regenerated by
// bnd-process
IFile manifest = getProject().getFile("target/classes/META-INF/MANIFEST.MF");
if (FileUtil.exists(manifest)) {
manifest.delete(true, monitor);
}
if (cleanBuild || !_isAutoBuild()) {
getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor);
} else {
getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
}
mavenProjectBuilder.execJarMojo(projectFacade, monitor);
MavenProject mavenProject = projectFacade.getMavenProject(monitor);
String targetName = mavenProject.getBuild().getFinalName() + "." + getBundleShape();
String buildDirectory = mavenProject.getBuild().getDirectory();
File baseDirectory = mavenProject.getBasedir();
IPath buildDirPath = new Path(buildDirectory);
IPath baseDirPath = new Path(baseDirectory.toString());
IPath relativePath = buildDirPath.makeRelativeTo(baseDirPath);
IFolder targetFolder = _getTargetFolder(getProject(), relativePath);
if (FileUtil.exists(targetFolder)) {
// targetFolder.refreshLocal( IResource.DEPTH_ONE, monitor );
IPath targetFile = targetFolder.getRawLocation().append(targetName);
if (FileUtil.exists(targetFile)) {
outputJar = targetFile;
}
}
return outputJar;
}
use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class MavenProjectBuilder method buildSB.
public IStatus buildSB(IFile serviceXmlFile, String goal, IProgressMonitor monitor) throws CoreException {
IProject serviceProject = serviceXmlFile.getProject();
IMavenProjectFacade facade = MavenUtil.getProjectFacade(serviceProject, monitor);
monitor.worked(10);
IStatus retval = null;
if (runMavenGoal(serviceProject, goal, monitor)) {
retval = Status.OK_STATUS;
} else {
retval = LiferayMavenCore.createErrorStatus("run build-service error");
}
refreshSiblingProject(facade, monitor);
serviceProject.refreshLocal(IResource.DEPTH_INFINITE, monitor);
monitor.worked(10);
monitor.done();
return retval;
}
use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class MavenProjectBuilder method initBundle.
public IStatus initBundle(IProject project, String bundleUrl, IProgressMonitor monitor) throws CoreException {
if (bundleUrl != null) {
File pomFile = FileUtil.getFile(project.getFile("pom.xml"));
MavenXpp3Reader mavenReader = new MavenXpp3Reader();
MavenXpp3Writer mavenWriter = new MavenXpp3Writer();
try (FileReader reader = new FileReader(pomFile)) {
Model model = mavenReader.read(reader);
if (model != null) {
Build build = model.getBuild();
Plugin plugin = build.getPluginsAsMap().get("com.liferay:com.liferay.portal.tools.bundle.support");
if (plugin != null) {
try (FileWriter fileWriter = new FileWriter(pomFile)) {
Xpp3Dom origin = (Xpp3Dom) plugin.getConfiguration();
Xpp3Dom newConfiguration = new Xpp3Dom("configuration");
Xpp3Dom url = new Xpp3Dom("url");
url.setValue(bundleUrl);
newConfiguration.addChild(url);
plugin.setConfiguration(Xpp3Dom.mergeXpp3Dom(newConfiguration, origin));
mavenWriter.write(fileWriter, model);
}
}
}
} catch (Exception e) {
LiferayMavenCore.logError("Could not write file in" + pomFile, e);
}
}
IMavenProjectFacade facade = MavenUtil.getProjectFacade(project, monitor);
if (_execMavenLaunch(project, MavenGoalUtil.getMavenInitBundleGoal(project), facade, monitor)) {
return Status.OK_STATUS;
}
return LiferayMavenCore.createErrorStatus("run init-bundle error");
}
Aggregations