【问题标题】:where is the main method in the sbt source code?sbt 源代码中的主要方法在哪里?
【发布时间】:2019-11-12 17:04:48
【问题描述】:

我克隆了sbt源代码,尝试研究,但找不到

def main

extends App 

即使在 sbt\main\src\main\scala\sbt\Main.scala 中

我搜索了所有的源文件,发现一些文件有main方法,但是所有这些文件都在测试目录中,我认为这些方法是sbt的主要方法

那么sbt的主要方法在哪里呢?谢谢!

【问题讨论】:

    标签: scala sbt


    【解决方案1】:

    如何在基于 *nix 的系统上快速找到它

    查找启动sbt的java进程的pid

    ps aux | grep java
    0:35.42 /usr/bin/java -Xms512m -Xmx3g -Xss2m -jar /.sbt/launchers/1.3.3/sbt-launch.jar shell
    
    

    这告诉你主类位于sbt-launch.jar jar 文件中

    向JVM发送信号3或使用jstack获取JVM的线程转储

     kill -3 xxxx
    

    这里是

        at sbt.xMain.run(Main.scala:39)
        at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:111)
        at xsbt.boot.Launch$.withContextLoader(Launch.scala:130)
        at xsbt.boot.Launch$.run(Launch.scala:111)
        at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:37)
        at xsbt.boot.Launch$.launch(Launch.scala:119)
        at xsbt.boot.Launch$.apply(Launch.scala:20)
        at xsbt.boot.Boot$.runImpl(Boot.scala:56)
        at xsbt.boot.Boot$.main(Boot.scala:18)
        at xsbt.boot.Boot.main(Boot.scala)
    

    【讨论】:

      【解决方案2】:

      我认为最终它是 sbt-launcher 中的主要方法

      https://github.com/sbt/launcher/blob/1.x/launcher-implementation/src/main/scala/xsbt/boot/Boot.scala

      来自主

      /** This class is the entry point for sbt. */
      final class xMain extends xsbti.AppMain { 
        ...
      }
      

      您可以看到它如何从启动器项目中扩展 AppMain。不过,我不确定实现这项工作所涉及的魔法。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-16
        • 2017-10-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-16
        • 1970-01-01
        相关资源
        最近更新 更多