Lines 13-23
Link Here
|
13 |
import java.io.File; |
13 |
import java.io.File; |
14 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
15 |
import java.util.HashMap; |
15 |
import java.util.HashMap; |
|
|
16 |
import java.util.Iterator; |
17 |
import java.util.List; |
16 |
|
18 |
|
|
|
19 |
import org.eclipse.core.resources.IFolder; |
17 |
import org.eclipse.core.resources.IProject; |
20 |
import org.eclipse.core.resources.IProject; |
18 |
import org.eclipse.core.resources.IResource; |
21 |
import org.eclipse.core.resources.IResource; |
|
|
22 |
import org.eclipse.core.resources.IResourceChangeEvent; |
23 |
import org.eclipse.core.resources.IResourceChangeListener; |
19 |
import org.eclipse.core.runtime.CoreException; |
24 |
import org.eclipse.core.runtime.CoreException; |
20 |
import org.eclipse.core.runtime.IPath; |
25 |
import org.eclipse.core.runtime.IPath; |
|
|
26 |
import org.eclipse.core.runtime.NullProgressMonitor; |
21 |
import org.eclipse.core.runtime.Path; |
27 |
import org.eclipse.core.runtime.Path; |
22 |
import org.eclipse.jdt.core.IAccessRule; |
28 |
import org.eclipse.jdt.core.IAccessRule; |
23 |
import org.eclipse.jdt.core.IClasspathAttribute; |
29 |
import org.eclipse.jdt.core.IClasspathAttribute; |
Lines 27-32
Link Here
|
27 |
import org.eclipse.pde.core.plugin.IPluginLibrary; |
33 |
import org.eclipse.pde.core.plugin.IPluginLibrary; |
28 |
import org.eclipse.pde.core.plugin.IPluginModelBase; |
34 |
import org.eclipse.pde.core.plugin.IPluginModelBase; |
29 |
import org.eclipse.pde.core.plugin.PluginRegistry; |
35 |
import org.eclipse.pde.core.plugin.PluginRegistry; |
|
|
36 |
import org.eclipse.pde.internal.build.Utils; |
30 |
|
37 |
|
31 |
public class PDEClasspathContainer { |
38 |
public class PDEClasspathContainer { |
32 |
|
39 |
|
Lines 44-51
Link Here
|
44 |
} |
51 |
} |
45 |
} |
52 |
} |
46 |
|
53 |
|
|
|
54 |
private static class PrebuildActions implements IResourceChangeListener { |
55 |
private List actions = new ArrayList() ; |
56 |
|
57 |
public void resourceChanged(IResourceChangeEvent event) { |
58 |
for (Iterator iterator = actions.iterator(); iterator.hasNext();) { |
59 |
Runnable action = (Runnable) iterator.next(); |
60 |
action.run(); |
61 |
} |
62 |
actions.clear(); |
63 |
} |
64 |
|
65 |
public void addAction(Runnable runnable) { |
66 |
actions.add(runnable); |
67 |
} |
68 |
} |
69 |
|
47 |
private static HashMap ACCESSIBLE_RULES = new HashMap(); |
70 |
private static HashMap ACCESSIBLE_RULES = new HashMap(); |
48 |
private static HashMap DISCOURAGED_RULES = new HashMap(); |
71 |
private static HashMap DISCOURAGED_RULES = new HashMap(); |
|
|
72 |
private static PrebuildActions workspaceRunnable ; |
49 |
|
73 |
|
50 |
private static final IAccessRule EXCLUDE_ALL_RULE = |
74 |
private static final IAccessRule EXCLUDE_ALL_RULE = |
51 |
JavaCore.newAccessRule(new Path("**/*"), IAccessRule.K_NON_ACCESSIBLE|IAccessRule.IGNORE_IF_BETTER); //$NON-NLS-1$ |
75 |
JavaCore.newAccessRule(new Path("**/*"), IAccessRule.K_NON_ACCESSIBLE|IAccessRule.IGNORE_IF_BETTER); //$NON-NLS-1$ |
Lines 76-82
Link Here
|
76 |
} |
100 |
} |
77 |
|
101 |
|
78 |
protected static void addExternalPlugin(IPluginModelBase model, Rule[] rules, ArrayList entries) throws CoreException { |
102 |
protected static void addExternalPlugin(IPluginModelBase model, Rule[] rules, ArrayList entries) throws CoreException { |
79 |
if (new File(model.getInstallLocation()).isFile()) { |
103 |
// bug# 198641 |
|
|
104 |
String[] devPaths = DevEntryHelper.getDevClassPath(model.getBundleDescription().getSymbolicName()); |
105 |
if (devPaths.length > 0) { |
106 |
addDevPluginPaths(entries, devPaths); |
107 |
} else if (new File(model.getInstallLocation()).isFile()) { |
80 |
IPath srcPath = ClasspathUtilCore.getSourceAnnotation(model, "."); //$NON-NLS-1$ |
108 |
IPath srcPath = ClasspathUtilCore.getSourceAnnotation(model, "."); //$NON-NLS-1$ |
81 |
if (srcPath == null) |
109 |
if (srcPath == null) |
82 |
srcPath = new Path(model.getInstallLocation()); |
110 |
srcPath = new Path(model.getInstallLocation()); |
Lines 100-106
Link Here
|
100 |
} |
128 |
} |
101 |
} |
129 |
} |
102 |
} |
130 |
} |
|
|
131 |
|
132 |
protected static void addDevPluginPaths(ArrayList entries, String[] paths) { |
133 |
for (int i = 0; i < paths.length; i++) { |
134 |
IClasspathEntry entry ; |
135 |
File file = new File(paths[i]); |
136 |
if (file.isFile()) { |
137 |
entry = JavaCore.newLibraryEntry(Path.fromPortableString(paths[i]), null, null); |
138 |
} else { |
139 |
entry = getFolderEntry(paths[i]); |
140 |
} |
141 |
|
142 |
if (entry != null) |
143 |
entries.add(entry); |
144 |
} |
145 |
return ; |
146 |
} |
103 |
|
147 |
|
|
|
148 |
private static IClasspathEntry getFolderEntry(String path) { |
149 |
final IPath ipath = Path.fromPortableString(path); |
150 |
IProject project ; |
151 |
project = getLinkedFolder(); |
152 |
if (project == null) |
153 |
return null ; |
154 |
String[] segments = ipath.segments(); |
155 |
String linkedFolder = Utils.getStringFromArray(segments, "_"); |
156 |
final IFolder folder = project.getFolder(linkedFolder); |
157 |
if (!folder.exists()) { |
158 |
workspaceRunnable.addAction(new Runnable() { |
159 |
public void run() { |
160 |
try { |
161 |
if (!folder.exists()) { |
162 |
folder.createLink(ipath, IResource.REPLACE, new NullProgressMonitor()); |
163 |
} |
164 |
} catch (CoreException e) { |
165 |
e.printStackTrace(); |
166 |
} |
167 |
} |
168 |
}); |
169 |
} |
170 |
return JavaCore.newLibraryEntry(folder.getFullPath(), null, null); |
171 |
} |
172 |
|
173 |
private static IProject getLinkedFolder() { |
174 |
final IProject project = PDECore.getWorkspace().getRoot().getProject("__host_plugins__"); |
175 |
if (!project.exists() || !project.isOpen()) |
176 |
workspaceRunnable.addAction(new Runnable() { |
177 |
public void run() { |
178 |
try { |
179 |
if (!project.exists()) { |
180 |
project.create(new NullProgressMonitor()); |
181 |
} |
182 |
if (!project.isOpen()) { |
183 |
project.open(new NullProgressMonitor()); |
184 |
} |
185 |
} catch (CoreException e) { |
186 |
e.printStackTrace(); |
187 |
} |
188 |
} |
189 |
}); |
190 |
return project ; |
191 |
} |
192 |
|
104 |
protected static void addLibraryEntry(IPath path, IPath srcPath, Rule[] rules, IClasspathAttribute[] attributes, ArrayList entries) { |
193 |
protected static void addLibraryEntry(IPath path, IPath srcPath, Rule[] rules, IClasspathAttribute[] attributes, ArrayList entries) { |
105 |
IClasspathEntry entry = null; |
194 |
IClasspathEntry entry = null; |
106 |
if (rules != null) { |
195 |
if (rules != null) { |
Lines 176-180
Link Here
|
176 |
} |
265 |
} |
177 |
return null; |
266 |
return null; |
178 |
} |
267 |
} |
|
|
268 |
|
269 |
public static void start() { |
270 |
if (workspaceRunnable == null) { |
271 |
workspaceRunnable = new PrebuildActions(); |
272 |
JavaCore.addPreProcessingResourceChangedListener( |
273 |
workspaceRunnable, |
274 |
IResourceChangeEvent.PRE_BUILD); |
275 |
} |
276 |
} |
277 |
|
278 |
public static void stop() { |
279 |
if (workspaceRunnable != null) { |
280 |
JavaCore.removePreProcessingResourceChangedListener(workspaceRunnable); |
281 |
workspaceRunnable = null ; |
282 |
} |
283 |
} |
179 |
|
284 |
|
180 |
} |
285 |
} |