Search in sources :

Example 36 with IMavenProjectFacade

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

the class MavenBundlePluginProject 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);
        } else if (IBundleProject.class.equals(adapterType)) {
            return adapterType.cast(this);
        }
    }
    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 37 with IMavenProjectFacade

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

the class MavenBundlePluginProject method getSymbolicName.

@Override
public String getSymbolicName() throws CoreException {
    String bsn = ProjectUtil.getBundleSymbolicNameFromBND(getProject());
    if (!CoreUtil.empty(bsn)) {
        return bsn;
    }
    String retval = null;
    IProgressMonitor monitor = new NullProgressMonitor();
    IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(getProject(), monitor);
    MavenProject mavenProject = projectFacade.getMavenProject(monitor);
    Artifact artifact = mavenProject.getArtifact();
    File file = artifact.getFile();
    if (FileUtil.exists(file) && !file.getName().equals("classes")) {
        retval = new DefaultMaven2OsgiConverter().getBundleSymbolicName(artifact);
    } else {
        IProject project = getProject();
        // fallback to project name
        retval = project.getLocation().lastSegment();
    }
    return retval;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) DefaultMaven2OsgiConverter(com.liferay.ide.maven.core.util.DefaultMaven2OsgiConverter) File(java.io.File) IFile(org.eclipse.core.resources.IFile) Artifact(org.apache.maven.artifact.Artifact) IProject(org.eclipse.core.resources.IProject)

Example 38 with IMavenProjectFacade

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

the class MavenProjectBuilder method preBuildService.

public IFile preBuildService(IProgressMonitor monitor) throws CoreException {
    IProject project = getProject();
    IFile retval = getDocrootFile("WEB-INF/" + ILiferayConstants.SERVICE_XML_FILE);
    if (retval == null) {
        IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(project);
        if (projectFacade != null) {
            IProject portletProject = getPortletProject(projectFacade, monitor);
            if (portletProject != null) {
                retval = new MavenProjectBuilder(portletProject).getDocrootFile("WEB-INF/" + ILiferayConstants.SERVICE_XML_FILE);
            }
        }
    }
    if (retval == null) {
        retval = project.getFile("service.xml");
    }
    return retval;
}
Also used : IFile(org.eclipse.core.resources.IFile) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProject(org.eclipse.core.resources.IProject)

Example 39 with IMavenProjectFacade

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

the class MavenProjectBuilder method execGoals.

public IStatus execGoals(List<String> goals, IProgressMonitor monitor) throws CoreException {
    IStatus retval = null;
    IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), monitor);
    ICallable<IStatus> callable = new ICallable<IStatus>() {

        public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
            IStatus execStatus = MavenUtil.executeGoals(facade, context, goals, monitor);
            MavenSession session = context.getSession();
            List<Throwable> exceptions = session.getResult().getExceptions();
            MultiStatusBuilder multiStatusBuilder = LiferayMavenCore.newMultiStatus();
            multiStatusBuilder.add(execStatus);
            multiStatusBuilder.addAll(exceptions);
            return multiStatusBuilder.retval();
        }
    };
    retval = executeMaven(facade, callable, monitor);
    return retval;
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MultiStatusBuilder(com.liferay.ide.core.util.MultiStatusBuilder) IMavenExecutionContext(org.eclipse.m2e.core.embedder.IMavenExecutionContext) ICallable(org.eclipse.m2e.core.embedder.ICallable) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

Example 40 with IMavenProjectFacade

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

the class MavenProjectBuilder method buildLang.

public IStatus buildLang(IFile langFile, IProgressMonitor monitor) throws CoreException {
    IProgressMonitor sub = SubMonitor.convert(monitor, 100);
    sub.beginTask(Msgs.buildingLanguages, 100);
    IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), sub);
    sub.worked(10);
    ICallable<IStatus> callable = new ICallable<IStatus>() {

        public IStatus call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
            return MavenUtil.executeMojoGoal(facade, context, ILiferayMavenConstants.PLUGIN_GOAL_BUILD_LANG, monitor);
        }
    };
    IStatus retval = executeMaven(facade, callable, sub);
    sub.worked(80);
    getProject().refreshLocal(IResource.DEPTH_INFINITE, sub);
    sub.worked(10);
    sub.done();
    return retval;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IMavenExecutionContext(org.eclipse.m2e.core.embedder.IMavenExecutionContext) ICallable(org.eclipse.m2e.core.embedder.ICallable) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

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