使用eclipse-resource-api插件开发遍历maven项目的依赖罐

问题描述

我有一个Maven项目。我想遍历其依赖项jar项目并读取其中的一些属性文件。 使用eclipse资源api,我可以在工作区中获取IProject实例并访问其类路径文件

Class-path具有以下结构。

    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLAsspATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
            <attribute name="org.eclipse.jst.component.nondependency" value=""/>
        </attributes>
    </classpathentry>

我如何从中提取出实际的依赖罐位置?

我原本希望这样的事情

<classpath>
 <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
 <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
</classpath>

2。还是有比这更好的方法来以编程方式读取maven依赖罐?

解决方法

getResolvedClasspath的{​​{1}}方法处理解析容器:

IJavaProject

JavaDoc说:

这是一个辅助方法,返回已解析的类路径。 项目作为简单(非变量,非容器)类路径的列表 条目。所有的classpath变量和classpath容器条目 项目的原始类路径将被简单的类路径替换 他们解决的条目。