Search in sources :

Example 1 with IProjectBuilder

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

the class MavenModuleProjectTests method testProjectTemplateServiceBuilder.

@Test
public void testProjectTemplateServiceBuilder() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("service-builder-test");
    op.setProjectProvider("maven-module");
    op.setProjectTemplateName("service-builder");
    op.setPackageName("com.liferay.test");
    IProject parent = create(op);
    assertTrue(parent != null && parent.exists());
    IProject api = CoreUtil.getProject("service-builder-test-api");
    assertTrue(api != null && api.exists());
    IProject service = CoreUtil.getProject("service-builder-test-service");
    assertTrue(service != null && service.exists());
    IProjectBuilder builder = LiferayCore.create(IProjectBuilder.class, service);
    builder.buildService(monitor);
    api.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
    service.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
    IBundleProject apiBundle = LiferayCore.create(IBundleProject.class, api);
    assertNotNull(apiBundle);
    IPath apiOutput = apiBundle.getOutputBundle(true, monitor);
    assertNotNull(apiOutput);
    assertTrue(apiOutput.toFile().exists());
    assertEquals("service-builder-test-api-1.0.0.jar", apiOutput.lastSegment());
    IBundleProject serviceBundle = LiferayCore.create(IBundleProject.class, service);
    IPath serviceOutput = serviceBundle.getOutputBundle(true, monitor);
    assertNotNull(serviceOutput);
    assertTrue(serviceOutput.toFile().exists());
    assertEquals("service-builder-test-service-1.0.0.jar", serviceOutput.lastSegment());
}
Also used : IBundleProject(com.liferay.ide.core.IBundleProject) IPath(org.eclipse.core.runtime.IPath) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 2 with IProjectBuilder

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

the class MavenModuleProjectTests method testMavenDependencyUpdate.

@Test
public void testMavenDependencyUpdate() throws Exception {
    String[][] dependency = new String[][] { { "com.liferay.portal", "com.liferay.portal.kernel", "2.6.0" } };
    Dependency mavenDependency = new Dependency();
    mavenDependency.setGroupId(dependency[0][0]);
    mavenDependency.setArtifactId(dependency[0][1]);
    mavenDependency.setVersion(dependency[0][2]);
    final URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/MavenDependencyTestProject.zip");
    final File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
    File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
    ZipUtil.unzip(wsZipFile, eclipseWorkspaceLocation);
    File mavenDependencyTestProjectFolder = new File(eclipseWorkspaceLocation, "MavenDependencyTestProject");
    MavenUtil.importProject(mavenDependencyTestProjectFolder.getAbsolutePath(), monitor);
    waitForJobsToComplete(monitor);
    IProject mavenDependencyTestProject = CoreUtil.getProject("MavenDependencyTestProject");
    assertNotNull(mavenDependencyTestProject);
    assertTrue(mavenDependencyTestProject.exists());
    IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(mavenDependencyTestProject, new NullProgressMonitor());
    assertNotNull(projectFacade);
    MavenProject mavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
    List<Dependency> existedDependencies = mavenProject.getDependencies();
    assertFalse(checkDependency(existedDependencies, mavenDependency));
    ILiferayProject liferayMavenDependencyProject = LiferayCore.create(mavenDependencyTestProject);
    IProjectBuilder projectBuilder = liferayMavenDependencyProject.adapt(IProjectBuilder.class);
    projectBuilder.updateProjectDependency(mavenDependencyTestProject, Arrays.asList(dependency));
    waitForJobsToComplete(monitor);
    MavenProject updateMavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
    List<Dependency> updateDependencies = updateMavenProject.getDependencies();
    assertTrue(checkDependency(updateDependencies, mavenDependency));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) ILiferayProject(com.liferay.ide.core.ILiferayProject) Dependency(org.apache.maven.model.Dependency) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 3 with IProjectBuilder

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

the class AbstractLiferayComponentTemplate method doMergeDependencyOperation.

protected void doMergeDependencyOperation() throws CoreException {
    IProjectBuilder builder = liferayProject.adapt(IProjectBuilder.class);
    builder.updateProjectDependency(project, getComponentDependency());
}
Also used : IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder)

Example 4 with IProjectBuilder

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

the class BuildServiceJob method runBuild.

protected void runBuild(IProgressMonitor monitor) throws CoreException {
    IProjectBuilder builder = getProjectBuilder();
    monitor.worked(50);
    IStatus retval = builder.buildService(monitor);
    if (retval == null) {
        retval = ServiceCore.createErrorStatus(NLS.bind(Msgs.errorRunningBuildService, 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 5 with IProjectBuilder

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

the class BuildServiceJob method getProjectBuilder.

protected IProjectBuilder getProjectBuilder() throws CoreException {
    ILiferayProject liferayProject = LiferayCore.create(getProject());
    if (liferayProject == null) {
        throw new CoreException(ServiceCore.createErrorStatus(NLS.bind(Msgs.couldNotCreateLiferayProject, getProject())));
    }
    IProjectBuilder builder = liferayProject.adapt(IProjectBuilder.class);
    if (builder == null) {
        throw new CoreException(ServiceCore.createErrorStatus(NLS.bind(Msgs.couldNotCreateProjectBuilder, getProject())));
    }
    return builder;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILiferayProject(com.liferay.ide.core.ILiferayProject) 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