Discovery of unresolved plug-in dependencies in eclipse

Source: Internet
Author: User
Tags requires

Problems encountered

Suppose we want to use a specific plug-in in Eclipse and have performed all the necessary actions, include it in the plug-in's manifest file, and declare it as a dependent file. But the system does not load this plugin, so we will be stuck here, software development can not continue to progress.

Does it sound familiar? If so, you may have spent a lot of time and effort looking at a lot of plugin.xml files to find out which specific plug-ins Eclipse might not have loaded. You may also have attempted to use the Plug-in dependencies view provided by the Eclipse PDE project, and you will find that the only work of this view is simply to display plug-ins that have been successfully loaded. Unfortunately, the problematic plug-ins are probably not part of the plug-in that was successfully loaded.

What should we do to make sure that Eclipse does not find or load a specific plug-in? Instead of manually traversing each plugin.xml file, we consider automatically implementing this search function. To automate the search, we need to understand how Eclipse saves its own plug-ins and how to find links to other plug-ins that are saved on disk. Based on this knowledge, we may want to write our own code to create a plug-in dependency traversal program, or use the generic Dependency Walker plugin given in this article. The "Downloads" section of this article gives the source code for this example.

Getting Started: Understanding plug-in dependencies and Eclipse's plug-in chain

Plug-in dependencies

The Eclipse plug-in is a software module that provides functionality that other plug-ins can use. If plug-in a requires plug-in B to work properly, then we say a depends on B. This dependency also means that plug-in A does not function unless plug-in B has been successfully loaded. Sometimes, plug-in B may also rely on Plug-ins C, D, E, which makes it even more uncomfortable that each of these plug-ins may depend on other plug-ins. This chain of dependence is easy to form hundreds of plug-ins linked together. There is no doubt that if any of the plug-ins in this chain cannot be loaded successfully, the plug-ins that depend on it may be problematic.

The plugin manifest file Plugin.xml describes each plug-in. This XML file contains a section that declares dependencies or requirements for other plug-ins. In Listing 1, this dependency is declared in the section in the Plugin.xml file that is represented in bold.


Listing 1. Plugin.xml file
<?xml version="1.0" encoding="UTF-8" ?> 
<?eclipse version="3.0"?> 
<plugin id="org.eclipse.draw2d" name="Draw2d" version="3.0.0" 
provider-name="Eclipse.org"> 
<runtime> 
 <library name="draw2d.jar"> 
 <export name="*" /> 
 <packages prefixes="org.eclipse.draw2d" /> 
 </library> 
</runtime> 
<requires> 
 <import plugin="org.eclipse.swt" export="true" /> 
 <import plugin="org.eclipse.core.runtime" /> 
</requires> 
</plugin> 

Note the <import plugin= "plugin id"/> Declaration embedded in the <requires> </requires> section. The example in Listing 1 shows that this plug-in ID org.eclipse.draw2d relies on plug-ins with IDs ORG.ECLIPSE.SWT and Org.eclipse.core.runtime.

Plug-in chain

When we use the Java™ technology platform in Eclipse to develop software, the system actually compiles the source code based on the target platform that you choose. You can specify the location of the target platform in Window > Preferences > Plug-in Development > Target Platform. This target platform has an eclipse copy of itself in <targetplatform>\eclipse. To resolve these dependencies for your code, look for the required plug-ins from two places:

Eclipse plug-in in the <targetplatform>\eclipse\plugins folder

The link plug-in that the. link file points to in the <targetplatform>\eclipse\links folder

Programmers often refer to the second place as the Links folder. The Links folder contains 0 or more files, and the file name usually ends with a ". Link" extension. These files contain links to information that you can use to locate the link plug-ins on disk where you can find them.

Each. link file has a keyword-value pair, which is formatted as path=location. (for example, there may be many. link files in the Links folder C:\eclipse\links, one of which may be named Com.ibm.indiver.dependencywalker.link.) The only line in this file may be similar to Path=c:\myplugins\dependencywalker. The. link file directs Eclipse to the specified location and looks for more available plug-ins in the \eclipse\plugins folder.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.