gpt4 book ai didi

org.onosproject.yang.compiler.utils.io.impl.YangFileScanner.getJavaFiles()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 12:21:31 26 4
gpt4 key购买 nike

本文整理了Java中org.onosproject.yang.compiler.utils.io.impl.YangFileScanner.getJavaFiles()方法的一些代码示例,展示了YangFileScanner.getJavaFiles()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangFileScanner.getJavaFiles()方法的具体详情如下:
包路径:org.onosproject.yang.compiler.utils.io.impl.YangFileScanner
类名称:YangFileScanner
方法名:getJavaFiles

YangFileScanner.getJavaFiles介绍

[英]Returns the list of java files.
[中]返回java文件的列表。

代码示例

代码示例来源:origin: org.onosproject/onos-yang-compiler-tool

/**
 * Adds all generated java class paths to YANG model.
 *
 * @param codeGenDir code gen directory.
 * @throws IOException when fails to do IO operations
 */
private void processGeneratedCode(String codeGenDir) throws IOException {
  List<String> files = getJavaFiles(codeGenDir);
  for (String file : files) {
    genJavaPath.add(Paths.get(file));
  }
}

代码示例来源:origin: org.onosproject/onos-yang-compiler-utils

/**
   * TODO: delete me, it is not part of config, it needs to be updated for
   * test scripts
   * Compiles the generated code for unit tests.
   *
   * @param dir1 directory path
   * @throws IOException when generated code has compilation errors.
   */
  @SuppressWarnings("unchecked")
  public static void compileCode(String dir1) throws IOException {
    String classpath = System.getProperty("java.class.path");
    List<String> optionList = new ArrayList<>();
    optionList.addAll(Arrays.asList("-classpath", classpath));

    List<String> files = YangFileScanner.getJavaFiles(dir1);
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager manager = compiler.getStandardFileManager(null, null, null);
    Iterable fileObjects = manager.getJavaFileObjectsFromStrings(files);
    JavaCompiler.CompilationTask task = compiler.getTask(null, null,
                               null, optionList, null,
                               fileObjects);

    boolean failOnError = !task.call();
    manager.close();
    if (failOnError) {
      throw new IOException("Yang Error : compilation errors in " +
                     "generated code.");
    }
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com