use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class MavenProjectBuilder method refreshSiblingProject.
public void refreshSiblingProject(IMavenProjectFacade projectFacade, IProgressMonitor monitor) throws CoreException {
try {
Plugin plugin6x = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
if (plugin6x != null) {
Xpp3Dom config = (Xpp3Dom) plugin6x.getConfiguration();
Xpp3Dom apiBaseDir = config.getChild(ILiferayMavenConstants.PLUGIN_CONFIG_API_BASE_DIR);
String apiBaseDirValue = apiBaseDir.getValue();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile apiBasePomFile = workspace.getRoot().getFileForLocation(new Path(apiBaseDirValue).append(IMavenConstants.POM_FILE_NAME));
IMavenProjectFacade apiBaseFacade = this.projectManager.create(apiBasePomFile, true, monitor);
apiBaseFacade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
} else {
Plugin plugin7x = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.SERVICE_BUILDER_PLUGIN_KEY, monitor);
if (plugin7x != null) {
Xpp3Dom config = (Xpp3Dom) plugin7x.getConfiguration();
Xpp3Dom apiDirName = config.getChild("apiDirName");
String apiDirNameValue = apiDirName.getValue();
int startIndex = apiDirNameValue.indexOf("../");
int endIndex = apiDirNameValue.indexOf("/src/main/java");
String projectName = apiDirNameValue.substring(startIndex + 3, endIndex);
IProject project = CoreUtil.getProject(projectName);
if (project != null) {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}
}
} catch (Exception e) {
LiferayMavenCore.logError("Could not refresh sibling service project.", e);
}
}
use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class MavenProjectRemoteServerPublisher method _runMavenGoal.
private boolean _runMavenGoal(IProject project, IProgressMonitor monitor) throws CoreException {
boolean retval = false;
IMavenProjectFacade facade = MavenUtil.getProjectFacade(project, monitor);
String pluginType = MavenUtil.getLiferayMavenPluginType(facade.getMavenProject(monitor));
if (pluginType == null) {
pluginType = ILiferayMavenConstants.DEFAULT_PLUGIN_TYPE;
}
MavenProject parentProject = facade.getMavenProject(monitor).getParent();
String goal = _getMavenDeployGoals();
if (_isServiceBuilderProject(project, pluginType, parentProject)) {
retval = _execMavenLaunch(ProjectUtil.getProject(parentProject.getName()), " package -am -pl " + project.getName(), MavenUtil.getProjectFacade(project, monitor), monitor);
} else {
retval = _execMavenLaunch(project, goal, facade, monitor);
}
return retval;
}
use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class FacetedMavenBundleProject method getOutputBundlePath.
@Override
public IPath getOutputBundlePath() {
IPath outputJar = null;
try {
IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(getProject(), null);
MavenProject mavenProject = projectFacade.getMavenProject(null);
String targetName = mavenProject.getBuild().getFinalName() + "." + getBundleShape();
IFolder targetFolder = getProject().getFolder("target");
if (FileUtil.exists(targetFolder)) {
IPath targetFile = targetFolder.getRawLocation().append(targetName);
if (FileUtil.exists(targetFile)) {
outputJar = targetFile;
}
}
} catch (Exception e) {
LiferayMavenCore.logError(e);
}
return outputJar;
}
use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class FacetedMavenBundleProject method getOutputBundle.
@Override
public IPath getOutputBundle(boolean cleanBuild, IProgressMonitor monitor) throws CoreException {
IPath outputJar = null;
MavenProjectBuilder mavenProjectBuilder = new MavenProjectBuilder(getProject());
List<String> goals = new ArrayList<>();
if (cleanBuild) {
goals.add("clean");
}
goals.add("package");
for (String goal : goals) {
mavenProjectBuilder.runMavenGoal(getProject(), goal, monitor);
}
// we are going to try to get the output jar even if the package failed.
IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(getProject(), monitor);
MavenProject mavenProject = projectFacade.getMavenProject(monitor);
String targetName = mavenProject.getBuild().getFinalName() + "." + getBundleShape();
IFolder targetFolder = getProject().getFolder("target");
if (FileUtil.exists(targetFolder)) {
// targetFolder.refreshLocal( IResource.DEPTH_ONE, monitor );
IPath targetFile = targetFolder.getRawLocation().append(targetName);
if (FileUtil.exists(targetFile)) {
outputJar = targetFile;
}
}
if (FileUtil.notExists(outputJar)) {
throw new CoreException(LiferayMavenCore.createErrorStatus("Unable to get output bundle for project " + getProject().getName()));
}
return outputJar;
}
use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.
the class FacetedMavenProject method adapt.
@Override
public <T> T adapt(Class<T> adapterType) {
T adapter = super.adapt(adapterType);
if (adapter != null) {
return adapter;
}
IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), new NullProgressMonitor());
if (facade != null) {
if (ILiferayPortal.class.equals(adapterType)) {
ILiferayPortal portal = new LiferayPortalMaven(this);
return adapterType.cast(portal);
}
}
return null;
}
Aggregations