Let say I have a file listofjars.txt
, which contain location of .jar
files on my local file system
lib/jarfile1.jar
lib/jarfile2.jar
Now I want to read this file and use it during compilation of my project as classpath, how this can be done using 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); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.