use of org.eclipse.wst.common.componentcore.resources.IVirtualReference in project liferay-ide by liferay.
the class PluginPackageResourceListener method processRequiredDeploymentContexts.
protected void processRequiredDeploymentContexts(Properties props, IProject project) {
IVirtualComponent rootComponent = ComponentCore.createComponent(project);
if (rootComponent == null) {
return;
}
List<IVirtualReference> removeRefs = new ArrayList<>();
IClasspathContainer webAppLibrariesContainer = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project);
if (webAppLibrariesContainer == null) {
return;
}
IClasspathEntry[] existingEntries = webAppLibrariesContainer.getClasspathEntries();
for (IClasspathEntry entry : existingEntries) {
IPath path = entry.getPath();
String archiveName = path.lastSegment();
if (archiveName.endsWith("-service.jar")) {
IFile file = _getWorkspaceFile(path);
if (file.exists() && ProjectUtil.isLiferayFacetedProject(file.getProject())) {
for (IVirtualReference ref : rootComponent.getReferences()) {
if (archiveName.equals(ref.getArchiveName())) {
removeRefs.add(ref);
}
}
}
}
}
List<IVirtualReference> addRefs = new ArrayList<>();
String requiredDeploymenContexts = props.getProperty("required-deployment-contexts");
if (requiredDeploymenContexts != null) {
String[] contexts = requiredDeploymenContexts.split(StringPool.COMMA);
if (ListUtil.isNotEmpty(contexts)) {
for (String context : contexts) {
IVirtualReference ref = processContext(rootComponent, context);
if (ref != null) {
addRefs.add(ref);
}
}
}
}
new WorkspaceJob("Update virtual component.") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
updateVirtualComponent(rootComponent, removeRefs, addRefs);
updateWebClasspathContainer(rootComponent, addRefs);
return Status.OK_STATUS;
}
}.schedule();
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualReference in project liferay-ide by liferay.
the class PluginPackageResourceListener method processContext.
protected IVirtualReference processContext(IVirtualComponent rootComponent, String context) {
// first check for jar file
IFile serviceJar = ComponentUtil.findServiceJarForContext(context);
if (serviceJar == null) {
return null;
}
IPath serviceJarPath = serviceJar.getFullPath();
if (rootComponent == null) {
return null;
}
String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR;
IVirtualComponent archive = ComponentCore.createArchiveComponent(rootComponent.getProject(), type + serviceJarPath.makeRelative().toString());
IVirtualReference ref = ComponentCore.createReference(rootComponent, archive, new Path(J2EEConstants.WEB_INF_LIB).makeAbsolute());
ref.setArchiveName(serviceJarPath.lastSegment());
return ref;
}
Aggregations