|
Lines 14-31
Link Here
|
| 14 |
import java.lang.reflect.InvocationTargetException; |
14 |
import java.lang.reflect.InvocationTargetException; |
| 15 |
|
15 |
|
| 16 |
import org.eclipse.core.commands.ExecutionException; |
16 |
import org.eclipse.core.commands.ExecutionException; |
|
|
17 |
import org.eclipse.core.resources.IContainer; |
| 17 |
import org.eclipse.core.resources.IFile; |
18 |
import org.eclipse.core.resources.IFile; |
|
|
19 |
import org.eclipse.core.resources.IFolder; |
| 18 |
import org.eclipse.core.resources.IProject; |
20 |
import org.eclipse.core.resources.IProject; |
| 19 |
import org.eclipse.core.runtime.CoreException; |
21 |
import org.eclipse.core.runtime.CoreException; |
| 20 |
import org.eclipse.core.runtime.IAdaptable; |
22 |
import org.eclipse.core.runtime.IAdaptable; |
| 21 |
import org.eclipse.core.runtime.IProgressMonitor; |
23 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 22 |
import org.eclipse.core.runtime.IStatus; |
24 |
import org.eclipse.core.runtime.IStatus; |
| 23 |
import org.eclipse.core.runtime.MultiStatus; |
25 |
import org.eclipse.core.runtime.MultiStatus; |
|
|
26 |
import org.eclipse.core.runtime.Path; |
| 24 |
import org.eclipse.core.runtime.Status; |
27 |
import org.eclipse.core.runtime.Status; |
| 25 |
import org.eclipse.core.runtime.SubProgressMonitor; |
28 |
import org.eclipse.core.runtime.SubProgressMonitor; |
| 26 |
import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; |
29 |
import org.eclipse.jst.j2ee.internal.earcreation.EARCreationResourceHandler; |
| 27 |
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; |
30 |
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; |
|
|
31 |
import org.eclipse.jst.j2ee.project.EarUtilities; |
| 28 |
import org.eclipse.osgi.util.NLS; |
32 |
import org.eclipse.osgi.util.NLS; |
|
|
33 |
import org.eclipse.wst.common.componentcore.ComponentCore; |
| 34 |
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
| 29 |
|
35 |
|
| 30 |
public class LinkArchiveIntoProjectOperation extends J2EEUtilityJarImportAssistantOperation { |
36 |
public class LinkArchiveIntoProjectOperation extends J2EEUtilityJarImportAssistantOperation { |
| 31 |
|
37 |
|
|
Lines 45-51
Link Here
|
| 45 |
IProject project = getWorkspaceRoot().getProject(getAssociatedEARProjectName()); |
51 |
IProject project = getWorkspaceRoot().getProject(getAssociatedEARProjectName()); |
| 46 |
|
52 |
|
| 47 |
try { |
53 |
try { |
| 48 |
IFile linkedJarFile = project.getFile(getUtilityJar().getName()); |
54 |
IVirtualComponent earComponent = ComponentCore.createComponent(project); |
|
|
55 |
IContainer underlyingFolder = earComponent.getRootFolder().getUnderlyingFolder(); |
| 56 |
String uriMapping = getUtilityJar().getName(); |
| 57 |
String earLib = EarUtilities.getEARLibDir(earComponent); |
| 58 |
IFolder libDirFolder = null; |
| 59 |
if(earLib != null && earLib.length() > 0) { |
| 60 |
uriMapping = (new Path(earLib)).append(uriMapping).toString(); |
| 61 |
if(underlyingFolder.isAccessible()) { |
| 62 |
libDirFolder = getWorkspaceRoot().getFolder(underlyingFolder.getFullPath().append(earLib)); |
| 63 |
} else { |
| 64 |
libDirFolder = getWorkspaceRoot().getFolder(project.getFullPath().append(earLib)); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
IFile linkedJarFile = null; |
| 69 |
if(underlyingFolder.isAccessible()) { |
| 70 |
linkedJarFile = underlyingFolder.getFile(new Path(uriMapping)); |
| 71 |
} else { |
| 72 |
linkedJarFile = project.getFile(uriMapping); |
| 73 |
} |
| 74 |
|
| 49 |
if (linkedJarFile.exists()) { |
75 |
if (linkedJarFile.exists()) { |
| 50 |
if (isOverwriteIfNecessary()) |
76 |
if (isOverwriteIfNecessary()) |
| 51 |
linkedJarFile.delete(true, true, new SubProgressMonitor(monitor, 1)); |
77 |
linkedJarFile.delete(true, true, new SubProgressMonitor(monitor, 1)); |
|
Lines 54-64
Link Here
|
| 54 |
return status; |
80 |
return status; |
| 55 |
} |
81 |
} |
| 56 |
} |
82 |
} |
| 57 |
status.add(createLinkedArchive(project, getUtilityJar().getName(), getUtilityJar(), linkedPathVariable, monitor)); |
83 |
|
|
|
84 |
// Create EAR's library directory folder if it doesn't exist |
| 85 |
if(libDirFolder != null && (!libDirFolder.exists() || !libDirFolder.isAccessible())) { |
| 86 |
mkdirs(libDirFolder); |
| 87 |
} |
| 88 |
|
| 89 |
status.add(createLinkedArchive(project, linkedJarFile.getProjectRelativePath().toString(), getUtilityJar(), linkedPathVariable, monitor)); |
| 58 |
|
90 |
|
| 59 |
addLibraryToClasspath(project, linkedJarFile, monitor); |
91 |
addLibraryToClasspath(project, linkedJarFile, monitor); |
| 60 |
|
92 |
|
| 61 |
createVirtualArchiveComponent(project, getUtilityJar().getName(), linkedJarFile, monitor); |
93 |
createVirtualArchiveComponent(project, uriMapping, linkedJarFile, monitor); |
| 62 |
|
94 |
|
| 63 |
} catch (CoreException e) { |
95 |
} catch (CoreException e) { |
| 64 |
status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); |
96 |
status.add(J2EEPlugin.createErrorStatus(0, e.getMessage(), e)); |