use of com.liferay.ide.gradle.core.LiferayGradleProject in project liferay-ide by liferay.
the class GradleProjectTests method getOutputJar.
@Test
public void getOutputJar() throws Exception {
LiferayGradleProject gradleProject = Util.fullImportGradleProject("projects/getOutputJar");
assertNotNull(gradleProject);
NullProgressMonitor monitor = new NullProgressMonitor();
IPath outputJar = gradleProject.getOutputBundle(false, monitor);
assertNotNull(outputJar);
if (outputJar.toFile().exists()) {
outputJar.toFile().delete();
}
assertTrue(!outputJar.toFile().exists());
outputJar = gradleProject.getOutputBundle(true, monitor);
assertNotNull(outputJar);
assertTrue(outputJar.toFile().exists());
}
use of com.liferay.ide.gradle.core.LiferayGradleProject in project liferay-ide by liferay.
the class GradleProjectTests method hasGradleBundlePluginDetection.
/* @Test
public void gradleProjectProviderCache() throws Exception
{
final int[] consolesAdded = new int[1];
IConsoleListener consoleListener = new IConsoleListener()
{
@Override
public void consolesRemoved( IConsole[] consoles )
{
}
@Override
public void consolesAdded( IConsole[] consoles )
{
consolesAdded[0]++;
}
};
ConsolePlugin.getDefault().getConsoleManager().addConsoleListener( consoleListener );;
LiferayGradleProject gradleProject = fullImportGradleProject( "projects/cacheTest" );
assertNotNull( gradleProject );
IBundleProject bundleProject = LiferayCore.create( IBundleProject.class, gradleProject.getProject() );
assertNotNull( bundleProject );
assertEquals( LiferayGradleProject.class, bundleProject.getClass() );
assertEquals( 1, consolesAdded[0] );
bundleProject = LiferayCore.create( IBundleProject.class, gradleProject.getProject() );
assertNotNull( bundleProject );
assertEquals( LiferayGradleProject.class, bundleProject.getClass() );
assertEquals( 1, consolesAdded[0] );
IFile buildFile = gradleProject.getProject().getFile( "build.gradle" );
String buildFileContents = CoreUtil.readStreamToString( buildFile.getContents( true ), true );
String updatedContents = buildFileContents.replaceAll( "apply plugin: 'org.dm.bundle'", "" );
buildFile.setContents(
new ByteArrayInputStream( updatedContents.getBytes() ), IResource.FORCE, new NullProgressMonitor() );
final Object lock = new Object();
IGradleModelListener gradleModelListener = new IGradleModelListener()
{
@Override
public <T> void modelChanged( GradleProject project, Class<T> type, T model )
{
synchronized( lock )
{
lock.notify();
}
}
};
gradleProject.addModelListener( gradleModelListener );
gradleProject.requestGradleModelRefresh();
synchronized( lock )
{
lock.wait();
}
bundleProject = LiferayCore.create( IBundleProject.class, gradleProject.getProject() );
assertNull( bundleProject );
assertEquals( 2, consolesAdded[0] );
buildFile.setContents(
new ByteArrayInputStream( buildFileContents.getBytes() ), IResource.FORCE, new NullProgressMonitor() );
gradleProject.requestGradleModelRefresh();
synchronized( lock )
{
lock.wait();
}
bundleProject = LiferayCore.create( IBundleProject.class, gradleProject.getProject() );
assertNotNull( bundleProject );
assertEquals( 3, consolesAdded[0] );
}*/
@Test
public void hasGradleBundlePluginDetection() throws Exception {
final LiferayGradleProject gradleProject = Util.fullImportGradleProject("projects/biz.aQute.bundle");
assertNotNull(gradleProject);
final IBundleProject[] bundleProject = new IBundleProject[1];
WorkspaceJob job = new WorkspaceJob("") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
bundleProject[0] = LiferayCore.create(IBundleProject.class, gradleProject.getProject());
return Status.OK_STATUS;
}
};
job.schedule(5000);
job.join();
assertNotNull(bundleProject[0]);
assertEquals(LiferayGradleProject.class, bundleProject[0].getClass());
}
use of com.liferay.ide.gradle.core.LiferayGradleProject 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));
}
Aggregations