1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
package org.apache.maven.plugin.eclipse.reader; |
15 | |
|
16 | |
import java.io.DataInputStream; |
17 | |
import java.io.File; |
18 | |
import java.io.FileInputStream; |
19 | |
import java.io.FileNotFoundException; |
20 | |
import java.io.FileReader; |
21 | |
import java.io.IOException; |
22 | |
import java.io.StringReader; |
23 | |
import java.net.URI; |
24 | |
import java.net.URISyntaxException; |
25 | |
import java.text.MessageFormat; |
26 | |
import java.util.ArrayList; |
27 | |
import java.util.HashMap; |
28 | |
import java.util.Iterator; |
29 | |
import java.util.Map; |
30 | |
import java.util.Properties; |
31 | |
import java.util.Set; |
32 | |
import java.util.jar.JarFile; |
33 | |
|
34 | |
import org.apache.maven.plugin.eclipse.Messages; |
35 | |
import org.apache.maven.plugin.eclipse.WorkspaceConfiguration; |
36 | |
import org.apache.maven.plugin.ide.IdeDependency; |
37 | |
import org.apache.maven.plugin.ide.IdeUtils; |
38 | |
import org.apache.maven.plugin.logging.Log; |
39 | |
import org.apache.maven.project.MavenProject; |
40 | |
import org.codehaus.plexus.util.IOUtil; |
41 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
42 | |
import org.codehaus.plexus.util.xml.Xpp3DomBuilder; |
43 | |
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; |
44 | |
import org.eclipse.core.internal.localstore.SafeChunkyInputStream; |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | 10 | public class ReadWorkspaceLocations |
53 | |
{ |
54 | |
|
55 | |
public static final String BINARY_LOCATION_FILE = ".location"; |
56 | |
|
57 | |
public static final String METADATA_PLUGINS_ORG_ECLIPSE_CORE_RESOURCES_PROJECTS = |
58 | |
".metadata/.plugins/org.eclipse.core.resources/.projects"; |
59 | |
|
60 | 2 | private static final String[] PARENT_VERSION = new String[] { "parent", "version" }; |
61 | |
|
62 | 2 | private static final String[] PARENT_GROUP_ID = new String[] { "parent", "groupId" }; |
63 | |
|
64 | 2 | private static final String[] PACKAGING = new String[] { "packaging" }; |
65 | |
|
66 | 2 | private static final String[] VERSION = new String[] { "version" }; |
67 | |
|
68 | 2 | private static final String[] GROUP_ID = new String[] { "groupId" }; |
69 | |
|
70 | 2 | private static final String[] ARTEFACT_ID = new String[] { "artifactId" }; |
71 | |
|
72 | |
private static final String METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_LAUNCHING_PREFS = |
73 | |
".metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs"; |
74 | |
|
75 | |
private static final String METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_PREFS_VM_KEY = |
76 | |
"org.eclipse.jdt.launching.PREF_VM_XML"; |
77 | |
|
78 | |
private static final String METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_SERVER_PREFS = |
79 | |
".metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.server.core.prefs"; |
80 | |
|
81 | |
private static final String METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_PREFS_RUNTIMES_KEY = "runtimes"; |
82 | |
|
83 | |
private static final String CLASSPATHENTRY_DEFAULT = "org.eclipse.jdt.launching.JRE_CONTAINER"; |
84 | |
|
85 | |
private static final String CLASSPATHENTRY_STANDARD = |
86 | |
CLASSPATHENTRY_DEFAULT + "/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/"; |
87 | |
|
88 | |
private static final String CLASSPATHENTRY_FORMAT = ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT + "/{0}/{1}"; |
89 | |
|
90 | |
public void init( Log log, WorkspaceConfiguration workspaceConfiguration, MavenProject project, |
91 | |
String wtpDefaultServer ) |
92 | |
{ |
93 | 0 | detectDefaultJREContainer( workspaceConfiguration, project, log ); |
94 | 0 | readWorkspace( workspaceConfiguration, log ); |
95 | 0 | detectWTPDefaultServer( workspaceConfiguration, wtpDefaultServer, log ); |
96 | 0 | } |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
private void detectWTPDefaultServer( WorkspaceConfiguration workspaceConfiguration, String wtpDefaultServer, Log log ) |
106 | |
{ |
107 | 0 | HashMap servers = readDefinedServers( workspaceConfiguration, log ); |
108 | 0 | if ( servers == null || servers.isEmpty() ) |
109 | |
{ |
110 | 0 | return; |
111 | |
} |
112 | 0 | if ( wtpDefaultServer != null ) |
113 | |
{ |
114 | 0 | Set ids = servers.keySet(); |
115 | |
|
116 | 0 | Iterator idIterator = ids.iterator(); |
117 | 0 | while ( workspaceConfiguration.getDefaultDeployServerId() == null && idIterator.hasNext() ) |
118 | |
{ |
119 | 0 | String id = (String) idIterator.next(); |
120 | 0 | String name = (String) servers.get( id ); |
121 | 0 | if ( wtpDefaultServer.equals( id ) || wtpDefaultServer.equals( name ) ) |
122 | |
{ |
123 | 0 | workspaceConfiguration.setDefaultDeployServerId( id ); |
124 | 0 | workspaceConfiguration.setDefaultDeployServerName( name ); |
125 | |
} |
126 | 0 | } |
127 | 0 | if ( workspaceConfiguration.getDefaultDeployServerId() == null ) |
128 | |
{ |
129 | 0 | log.info( "no exact wtp server match." ); |
130 | |
|
131 | 0 | idIterator = ids.iterator(); |
132 | 0 | while ( workspaceConfiguration.getDefaultDeployServerId() == null && idIterator.hasNext() ) |
133 | |
{ |
134 | 0 | String id = (String) idIterator.next(); |
135 | 0 | String name = (String) servers.get( id ); |
136 | 0 | if ( id.indexOf( wtpDefaultServer ) >= 0 || name.indexOf( wtpDefaultServer ) >= 0 ) |
137 | |
{ |
138 | 0 | workspaceConfiguration.setDefaultDeployServerId( id ); |
139 | 0 | workspaceConfiguration.setDefaultDeployServerName( name ); |
140 | |
} |
141 | 0 | } |
142 | |
} |
143 | |
} |
144 | 0 | if ( workspaceConfiguration.getDefaultDeployServerId() == null && servers.size() > 0 ) |
145 | |
{ |
146 | |
|
147 | 0 | log.info( "no substring wtp server match." ); |
148 | 0 | workspaceConfiguration.setDefaultDeployServerId( (String) servers.get( "" ) ); |
149 | 0 | workspaceConfiguration.setDefaultDeployServerName( (String) servers.get( workspaceConfiguration.getDefaultDeployServerId() ) ); |
150 | |
} |
151 | 0 | log.info( "Using as WTP server : " + workspaceConfiguration.getDefaultDeployServerName() ); |
152 | 0 | } |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
private String getContainerFromExecutable( String rawExecutable, Map jreMap, Log logger ) |
163 | |
{ |
164 | 0 | String foundContainer = null; |
165 | 0 | if ( rawExecutable != null ) |
166 | |
{ |
167 | |
String executable; |
168 | |
try |
169 | |
{ |
170 | 0 | executable = new File( rawExecutable ).getCanonicalPath(); |
171 | 0 | logger.debug( "detected executable: " + executable ); |
172 | |
} |
173 | 0 | catch ( Exception e ) |
174 | |
{ |
175 | 0 | return null; |
176 | 0 | } |
177 | 0 | File executableFile = new File( executable ); |
178 | 0 | while ( executableFile != null ) |
179 | |
{ |
180 | 0 | foundContainer = (String) jreMap.get( executableFile.getPath() ); |
181 | 0 | if ( foundContainer != null ) |
182 | |
{ |
183 | 0 | logger.debug( "detected classpathContainer from executable: " + foundContainer ); |
184 | 0 | return foundContainer; |
185 | |
|
186 | |
} |
187 | 0 | executableFile = executableFile.getParentFile(); |
188 | |
} |
189 | |
} |
190 | 0 | return null; |
191 | |
} |
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
private void detectDefaultJREContainer( WorkspaceConfiguration workspaceConfiguration, MavenProject project, |
201 | |
Log logger ) |
202 | |
{ |
203 | 0 | String defaultJREContainer = ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT; |
204 | 0 | if ( workspaceConfiguration.getWorkspaceDirectory() != null ) |
205 | |
{ |
206 | 0 | Map jreMap = readAvailableJREs( workspaceConfiguration.getWorkspaceDirectory(), logger ); |
207 | 0 | if ( jreMap != null ) |
208 | |
{ |
209 | 0 | String foundContainer = |
210 | |
getContainerFromExecutable( System.getProperty( "maven.compiler.executable" ), jreMap, logger ); |
211 | 0 | if ( foundContainer == null ) |
212 | |
{ |
213 | 0 | foundContainer = |
214 | |
getContainerFromExecutable( IdeUtils.getCompilerPluginSetting( project, "executable" ), jreMap, |
215 | |
logger ); |
216 | |
} |
217 | 0 | if ( foundContainer == null ) |
218 | |
{ |
219 | 0 | String sourceVersion = IdeUtils.getCompilerSourceVersion( project ); |
220 | 0 | foundContainer = (String) jreMap.get( sourceVersion ); |
221 | 0 | if ( foundContainer != null ) |
222 | |
{ |
223 | 0 | logger.debug( "detected classpathContainer from sourceVersion(" + sourceVersion + "): " |
224 | |
+ foundContainer ); |
225 | |
} |
226 | |
} |
227 | 0 | if ( foundContainer == null ) |
228 | |
{ |
229 | 0 | foundContainer = getContainerFromExecutable( System.getProperty( "java.home" ), jreMap, logger ); |
230 | |
} |
231 | 0 | if ( foundContainer != null ) |
232 | |
{ |
233 | 0 | defaultJREContainer = foundContainer; |
234 | |
} |
235 | |
|
236 | |
} |
237 | |
} |
238 | 0 | workspaceConfiguration.setDefaultClasspathContainer( defaultJREContainer ); |
239 | 0 | } |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
File getProjectLocation( File workspaceLocation, File project ) |
251 | |
throws IOException, URISyntaxException |
252 | |
{ |
253 | 6 | File location = new File( project, ReadWorkspaceLocations.BINARY_LOCATION_FILE ); |
254 | 6 | if ( location.exists() ) |
255 | |
{ |
256 | 4 | SafeChunkyInputStream fileInputStream = null; |
257 | |
try |
258 | |
{ |
259 | 4 | fileInputStream = new SafeChunkyInputStream( location ); |
260 | 4 | DataInputStream dataInputStream = new DataInputStream( fileInputStream ); |
261 | 4 | String file = dataInputStream.readUTF().trim(); |
262 | |
|
263 | 4 | if ( file.length() > 0 ) |
264 | |
{ |
265 | 4 | if ( !file.startsWith( "URI//" ) ) |
266 | |
{ |
267 | 0 | throw new IOException( location.getAbsolutePath() + " contains unexpected data: " + file ); |
268 | |
} |
269 | 4 | file = file.substring( "URI//".length() ); |
270 | 4 | return new File( new URI( file ) ); |
271 | |
} |
272 | |
} |
273 | |
finally |
274 | |
{ |
275 | 4 | IOUtil.close( fileInputStream ); |
276 | 0 | } |
277 | |
} |
278 | 2 | File projectBase = new File( workspaceLocation, project.getName() ); |
279 | 2 | if ( projectBase.isDirectory() ) |
280 | |
{ |
281 | 2 | return projectBase; |
282 | |
} |
283 | |
|
284 | 0 | return null; |
285 | |
} |
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
private String getValue( Xpp3Dom element, String[] elementNames, String defaultValue ) |
296 | |
{ |
297 | 0 | String value = null; |
298 | 0 | Xpp3Dom dom = element; |
299 | 0 | for ( int index = 0; dom != null && index < elementNames.length; index++ ) |
300 | |
{ |
301 | 0 | dom = dom.getChild( elementNames[index] ); |
302 | |
} |
303 | 0 | if ( dom != null ) |
304 | |
{ |
305 | 0 | value = dom.getValue(); |
306 | |
} |
307 | 0 | if ( value == null || value.trim().length() == 0 ) |
308 | |
{ |
309 | 0 | return defaultValue; |
310 | |
} |
311 | |
else |
312 | |
{ |
313 | 0 | return value; |
314 | |
} |
315 | |
} |
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | |
|
328 | |
private IdeDependency readArtefact( File projectLocation, Log logger ) |
329 | |
throws FileNotFoundException, XmlPullParserException, IOException |
330 | |
{ |
331 | 0 | File projectFile = new File( projectLocation, ".project" ); |
332 | 0 | String eclipseProjectName = projectLocation.getName(); |
333 | 0 | if ( projectFile.exists() ) |
334 | |
{ |
335 | 0 | Xpp3Dom project = Xpp3DomBuilder.build( new FileReader( projectFile ) ); |
336 | 0 | eclipseProjectName = getValue( project, new String[] { "name" }, eclipseProjectName ); |
337 | |
} |
338 | 0 | File pomFile = new File( projectLocation, "pom.xml" ); |
339 | 0 | if ( pomFile.exists() ) |
340 | |
{ |
341 | 0 | Xpp3Dom pom = Xpp3DomBuilder.build( new FileReader( pomFile ) ); |
342 | |
|
343 | 0 | String artifact = getValue( pom, ReadWorkspaceLocations.ARTEFACT_ID, null ); |
344 | 0 | String group = |
345 | |
getValue( pom, ReadWorkspaceLocations.GROUP_ID, getValue( pom, ReadWorkspaceLocations.PARENT_GROUP_ID, |
346 | |
null ) ); |
347 | 0 | String version = |
348 | |
getValue( pom, ReadWorkspaceLocations.VERSION, getValue( pom, ReadWorkspaceLocations.PARENT_VERSION, |
349 | |
null ) ); |
350 | 0 | String packaging = getValue( pom, ReadWorkspaceLocations.PACKAGING, "jar" ); |
351 | |
|
352 | 0 | logger.debug( "found workspace artefact " + group + ":" + artifact + ":" + version + " " + packaging + " (" |
353 | |
+ eclipseProjectName + ")" + " -> " + projectLocation.getAbsolutePath() ); |
354 | 0 | return new IdeDependency( group, artifact, version, packaging, true, false, false, false, false, null, |
355 | |
packaging, false, null, 0, eclipseProjectName ); |
356 | |
} |
357 | |
else |
358 | |
{ |
359 | 0 | logger.debug( "ignored workspace project NO pom available " + projectLocation.getAbsolutePath() ); |
360 | 0 | return null; |
361 | |
} |
362 | |
} |
363 | |
|
364 | |
HashMap readDefinedServers( WorkspaceConfiguration workspaceConfiguration, Log logger ) |
365 | |
{ |
366 | 4 | HashMap detectedRuntimes = new HashMap(); |
367 | 4 | if ( workspaceConfiguration.getWorkspaceDirectory() != null ) |
368 | |
{ |
369 | 4 | Xpp3Dom runtimesElement = null; |
370 | |
try |
371 | |
{ |
372 | 4 | File prefs = |
373 | |
new File( workspaceConfiguration.getWorkspaceDirectory(), |
374 | |
ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_SERVER_PREFS ); |
375 | 4 | if ( prefs.exists() ) |
376 | |
{ |
377 | 0 | Properties properties = new Properties(); |
378 | 0 | properties.load( new FileInputStream( prefs ) ); |
379 | 0 | String runtimes = |
380 | |
properties.getProperty( ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_PREFS_RUNTIMES_KEY ); |
381 | 0 | if ( runtimes != null ) |
382 | |
{ |
383 | 0 | runtimesElement = Xpp3DomBuilder.build( new StringReader( runtimes ) ); |
384 | |
} |
385 | |
} |
386 | |
} |
387 | 0 | catch ( Exception e ) |
388 | |
{ |
389 | 0 | logger.error( "Could not read workspace wtp server runtimes preferences : " + e.getMessage() ); |
390 | 4 | } |
391 | |
|
392 | 4 | if ( runtimesElement != null ) |
393 | |
{ |
394 | 0 | Xpp3Dom[] runtimeArray = runtimesElement.getChildren( "runtime" ); |
395 | 0 | for ( int index = 0; runtimeArray != null && index < runtimeArray.length; index++ ) |
396 | |
{ |
397 | 0 | String id = runtimeArray[index].getAttribute( "id" ); |
398 | 0 | String name = runtimeArray[index].getAttribute( "name" ); |
399 | 0 | if ( detectedRuntimes.isEmpty() ) |
400 | |
{ |
401 | 0 | logger.debug( "Using WTP runtime with id: \"" + id + "\" as default runtime" ); |
402 | 0 | detectedRuntimes.put( "", id ); |
403 | |
} |
404 | 0 | detectedRuntimes.put( id, name ); |
405 | 0 | logger.debug( "Detected WTP runtime with id: \"" + id + "\" and name: \"" + name + "\"" ); |
406 | |
} |
407 | |
} |
408 | |
} |
409 | 4 | return detectedRuntimes; |
410 | |
} |
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
private HashMap readAvailableJREs( File workspaceLocation, Log logger ) |
421 | |
{ |
422 | |
Xpp3Dom vms; |
423 | |
try |
424 | |
{ |
425 | 0 | File prefs = |
426 | |
new File( workspaceLocation, |
427 | |
ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_LAUNCHING_PREFS ); |
428 | 0 | if ( !prefs.exists() ) |
429 | |
{ |
430 | 0 | return null; |
431 | |
} |
432 | 0 | Properties properties = new Properties(); |
433 | 0 | properties.load( new FileInputStream( prefs ) ); |
434 | 0 | vms = |
435 | |
Xpp3DomBuilder.build( new StringReader( |
436 | |
properties.getProperty( ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RUNTIME_PREFS_VM_KEY ) ) ); |
437 | |
} |
438 | 0 | catch ( Exception e ) |
439 | |
{ |
440 | 0 | logger.error( "Could not read workspace JRE preferences", e ); |
441 | 0 | return null; |
442 | 0 | } |
443 | |
|
444 | 0 | HashMap jreMap = new HashMap(); |
445 | 0 | jreMap.put( "1.2", CLASSPATHENTRY_STANDARD + "J2SE-1.2" ); |
446 | 0 | jreMap.put( "1.3", CLASSPATHENTRY_STANDARD + "J2SE-1.3" ); |
447 | 0 | jreMap.put( "1.4", CLASSPATHENTRY_STANDARD + "J2SE-1.4" ); |
448 | 0 | jreMap.put( "1.5", CLASSPATHENTRY_STANDARD + "J2SE-1.5" ); |
449 | 0 | jreMap.put( "5", jreMap.get( "1.5" ) ); |
450 | 0 | jreMap.put( "1.6", CLASSPATHENTRY_STANDARD + "JavaSE-1.6" ); |
451 | 0 | jreMap.put( "6", jreMap.get( "1.6" ) ); |
452 | 0 | String defaultJRE = vms.getAttribute( "defaultVM" ).trim(); |
453 | 0 | Xpp3Dom[] vmTypes = vms.getChildren( "vmType" ); |
454 | 0 | for ( int vmTypeIndex = 0; vmTypeIndex < vmTypes.length; vmTypeIndex++ ) |
455 | |
{ |
456 | 0 | String typeId = vmTypes[vmTypeIndex].getAttribute( "id" ); |
457 | 0 | Xpp3Dom[] vm = vmTypes[vmTypeIndex].getChildren( "vm" ); |
458 | 0 | for ( int vmIndex = 0; vmIndex < vm.length; vmIndex++ ) |
459 | |
{ |
460 | |
try |
461 | |
{ |
462 | 0 | String path = vm[vmIndex].getAttribute( "path" ); |
463 | 0 | String name = vm[vmIndex].getAttribute( "name" ); |
464 | 0 | String vmId = vm[vmIndex].getAttribute( "id" ).trim(); |
465 | 0 | String classpathEntry = |
466 | |
MessageFormat.format( ReadWorkspaceLocations.CLASSPATHENTRY_FORMAT, |
467 | |
new Object[] { typeId, name } ); |
468 | 0 | String jrePath = new File( path ).getCanonicalPath(); |
469 | 0 | File rtJarFile = new File( new File( jrePath ), "jre/lib/rt.jar" ); |
470 | 0 | if ( !rtJarFile.exists() ) |
471 | |
{ |
472 | 0 | logger.warn( Messages.getString( "EclipsePlugin.invalidvminworkspace", jrePath ) ); |
473 | 0 | continue; |
474 | |
} |
475 | 0 | JarFile rtJar = new JarFile( rtJarFile ); |
476 | 0 | String version = rtJar.getManifest().getMainAttributes().getValue( "Specification-Version" ); |
477 | 0 | if ( defaultJRE.endsWith( "," + vmId ) ) |
478 | |
{ |
479 | 0 | jreMap.put( jrePath, ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT ); |
480 | 0 | jreMap.put( version, ReadWorkspaceLocations.CLASSPATHENTRY_DEFAULT ); |
481 | 0 | logger.debug( "Default Classpath Container version: " + version + " location: " + jrePath ); |
482 | |
} |
483 | 0 | else if ( !jreMap.containsKey( jrePath ) ) |
484 | |
{ |
485 | 0 | if ( !jreMap.containsKey( version ) ) |
486 | |
{ |
487 | 0 | jreMap.put( version, classpathEntry ); |
488 | |
} |
489 | 0 | jreMap.put( jrePath, classpathEntry ); |
490 | 0 | logger.debug( "Additional Classpath Container version: " + version + " " + classpathEntry |
491 | |
+ " location: " + jrePath ); |
492 | |
} |
493 | |
else |
494 | |
{ |
495 | 0 | logger.debug( "Ignored (duplicated) additional Classpath Container version: " + version + " " |
496 | |
+ classpathEntry + " location: " + jrePath ); |
497 | |
} |
498 | |
} |
499 | 0 | catch ( IOException e ) |
500 | |
{ |
501 | 0 | logger.warn( "Could not interpret entry: " + vm[vmIndex].toString() ); |
502 | 0 | } |
503 | |
} |
504 | |
} |
505 | 0 | return jreMap; |
506 | |
} |
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
|
512 | |
|
513 | |
|
514 | |
private void readWorkspace( WorkspaceConfiguration workspaceConfiguration, Log logger ) |
515 | |
{ |
516 | 0 | ArrayList dependencies = new ArrayList(); |
517 | 0 | if ( workspaceConfiguration.getWorkspaceDirectory() != null ) |
518 | |
{ |
519 | 0 | File workspace = |
520 | |
new File( workspaceConfiguration.getWorkspaceDirectory(), |
521 | |
ReadWorkspaceLocations.METADATA_PLUGINS_ORG_ECLIPSE_CORE_RESOURCES_PROJECTS ); |
522 | |
|
523 | 0 | File[] directories = workspace.listFiles(); |
524 | 0 | for ( int index = 0; directories != null && index < directories.length; index++ ) |
525 | |
{ |
526 | 0 | File project = directories[index]; |
527 | 0 | if ( project.isDirectory() ) |
528 | |
{ |
529 | |
try |
530 | |
{ |
531 | 0 | File projectLocation = |
532 | |
getProjectLocation( workspaceConfiguration.getWorkspaceDirectory(), project ); |
533 | 0 | if ( projectLocation != null ) |
534 | |
{ |
535 | 0 | logger.debug( "read workpsace project " + projectLocation ); |
536 | 0 | IdeDependency ideDependency = readArtefact( projectLocation, logger ); |
537 | 0 | if ( ideDependency != null ) |
538 | |
{ |
539 | 0 | dependencies.add( ideDependency ); |
540 | |
} |
541 | |
} |
542 | |
} |
543 | 0 | catch ( Exception e ) |
544 | |
{ |
545 | 0 | logger.warn( "could not read workspace project:" + project, e ); |
546 | 0 | } |
547 | |
} |
548 | |
} |
549 | |
} |
550 | 0 | logger.debug( dependencies.size() + " from workspace " + workspaceConfiguration.getWorkspaceDirectory() ); |
551 | 0 | workspaceConfiguration.setWorkspaceArtefacts( (IdeDependency[]) dependencies.toArray( new IdeDependency[dependencies.size()] ) ); |
552 | 0 | } |
553 | |
} |