To *_*Kra 3 java eclipse classpath gradle
这是蚀.classpath文件的例子
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" output="bin/test" path="src/test/java"/>
<classpathentry kind="src" output="bin/test" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/slf4j-api-1.7.7.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/slf4j-log4j12-1.7.7.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/commons-collections4-4.0.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/commons-codec-1.6.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/commons-io-2.4.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/commons-cli-1.2.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/commons-net-3.3.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/commons-lang-2.4.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/opencsv-2.3.jar"/>
<classpathentry kind="lib" path="/kc-tools-thirdparty/lib/log4j-1.2.17.jar"/>
<classpathentry kind="output" path="bin/main"/>
</classpath>
Run Code Online (Sandbox Code Playgroud)
在gradle中,我想自动将它们添加到依赖项中。
是否有任何插件可以做到这一点?(我知道我可以编写自己的方法来解析XML,但我正在寻找一些通用方法)
我没有测试它,但是我会做这样的事情:
//Init classpath file
def classpathFile = file('.classpath')
//parse xml
def cpXml = new XmlParser().parse(classpathFile)
//find all lib entries
def libPaths= []
cpXml.classpathentry.each {
if('lib' == it.@kind) {
libPaths.add(project.projectDir.parentFile.absolutePath + it.@path)
}
}
dependencies{
compile files(libPaths)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
687 次 |
| 最近记录: |