![](/img/trans.png)
[英]How to read the dependencies from an eclipse .classpath in gradle?
[英]How can I READ list of jars from a file and use it as classpath in Gradle?
假設我有一個文件listofjars.txt
,其中包含.jar
文件在本地文件系統上的位置
lib/jarfile1.jar
lib/jarfile2.jar
現在,我想讀取此文件並在將項目編譯為類路徑時使用它,如何使用Gradle做到這一點?
apply plugin: "java"; def List < String > list = new ArrayList < String > (); task readFile << { new File('jarfile.txt').eachLine { line - > list.add(line); } } dependencies() { compile files(list); } sourceSets { main { java { srcDir 'src'; } } } init { new File('jarfile.txt').eachLine { line - > if (!line.equals("")) list.add(line); }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.