如何从Eclipse classpathentry中读取所有JAR,其中kind =“con” [英] How to read all JARs from Eclipse classpathentry where kind="con"

查看:578
本文介绍了如何从Eclipse classpathentry中读取所有JAR,其中kind =“con”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含所有类路径条目的项目的.classpath文件。现在它有以下条目 -

 < classpathentry kind =conpath =org.eclipse.jdt.launching.JRE_CONTAINER /org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5\"> 
< / classpathentry>

现在,从这个条目,我想通过java代码找到与这个库相关联的所有jar以编程方式有没有办法阅读所有罐子?

解决方案

以下是调查运行Eclipse JEE Kepler的同时阅读2016年夏天检出的源代码,并在启动时调试Eclipse。 / p>

在您的工作区根文件夹中有一个文件.metadata.plugins\org.eclipse.jdt.core\variablesAndContainers.dat。
此文件由JavaModelManager从方法loadVariablesAndContainers读取。



以下是JavaModelManager的来源
https:// git。 eclipse.org/c/e4/org.eclipse.jdt.core.git/tree/model/org/eclipse/jdt/internal/core/JavaModelManager.java



在variablesAndContainers.dat中,我相信每个项目都有一个条目,每个项目都有一个容器。您可以在文件中看到容器名称为String。



流程继续到
JavaModelManager $ VariablesAndContainersLoadHelper.loadContainers(IJavaProject)



从这里,该文件读取类路径条目数的计数。对于每个条目,它将使用VariablesAndContainersLoadHelper.loadClasspathEntry方法读取容器。这将创建一个表示Java容器的类路径条目数组。这是作为JavaModelManager.PersistedClasspathContainer存储在内存中。



这是您创建独立应用程序时所要寻找的内容。
如果创建Eclipse插件,请检查JavaModelManager.getClasspathContainer的行为。



您必须学习代码,也可能调试大量Eclipse初创公司找出文件的整个格式。


I have a .classpath file of a project which contains all classpath entries. Now it has following entry-

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
</classpathentry>

Now, from this entry , I want to find all jars which are associated with this library through java code programatically ? Is there any way to read all jars?

解决方案

The following was investigated running Eclipse JEE Kepler while reading source code that was checked out summer 2016 and debugging Eclipse on startup.

In your workspace root folder there is a file .metadata.plugins\org.eclipse.jdt.core\variablesAndContainers.dat. This file is read by JavaModelManager from the method loadVariablesAndContainers.

Here is the source of JavaModelManager https://git.eclipse.org/c/e4/org.eclipse.jdt.core.git/tree/model/org/eclipse/jdt/internal/core/JavaModelManager.java

Within variablesAndContainers.dat, I believe there is an entry for each project, and each project has a container. You can see the container name as a String in the file.

Flow continues to JavaModelManager$VariablesAndContainersLoadHelper.loadContainers(IJavaProject)

From here, the file reads a count of the number of classpath entries. For each entry, it then reads the container with the method VariablesAndContainersLoadHelper.loadClasspathEntry. This creates an array of classpath entries which represents the Java container. This is held in memory as JavaModelManager.PersistedClasspathContainer.

This is what you are looking for if creating a standalone application. If creating an Eclipse plugin, examine the behavior of JavaModelManager.getClasspathContainer.

You'll have to study the code, and maybe debug a lot of Eclipse startups to figure out the whole format of the file.

这篇关于如何从Eclipse classpathentry中读取所有JAR,其中kind =“con”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆