Search in sources :

Example 31 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.

the class ThemePluginBuildParticipant method build.

@Override
public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception {
    IMavenProjectFacade facade = getMavenProjectFacade();
    if (!shouldBuild(kind, facade)) {
        return null;
    }
    ICallable<IStatus> callable = new ICallable<IStatus>() {

        public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
            return executeThemeMojo(facade, context, monitor);
        }
    };
    IStatus retval = null;
    try {
        retval = executeMaven(facade, callable, monitor);
    } catch (Exception e) {
        retval = LiferayMavenCore.createErrorStatus(getGoal() + " build error", e);
    }
    if ((retval != null) && !retval.isOK()) {
        LiferayMavenCore.log(retval);
    }
    try {
        facade.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
    } catch (CoreException ce) {
    }
    monitor.worked(10);
    return null;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IMavenExecutionContext(org.eclipse.m2e.core.embedder.IMavenExecutionContext) ICallable(org.eclipse.m2e.core.embedder.ICallable) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) CoreException(org.eclipse.core.runtime.CoreException)

Example 32 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.

the class LiferayMavenProject 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 (IProjectBuilder.class.equals(adapterType)) {
            IProjectBuilder projectBuilder = new MavenProjectBuilder(getProject());
            return adapterType.cast(projectBuilder);
        } else if (IRemoteServerPublisher.class.equals(adapterType)) {
            IRemoteServerPublisher remoteServerPublisher = new MavenProjectRemoteServerPublisher(getProject());
            return adapterType.cast(remoteServerPublisher);
        }
    }
    return null;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IRemoteServerPublisher(com.liferay.ide.server.remote.IRemoteServerPublisher) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder)

Example 33 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.

the class LiferayMavenProject method getLiferayMavenPluginVersion.

public String getLiferayMavenPluginVersion() {
    String retval = null;
    IMavenProjectFacade projectFacade = MavenPlugin.getMavenProjectRegistry().getProject(getProject());
    if (projectFacade != null) {
        try {
            NullProgressMonitor npm = new NullProgressMonitor();
            MavenProject mavenProject = projectFacade.getMavenProject(npm);
            if (mavenProject != null) {
                Plugin liferayMavenPlugin = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, npm);
                retval = liferayMavenPlugin.getVersion();
            }
        } catch (CoreException ce) {
        }
    }
    return retval;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) CoreException(org.eclipse.core.runtime.CoreException) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) Plugin(org.apache.maven.model.Plugin) MavenPlugin(org.eclipse.m2e.core.MavenPlugin) MavenJdtPlugin(org.eclipse.m2e.jdt.MavenJdtPlugin)

Example 34 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.

the class LiferayPortalMaven method getVersion.

@Override
public String getVersion() {
    String retval = null;
    IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(this._lrMvnProject.getProject());
    if (projectFacade != null) {
        try {
            MavenProject mavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
            String liferayVersion = MavenUtil.getLiferayMavenPluginConfig(mavenProject, ILiferayMavenConstants.PLUGIN_CONFIG_LIFERAY_VERSION);
            if (liferayVersion == null) {
                liferayVersion = mavenProject.getProperties().getProperty("liferay.version");
                if (liferayVersion == null) {
                    // look through dependencies for portal-service
                    List<Dependency> deps = mavenProject.getDependencies();
                    if (deps != null) {
                        for (Dependency dep : deps) {
                            if (dep.getArtifactId().startsWith("portal-") && dep.getGroupId().startsWith("com.liferay")) {
                                liferayVersion = dep.getVersion();
                                break;
                            }
                        }
                    }
                }
            }
            if (liferayVersion != null) {
                retval = MavenUtil.getVersion(liferayVersion);
            }
        } catch (CoreException ce) {
        }
    }
    return retval;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) CoreException(org.eclipse.core.runtime.CoreException) Dependency(org.apache.maven.model.Dependency) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

Example 35 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade in project liferay-ide by liferay.

the class MavenBundlePluginProject 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)

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