• Atitit java读取堵塞cmd命令行返回结果 java read maven 主要原理是另外线程读取标准流,错误流。。 回显增加out头,这样发布区分errstream和stdstream的


    Atitit java读取堵塞cmd命令行返回结果 java read maven

     

     

    主要原理是另外线程读取标准流,错误流。。

    回显增加out头,这样发布区分errstream和stdstream的输出

     

    /bookmarksHtmlEverythingIndexPrj/src/aOPtool/preSvr_adminPubScrpt2publishtool2.java

    //maven

    String mvnString="Z:\\soft\\apache-maven-3.5.4-bin\\apache-maven-3.5.4\\bin\\mvn.cmd";

    String cmdString = mvnString+"    -f G:\\0ttapi\\tt-api\\com-tt-admin\\pom_prod.xml install";

    System.out.println(cmdString);

    Process process = Runtime.getRuntime().exec(cmdString);

    InputStream inputStream = process.getInputStream();

    // 消费掉IO流,防止程序被阻塞卡死

    printStream(inputStream,"stdstream:>");

     

    // 消费掉IO流,防止程序被阻塞卡死

    printStream(process.getErrorStream(),"errstream:>");

     

     

     

     

    private static void printStream(InputStream inputStream, String outtag) {

    new Thread(new Runnable() {

     

    @Override

    public void run() {

    InputStreamReader isr;

    try {

    isr = new InputStreamReader(inputStream, "utf8");

     

    BufferedReader br = new BufferedReader(isr);

    String line = null;

     

    while ((line = br.readLine()) != null)

    System.out.println(outtag+""+line);

     

    } catch (Exception e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

     

    }

    }).start();

    }

    stdstream:>[INFO] Scanning for projects...

    stdstream:>[WARNING]

    stdstream:>[WARNING] Some problems were encountered while building the effective model for ttadmingroupId:tt-admin:war:1.1

    stdstream:>[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 96, column 12

    stdstream:>[WARNING]

    stdstream:>[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.

    stdstream:>[WARNING]

    stdstream:>[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

    stdstream:>[WARNING]

    stdstream:>[INFO]

    stdstream:>[INFO] ----------------------< ttadmingroupId:tt-admin >-----------------------

    stdstream:>[INFO] Building tt-admin 1.1

    stdstream:>[INFO] --------------------------------[ war ]---------------------------------

    stdstream:>[INFO]

    stdstream:>[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tt-admin ---

    stdstream:>[INFO] Using 'UTF-8' encoding to copy filtered resources.

    stdstream:>[INFO] Copying 655 resources to G:\0ttapi\tt-api\com-tt-admin/target/admin

    stdstream:>[INFO] Copying 655 resources to G:\0ttapi\tt-api\com-tt-admin/target/admin/WEB-INF/classes

    stdstream:>[INFO] Copying 851 resources to G:\0ttapi\tt-api\com-tt-admin/target/admin/WEB-INF/classes

    stdstream:>[INFO] Copying 136 resources to G:\0ttapi\tt-api\com-tt-admin/target/admin/WEB-INF/lib

    stdstream:>[INFO] Copying 1 resource to G:\0ttapi\tt-api\com-tt-admin/target/admin/WEB-INF/lib

    stdstream:>[INFO] Copying 1 resource to G:\0ttapi\tt-api\com-tt-admin/target/admin/WEB-INF/lib

    stdstream:>[INFO] Copying 1 resource to G:\0ttapi\tt-api\com-tt-admin/target/admin/WEB-INF/lib

    stdstream:>[INFO] Copying 6 resources

    stdstream:>[INFO] Copying 0 resource

    stdstream:>[INFO]

    stdstream:>[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tt-admin ---

    stdstream:>[INFO] Nothing to compile - all classes are up to date

    stdstream:>[INFO]

    stdstream:>[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ tt-admin ---

    stdstream:>[INFO] Using 'UTF-8' encoding to copy filtered resources.

    stdstream:>[INFO] skip non existing resourceDirectory G:\0ttapi\tt-api\com-tt-admin\src\test\resources

    stdstream:>[INFO]

    stdstream:>[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ tt-admin ---

    stdstream:>[INFO] Nothing to compile - all classes are up to date

    stdstream:>[INFO]

    stdstream:>[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ tt-admin ---

    stdstream:>[INFO]

    stdstream:>[INFO] --- maven-war-plugin:2.6:war (default-war) @ tt-admin ---

    stdstream:>[INFO] Packaging webapp

    stdstream:>[INFO] Assembling webapp [tt-admin] in [G:\0ttapi\tt-api\com-tt-admin\target\admin_prod]

    stdstream:>[INFO] Processing war project

    stdstream:>[INFO] Copying webapp resources [G:\0ttapi\tt-api\com-tt-admin\src\main\webapp]

    stdstream:>[INFO] Webapp assembled in [4985 msecs]

    stdstream:>[INFO] Building war: G:\0ttapi\tt-api\com-tt-admin\target\admin_prod.war

    stdstream:>[INFO]

    stdstream:>[INFO] --- maven-install-plugin:2.4:install (default-install) @ tt-admin ---

    stdstream:>[INFO] Installing G:\0ttapi\tt-api\com-tt-admin\target\admin_prod.war to G:\wjh\project\mavenRepository\ttadmingroupId\tt-admin\1.1\tt-admin-1.1.war

    stdstream:>[INFO] Installing G:\0ttapi\tt-api\com-tt-admin\pom_prod.xml to G:\wjh\project\mavenRepository\ttadmingroupId\tt-admin\1.1\tt-admin-1.1.pom

    stdstream:>[INFO] ------------------------------------------------------------------------

    stdstream:>[INFO] BUILD SUCCESS

    stdstream:>[INFO] ------------------------------------------------------------------------

    stdstream:>[INFO] Total time: 15.301 s

    stdstream:>[INFO] Finished at: 2019-04-01T20:13:21+08:00

    stdstream:>[INFO]

  • 相关阅读:
    css
    团队介绍
    day4
    线段树懒标记
    P2014选课
    P2015
    扩展欧几里得(exgcd)求解不定方程/求逆元
    transform和tolower
    快读
    bzoj2118
  • 原文地址:https://www.cnblogs.com/attilax/p/15197368.html
Copyright © 2020-2023  润新知