/** * Find relate proto files. * * @param file the file * @param dependencyNames the dependency names * @return the list * @throws IOException Signals that an I/O exception has occurred. */ private static List<ProtoFile> findRelateProtoFiles(File file, Set<String> dependencyNames) throws IOException { LinkedList<ProtoFile> protoFiles = new LinkedList<ProtoFile>(); ProtoFile protoFile = ProtoSchemaParser.parse(file); protoFiles.addFirst(protoFile); String parent = file.getParent(); // parse dependency, to find all PROTO file if using import command List<String> dependencies = protoFile.getDependencies(); if (dependencies != null && !dependencies.isEmpty()) { for (String fn : dependencies) { if (dependencyNames.contains(fn)) { continue; } File dependencyFile = new File(parent, fn); protoFiles.addAll(findRelateProtoFiles(dependencyFile, dependencyNames)); } } return protoFiles; }
/** * Do create pro. * * @param file the file * @param multi the multi * @param debug the debug * @param path the path * @param generateSouceOnly the generate souce only * @param sourceOutputDir the source output dir * @param cds the cds * @param compiledClass the compiled class * @param isUniName the is uni name * @return the map * @throws IOException Signals that an I/O exception has occurred. */ private static Map<String, IDLProxyObject> doCreatePro(File file, boolean multi, boolean debug, File path, boolean generateSouceOnly, File sourceOutputDir, List<CodeDependent> cds, Set<String> compiledClass, boolean isUniName) throws IOException { checkDirectory(generateSouceOnly, sourceOutputDir); // to find all PROTO file if using import command List<ProtoFile> protoFiles = findRelateProtoFiles(file, new HashSet<String>()); Collections.reverse(protoFiles); return doCreatePro(protoFiles, multi, debug, path, generateSouceOnly, sourceOutputDir, cds, compiledClass, new HashMap<String, String>(), isUniName); }