use of com.liferay.ide.core.ILiferayProjectImporter in project liferay-ide by liferay.
the class NewMavenJSFModuleProjectProvider method createNewProject.
@Override
public IStatus createNewProject(NewLiferayJSFModuleProjectOp op, IProgressMonitor monitor) throws CoreException {
IStatus retval = null;
IPath projectLocation = createArchetypeProject(op, monitor);
IPath buildGradle = projectLocation.append("build.gradle");
if (FileUtil.exists(buildGradle)) {
buildGradle.toFile().delete();
}
ILiferayProjectImporter importer = LiferayCore.getImporter("maven");
IStatus canImport = importer.canImport(projectLocation.toOSString());
if (canImport.getCode() != Status.ERROR) {
importer.importProjects(projectLocation.toOSString(), monitor);
}
retval = Status.OK_STATUS;
return retval;
}
use of com.liferay.ide.core.ILiferayProjectImporter in project liferay-ide by liferay.
the class LiferayMavenLegacyProjectUpdaterTests method testUpgrade.
@Test
public void testUpgrade() throws Exception {
IProject project = CoreUtil.getProject("testMavenProjects");
if (project != null && project.exists()) {
project.delete(true, true, new NullProgressMonitor());
}
final URL projectZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/testMavenProjects.zip");
final File projectZipFile = new File(FileLocator.toFileURL(projectZipUrl).getFile());
IPath stateLocation = LiferayMavenCore.getDefault().getStateLocation();
File targetFolder = new File(stateLocation.toFile(), "testMavenProjects");
if (targetFolder.exists()) {
targetFolder.delete();
}
ZipUtil.unzip(projectZipFile, stateLocation.toFile());
assertTrue(targetFolder.exists());
ILiferayProjectImporter importer = LiferayCore.getImporter("maven");
importer.importProjects(targetFolder.getAbsolutePath(), new NullProgressMonitor());
LiferayMavenLegacyProjectUpdater updater = new LiferayMavenLegacyProjectUpdater();
// portlet project
IProject ppProject = CoreUtil.getProject("testpp");
assertTrue(updater.isNeedUpgrade(ppProject));
updater.upgradePomFile(ppProject, null);
assertFalse(updater.isNeedUpgrade(ppProject));
assertTrue(containString(ppProject, "com.liferay.css.builder"));
makeSureNoLegacyElememnts(ppProject);
// service builder parent project
IProject testsbProject = CoreUtil.getProject("testsb");
assertTrue(updater.isNeedUpgrade(testsbProject));
updater.upgradePomFile(testsbProject, null);
assertFalse(updater.isNeedUpgrade(testsbProject));
makeSureNoLegacyElememnts(testsbProject);
// service builder -portlet subproject
IProject testsbPortletProject = CoreUtil.getProject("testsb-portlet");
assertTrue(updater.isNeedUpgrade(testsbPortletProject));
updater.upgradePomFile(testsbPortletProject, null);
assertFalse(updater.isNeedUpgrade(testsbPortletProject));
assertTrue(containString(testsbPortletProject, "com.liferay.css.builder"));
assertTrue(containString(testsbPortletProject, "com.liferay.portal.tools.service.builder"));
assertTrue(containString(testsbPortletProject, "biz.aQute.bnd.annotation"));
makeSureNoLegacyElememnts(testsbPortletProject);
// // service builder -service subproject
IProject testsbPortletServiceProject = CoreUtil.getProject("testsb-portlet-service");
assertTrue(updater.isNeedUpgrade(testsbPortletServiceProject));
updater.upgradePomFile(testsbPortletServiceProject, null);
assertFalse(updater.isNeedUpgrade(testsbPortletServiceProject));
assertTrue(containString(testsbPortletServiceProject, "biz.aQute.bnd.annotation"));
makeSureNoLegacyElememnts(testsbPortletServiceProject);
// theme project
IProject testthemeProject = CoreUtil.getProject("testtheme");
assertTrue(updater.isNeedUpgrade(testthemeProject));
updater.upgradePomFile(testthemeProject, null);
assertFalse(updater.isNeedUpgrade(testthemeProject));
assertTrue(containString(testthemeProject, "com.liferay.portal.tools.theme.builder.outputDir"));
assertTrue(containString(testthemeProject, "project.build.sourceEncoding"));
assertTrue(containString(testthemeProject, "maven-war-plugin"));
assertTrue(containString(testthemeProject, "maven-dependency-plugin"));
assertTrue(containString(testthemeProject, "com.liferay.css.builder"));
assertTrue(containString(testthemeProject, "com.liferay.portal.tools.theme.builder"));
makeSureNoLegacyElememnts(testthemeProject);
}
use of com.liferay.ide.core.ILiferayProjectImporter in project liferay-ide by liferay.
the class NewLiferayWorkspaceOpTests method testNewLiferayWorkspaceOp.
@Test
public void testNewLiferayWorkspaceOp() throws Exception {
ILiferayProjectImporter importer = LiferayCore.getImporter("gradle");
File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
URL projectZipUrl = Platform.getBundle("com.liferay.ide.project.core.tests").getEntry("projects/existingProject.zip");
final File projectZipFile = new File(FileLocator.toFileURL(projectZipUrl).getFile());
ZipUtil.unzip(projectZipFile, eclipseWorkspaceLocation);
File projectFolder = new File(eclipseWorkspaceLocation, "existingProject");
waitForBuildAndValidation();
importer.importProjects(projectFolder.getAbsolutePath(), new NullProgressMonitor());
NewLiferayWorkspaceOp op = NewLiferayWorkspaceOp.TYPE.instantiate();
op.setWorkspaceName("existingProject");
String message = op.validation().message();
assertNotNull(message);
assertEquals("A project with that name(ignore case) already exists.", message);
op.setWorkspaceName("ExistingProject");
message = op.validation().message();
assertTrue(message.equals("A project with that name(ignore case) already exists."));
String projectName = "test-liferay-workspace";
IPath workspaceLocation = CoreUtil.getWorkspaceRoot().getLocation();
op.setWorkspaceName(projectName);
op.setUseDefaultLocation(false);
op.setLocation(workspaceLocation.toPortableString());
op.execute(new ProgressMonitor());
String wsLocation = workspaceLocation.append(projectName).toPortableString();
File wsFile = new File(wsLocation);
assertTrue(wsFile.exists());
assertTrue(LiferayWorkspaceUtil.isValidWorkspaceLocation(wsLocation));
File propertiesFile = new File(wsFile, "gradle.properties");
Properties prop = PropertiesUtil.loadProperties(propertiesFile);
prop.setProperty(LiferayWorkspaceUtil.LIFERAY_WORKSPACE_WARS_DIR, "wars,wars2");
PropertiesUtil.saveProperties(prop, propertiesFile);
NewLiferayModuleProjectOp moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
moduleProjectOp.setProjectName("testThemeWarDefault");
moduleProjectOp.setProjectTemplateName("theme");
moduleProjectOp.execute(new ProgressMonitor());
waitForBuildAndValidation();
assertTrue(CoreUtil.getProject("testThemeWarDefault").exists());
moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
moduleProjectOp.setProjectName("testThemeWarNotDefault");
moduleProjectOp.setProjectTemplateName("theme");
moduleProjectOp.setUseDefaultLocation(false);
moduleProjectOp.setLocation(wsLocation + "/wars");
moduleProjectOp.execute(new ProgressMonitor());
waitForBuildAndValidation();
assertTrue(CoreUtil.getProject("testThemeWarNotDefault").exists());
moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
moduleProjectOp.setProjectName("testThemeWar2");
moduleProjectOp.setProjectTemplateName("theme");
moduleProjectOp.setUseDefaultLocation(false);
moduleProjectOp.setLocation(wsLocation + "/wars2");
moduleProjectOp.execute(new ProgressMonitor());
waitForBuildAndValidation();
assertTrue(CoreUtil.getProject("testThemeWar2").exists());
}
use of com.liferay.ide.core.ILiferayProjectImporter in project liferay-ide by liferay.
the class InitConfigureProjectPage method importProject.
protected void importProject() throws CoreException {
String layout = dataModel.getLayout().content();
IPath location = PathBridge.create(dataModel.getSdkLocation().content());
if (_isAlreadyImported(location)) {
Stream.of(CoreUtil.getAllProjects()).forEach(this::_checkProjectType);
dataModel.setImportFinished(true);
return;
}
try {
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
progressService.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
String newPath = "";
_backup(monitor);
_clearExistingProjects(location, monitor);
_deleteEclipseConfigFiles(location.toFile());
if (_isMavenProject(location.toPortableString())) {
ILiferayProjectImporter importer = LiferayCore.getImporter("maven");
List<IProject> projects = importer.importProjects(location.toPortableString(), monitor);
for (IProject project : projects) {
_checkProjectType(project);
}
} else {
if (layout.equals("Upgrade to Liferay Workspace")) {
_createLiferayWorkspace(location, monitor);
_removeIvyPrivateSetting(location.append("plugins-sdk"));
newPath = _renameProjectFolder(location);
IPath sdkLocation = new Path(newPath).append("plugins-sdk");
_deleteSDKLegacyProjects(sdkLocation);
ILiferayProjectImporter importer = LiferayCore.getImporter("gradle");
importer.importProjects(newPath, monitor);
if (dataModel.getDownloadBundle().content()) {
_createInitBundle(monitor);
}
_importSDKProject(sdkLocation, monitor);
dataModel.setConvertLiferayWorkspace(true);
} else {
_deleteEclipseConfigFiles(location.toFile());
_copyNewSDK(location, monitor);
_removeIvyPrivateSetting(location);
_deleteSDKLegacyProjects(location);
String serverName = dataModel.getLiferay70ServerName().content();
IServer server = ServerUtil.getServer(serverName);
newPath = _renameProjectFolder(location);
SDK sdk = SDKUtil.createSDKFromLocation(new Path(newPath));
sdk.addOrUpdateServerProperties(ServerUtil.getLiferayRuntime(server).getLiferayHome());
SDKUtil.openAsProject(sdk, monitor);
_importSDKProject(sdk.getLocation(), monitor);
}
}
dataModel.setImportFinished(true);
} catch (Exception e) {
ProjectUI.logError(e);
throw new InvocationTargetException(e, e.getMessage());
}
}
});
} catch (Exception e) {
ProjectUI.logError(e);
throw new CoreException(StatusBridge.create(Status.createErrorStatus(e.getMessage(), e)));
}
}
use of com.liferay.ide.core.ILiferayProjectImporter in project liferay-ide by liferay.
the class ImportLiferayModuleProjectOpMethods method execute.
public static final Status execute(ImportLiferayModuleProjectOp op, ProgressMonitor pm) {
IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
monitor.beginTask("Importing Module project...", 100);
Path path = op.getLocation().content();
String location = path.toOSString();
ILiferayProjectImporter importer = LiferayCore.getImporter(op.getBuildType().content());
Status retval = Status.createOkStatus();
try {
importer.importProjects(location, monitor);
} catch (CoreException ce) {
retval = Status.createErrorStatus(ce);
}
return retval;
}
Aggregations