Search in sources :

Example 11 with GradleDependencyUpdater

use of com.liferay.ide.gradle.core.parser.GradleDependencyUpdater 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)

Aggregations

GradleDependencyUpdater (com.liferay.ide.gradle.core.parser.GradleDependencyUpdater)11 File (java.io.File)9 Test (org.junit.Test)9 GradleDependency (com.liferay.ide.gradle.core.parser.GradleDependency)6 FindDependenciesVisitor (com.liferay.ide.gradle.core.parser.FindDependenciesVisitor)5 IOException (java.io.IOException)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 LiferayGradleProject (com.liferay.ide.gradle.core.LiferayGradleProject)1 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IResource (org.eclipse.core.resources.IResource)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 CUCorrectionProposal (org.eclipse.jdt.ui.text.java.correction.CUCorrectionProposal)1 IDocument (org.eclipse.jface.text.IDocument)1 Image (org.eclipse.swt.graphics.Image)1 Display (org.eclipse.swt.widgets.Display)1 Bundle (org.osgi.framework.Bundle)1