Search in sources :

Example 6 with IMavenProjectFacade

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

Example 7 with IMavenProjectFacade

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

Example 8 with IMavenProjectFacade

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

Example 9 with IMavenProjectFacade

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProject(org.eclipse.core.resources.IProject)

Example 10 with IMavenProjectFacade

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");
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Build(org.apache.maven.model.Build) FileWriter(java.io.FileWriter) Model(org.apache.maven.model.Model) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) FileReader(java.io.FileReader) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IFile(org.eclipse.core.resources.IFile) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException) MavenXpp3Writer(org.apache.maven.model.io.xpp3.MavenXpp3Writer) DebugPlugin(org.eclipse.debug.core.DebugPlugin) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Plugin(org.apache.maven.model.Plugin) MavenPlugin(org.eclipse.m2e.core.MavenPlugin)

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