Skip to content

Commit 3530bc0

Browse files
committed
fixed interface name generator to work with jarPaths, instead of jarDir
1 parent f8ad249 commit 3530bc0

File tree

1 file changed

+8
-36
lines changed
  • build/project-template-gradle/build-tools/android-static-binding-generator/interface-name-generator/src/main/java/com/ig

1 file changed

+8
-36
lines changed

build/project-template-gradle/build-tools/android-static-binding-generator/interface-name-generator/src/main/java/com/ig/GetInterfaceNames.java

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,22 @@ public class GetInterfaceNames {
1818

1919
public static void main(String[] args) throws IOException, ClassNotFoundException {
2020
currentDir = System.getProperty("user.dir");
21-
22-
String jarsDir = currentDir + "\\jars";
2321
String outputFileName = "interfaces-names.txt";
2422

23+
// System.out.println("inside: " + args);
2524
if (args != null) {
26-
27-
if(args.length > 0) {
28-
jarsDir = args[0];
25+
if(args.length < 1) {
26+
throw new IllegalArgumentException("There are no parameters passed!");
2927
}
30-
if(args.length > 1) {
31-
outputFileName = args[1];
32-
}
33-
}
34-
35-
if(!new File(jarsDir).exists()) {
36-
System.out.println("Please provide a valid dir with jars to parse! Default dir is '.\\jars'");
37-
System.exit(1);
3828
}
3929

40-
String[] pathsToJars = getAllFilesPaths(jarsDir);
41-
4230
PrintWriter out = ensureOutputFile(outputFileName);
4331

44-
for(String pathToJar : pathsToJars) {
45-
generateInterfaceNames(pathToJar, out);
32+
for(String pathToJar : args) {
33+
// System.out.println("\t+jar: " + pathToJar);
34+
if(pathToJar.endsWith(".jar")) {
35+
generateInterfaceNames(pathToJar, out);
36+
}
4637
}
4738

4839
out.close();
@@ -104,23 +95,4 @@ private static URLClassLoader getClassLoader(String pathToJar) throws MalformedU
10495
URLClassLoader cl = URLClassLoader.newInstance(urls);
10596
return cl;
10697
}
107-
108-
private static String[] getAllFilesPaths(String path) {
109-
File folder = new File(path);
110-
File[] listOfFiles = folder.listFiles();
111-
String[] paths = new String[listOfFiles.length];
112-
113-
for (int i = 0; i < listOfFiles.length; i++) {
114-
115-
if (listOfFiles[i].isFile()) {
116-
117-
if(listOfFiles[i].getName().indexOf(".jar") != -1) {
118-
paths[i] = listOfFiles[i].getAbsolutePath();
119-
}
120-
}
121-
}
122-
123-
return paths;
124-
}
125-
12698
}

0 commit comments

Comments
 (0)