Search in sources :

Example 6 with IProjectBuilder

use of com.liferay.ide.project.core.IProjectBuilder in project liferay-ide by liferay.

the class BuildWSDDJob method runBuild.

@Override
protected void runBuild(IProgressMonitor monitor) throws CoreException {
    IProjectBuilder builder = getProjectBuilder();
    monitor.worked(50);
    IStatus retval = builder.buildWSDD(monitor);
    if (retval == null) {
        retval = ServiceCore.createErrorStatus(NLS.bind(Msgs.errorRunningBuildWSDD, getProject()));
    }
    if ((retval == null) || !retval.isOK()) {
        throw new CoreException(retval);
    }
    monitor.worked(90);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder)

Example 7 with IProjectBuilder

use of com.liferay.ide.project.core.IProjectBuilder in project liferay-ide by liferay.

the class LiferayDependencyQuickFix method _createDepProposal.

private IJavaCompletionProposal _createDepProposal(IInvocationContext context, ServiceContainer bundle) {
    final String bundleGroup = bundle.getBundleGroup();
    final String bundleName = bundle.getBundleName();
    final String bundleVersion = bundle.getBundleVersion();
    return new CUCorrectionProposal("Add module dependency " + bundleName, context.getCompilationUnit(), null, -0) {

        @Override
        public void apply(IDocument document) {
            try {
                IJavaProject javaProject = context.getCompilationUnit().getJavaProject();
                IProject project = javaProject.getProject();
                ILiferayProject liferayProject = LiferayCore.create(project);
                final IProjectBuilder builder = liferayProject.adapt(IProjectBuilder.class);
                if (builder != null) {
                    Version retriveVersion = new Version(bundleVersion);
                    String[] dependency = { bundleGroup, bundleName, retriveVersion.getMajor() + "." + retriveVersion.getMinor() + ".0" };
                    List<String[]> dependencyList = new ArrayList<>();
                    dependencyList.add(dependency);
                    builder.updateProjectDependency(project, dependencyList);
                }
            } catch (Exception e) {
                ProjectUI.logError("Error adding module dependency", e);
            }
        }

        @Override
        public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
            return "Add module dependency";
        }

        @Override
        public Image getImage() {
            return ProjectUI.getPluginImageRegistry().get(ProjectUI.MODULE_DEPENDENCY_IAMGE_ID);
        }
    };
}
Also used : ArrayList(java.util.ArrayList) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CUCorrectionProposal(org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal) IJavaProject(org.eclipse.jdt.core.IJavaProject) Version(org.osgi.framework.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) IDocument(org.eclipse.jface.text.IDocument)

Example 8 with IProjectBuilder

use of com.liferay.ide.project.core.IProjectBuilder in project liferay-ide by liferay.

the class BuildLanguageJob method runBuildLang.

protected void runBuildLang(IProgressMonitor monitor) throws CoreException {
    ILiferayProject liferayProject = LiferayCore.create(_getProject());
    if (liferayProject == null) {
        throw new CoreException(PortletCore.createErrorStatus(NLS.bind(Msgs.couldNotCreateLiferayProject, _getProject())));
    }
    IProjectBuilder builder = liferayProject.adapt(IProjectBuilder.class);
    if (builder == null) {
        throw new CoreException(PortletCore.createErrorStatus(NLS.bind(Msgs.couldNotCreateProjectBuilder, _getProject())));
    }
    monitor.worked(50);
    IStatus retval = builder.buildLang(langFile, monitor);
    if (retval == null) {
        retval = PortletCore.createErrorStatus(NLS.bind(Msgs.errorRunningBuildLang, _getProject()));
    }
    try {
        _getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
    } catch (Exception e) {
        PortletCore.logError(e);
    }
    _getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
    try {
        _getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
    } catch (Exception e) {
        PortletCore.logError(e);
    }
    if ((retval == null) || !retval.isOK()) {
        throw new CoreException(retval);
    }
    monitor.worked(90);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ILiferayProject(com.liferay.ide.core.ILiferayProject) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) CoreException(org.eclipse.core.runtime.CoreException)

Example 9 with IProjectBuilder

use of com.liferay.ide.project.core.IProjectBuilder in project liferay-ide by liferay.

the class GradleProjectTests method testAddGradleDependency.

@Test
public void testAddGradleDependency() throws Exception {
    LiferayGradleProject gradleProject = Util.fullImportGradleProject("projects/GradleDependencyTestProject");
    String[][] gradleDependencies = new String[][] { { "com.liferay.portal", "com.liferay.portal.kernel", "2.6.0" } };
    GradleDependency gd = new GradleDependency(gradleDependencies[0][0], gradleDependencies[0][1], gradleDependencies[0][2]);
    assertNotNull(gradleProject);
    IProject project = gradleProject.getProject();
    IFile gradileFile = project.getFile("build.gradle");
    GradleDependencyUpdater updater = new GradleDependencyUpdater(gradileFile.getLocation().toFile());
    List<GradleDependency> existDependencies = updater.getAllDependencies();
    assertFalse(existDependencies.contains(gd));
    IProjectBuilder gradleProjectBuilder = gradleProject.adapt(IProjectBuilder.class);
    gradleProjectBuilder.updateProjectDependency(project, Arrays.asList(gradleDependencies));
    GradleDependencyUpdater dependencyUpdater = new GradleDependencyUpdater(gradileFile.getLocation().toFile());
    List<GradleDependency> updatedDependencies = dependencyUpdater.getAllDependencies();
    assertTrue(updatedDependencies.contains(gd));
}
Also used : LiferayGradleProject(com.liferay.ide.gradle.core.LiferayGradleProject) IFile(org.eclipse.core.resources.IFile) GradleDependencyUpdater(com.liferay.ide.gradle.core.parser.GradleDependencyUpdater) GradleDependency(com.liferay.ide.gradle.core.parser.GradleDependency) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 10 with IProjectBuilder

use of com.liferay.ide.project.core.IProjectBuilder 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)

Aggregations

IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)11 CoreException (org.eclipse.core.runtime.CoreException)5 ILiferayProject (com.liferay.ide.core.ILiferayProject)4 IProject (org.eclipse.core.resources.IProject)4 IStatus (org.eclipse.core.runtime.IStatus)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)3 Test (org.junit.Test)3 IRemoteServerPublisher (com.liferay.ide.server.remote.IRemoteServerPublisher)2 IFile (org.eclipse.core.resources.IFile)2 IBundleProject (com.liferay.ide.core.IBundleProject)1 LiferayGradleProject (com.liferay.ide.gradle.core.LiferayGradleProject)1 GradleDependency (com.liferay.ide.gradle.core.parser.GradleDependency)1 GradleDependencyUpdater (com.liferay.ide.gradle.core.parser.GradleDependencyUpdater)1 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)1 File (java.io.File)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Dependency (org.apache.maven.model.Dependency)1 MavenProject (org.apache.maven.project.MavenProject)1