java - How to read the dependencies from an eclipse .classpath in gradle? -
here example of eclipse .classpath
file
<?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>
in gradle automatically add these dependencies.
is there plugin ? (i know write own method parse xml looking general way)
i didn't test this:
//init classpath file def classpathfile = file('.classpath') //parse xml def cpxml = new xmlparser().parse(classpathfile) //find lib entries def libpaths= [] cpxml.classpathentry.each { if('lib' == it.@kind) { libpaths.add(project.projectdir.parentfile.absolutepath + it.@path) } } dependencies{ compile files(libpaths) }
Comments
Post a Comment