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);
}
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);
}
};
}
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);
}
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));
}
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;
}
Aggregations