Search in sources :

Example 41 with IMavenProjectFacade

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);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) IFile(org.eclipse.core.resources.IFile) IWorkspace(org.eclipse.core.resources.IWorkspace) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) DebugPlugin(org.eclipse.debug.core.DebugPlugin) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Plugin(org.apache.maven.model.Plugin) MavenPlugin(org.eclipse.m2e.core.MavenPlugin)

Example 42 with IMavenProjectFacade

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;
}
Also used : MavenProject(org.apache.maven.project.MavenProject) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

Example 43 with IMavenProjectFacade

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) MavenProject(org.apache.maven.project.MavenProject) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) CoreException(org.eclipse.core.runtime.CoreException) IFolder(org.eclipse.core.resources.IFolder)

Example 44 with IMavenProjectFacade

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) MavenProject(org.apache.maven.project.MavenProject) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IFolder(org.eclipse.core.resources.IFolder)

Example 45 with IMavenProjectFacade

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;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Aggregations

IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)54 MavenProject (org.apache.maven.project.MavenProject)21 IProject (org.eclipse.core.resources.IProject)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)19 CoreException (org.eclipse.core.runtime.CoreException)18 IPath (org.eclipse.core.runtime.IPath)16 IFile (org.eclipse.core.resources.IFile)13 File (java.io.File)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 Path (org.eclipse.core.runtime.Path)10 IStatus (org.eclipse.core.runtime.IStatus)9 Test (org.junit.Test)9 MavenPlugin (org.eclipse.m2e.core.MavenPlugin)6 Plugin (org.apache.maven.model.Plugin)5 IFolder (org.eclipse.core.resources.IFolder)5 ICallable (org.eclipse.m2e.core.embedder.ICallable)5 IMavenExecutionContext (org.eclipse.m2e.core.embedder.IMavenExecutionContext)5 FacetedMavenProject (com.liferay.ide.maven.core.FacetedMavenProject)4 ArrayList (java.util.ArrayList)4 IMavenProjectRegistry (org.eclipse.m2e.core.project.IMavenProjectRegistry)4