use of org.apache.ivyde.eclipse.cp.IvyClasspathContainer in project liferay-ide by liferay.
the class IvyUtil method addIvyLibrary.
public static IvyClasspathContainer addIvyLibrary(IProject project, IProgressMonitor monitor) {
final String projectName = project.getName();
final IJavaProject javaProject = JavaCore.create(project);
final IvyClasspathContainerConfiguration conf = new IvyClasspathContainerConfiguration(javaProject, ISDKConstants.IVY_XML_FILE, true);
final ClasspathSetup classpathSetup = new ClasspathSetup();
conf.setAdvancedProjectSpecific(false);
conf.setClasspathSetup(classpathSetup);
conf.setClassthProjectSpecific(false);
conf.setConfs(Collections.singletonList("*"));
conf.setMappingProjectSpecific(false);
conf.setSettingsProjectSpecific(true);
SDK sdk = SDKUtil.getSDK(project);
final SettingsSetup settingsSetup = new SettingsSetup();
IPath ivyFilePath = sdk.getLocation().append(ISDKConstants.IVY_SETTINGS_XML_FILE);
if (ivyFilePath.toFile().exists()) {
StringBuilder builder = new StringBuilder();
builder.append("${");
builder.append(ISDKConstants.VAR_NAME_LIFERAY_SDK_DIR);
builder.append(":");
builder.append(projectName);
builder.append("}/");
builder.append(ISDKConstants.IVY_SETTINGS_XML_FILE);
settingsSetup.setIvySettingsPath(builder.toString());
}
StringBuilder builder = new StringBuilder();
builder.append("${");
builder.append(ISDKConstants.VAR_NAME_LIFERAY_SDK_DIR);
builder.append(":");
builder.append(projectName);
builder.append("}/.ivy");
settingsSetup.setIvyUserDir(builder.toString());
conf.setIvySettingsSetup(settingsSetup);
final IPath path = conf.getPath();
final IClasspathAttribute[] atts = conf.getAttributes();
final IClasspathEntry ivyEntry = JavaCore.newContainerEntry(path, null, atts, false);
final IVirtualComponent virtualComponent = ComponentCore.createComponent(project);
try {
IClasspathEntry[] entries = javaProject.getRawClasspath();
List<IClasspathEntry> newEntries = new ArrayList<>(Arrays.asList(entries));
IPath runtimePath = getDefaultRuntimePath(virtualComponent, ivyEntry);
// add the deployment assembly config to deploy ivy container to /WEB-INF/lib
final IClasspathEntry cpeTagged = modifyDependencyPath(ivyEntry, runtimePath);
newEntries.add(cpeTagged);
entries = (IClasspathEntry[]) newEntries.toArray(new IClasspathEntry[newEntries.size()]);
javaProject.setRawClasspath(entries, javaProject.getOutputLocation(), monitor);
IvyClasspathContainer ivycp = IvyClasspathContainerHelper.getContainer(path, javaProject);
return ivycp;
} catch (JavaModelException jme) {
ProjectUI.logError("Unable to add Ivy library container", jme);
}
return null;
}
use of org.apache.ivyde.eclipse.cp.IvyClasspathContainer in project liferay-ide by liferay.
the class IvyUtil method configureIvyProject.
public static IStatus configureIvyProject(final IProject project, IProgressMonitor monitor) throws CoreException {
SDK sdk = SDKUtil.getSDK(project);
// check for 6.1.2 and greater but not 6.1.10 which is older EE release
// and match 6.2.0 and greater
final Version version = new Version(sdk.getVersion());
if (((CoreUtil.compareVersions(version, ILiferayConstants.V611) >= 0) && (CoreUtil.compareVersions(version, ILiferayConstants.V6110) < 0)) || (CoreUtil.compareVersions(version, ILiferayConstants.V620) >= 0)) {
IFile ivyXmlFile = project.getFile(ISDKConstants.IVY_XML_FILE);
if (ivyXmlFile.exists()) {
// IDE-1044
addIvyNature(project, monitor);
IvyClasspathContainer ivycp = addIvyLibrary(project, monitor);
if (ivycp != null) {
IStatus status = ivycp.launchResolve(false, monitor);
if (status.isOK()) {
final IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if (webproject != null) {
final IFolder webinfFolder = webproject.getDefaultDocrootFolder().getFolder("WEB-INF");
if (webinfFolder != null) {
ComponentUtil.validateFolder(webinfFolder, monitor);
}
}
} else {
return status;
}
}
}
}
return Status.OK_STATUS;
}
Aggregations