配置 sbt 项目以在“sbt run"中包含外部 Main 方法; [英] Configuring sbt project to include external Main methods in "sbt run"

查看:51
本文介绍了配置 sbt 项目以在“sbt run"中包含外部 Main 方法;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常会创建一个依赖于外部 jar 的 sbt 项目,并打算使用外部 jar 中的 Main 方法运行.目前,我只是使用run-main xxx"运行它,但我更希望能够在 sbt 提供的 run() 选项列表中包含 Main 方法.是否有捷径可寻?或者是包含一个作为 run-main xxx 别名的 sbt 任务的最佳选择?

It's very common for me to create an sbt project that depends on an external jar and is intended to be run with a Main method from the external jar. At the moment, I just run it using "run-main xxx" but I'd much prefer to be able to include the Main method in the list of run() options provided by sbt. Is there an easy way to do this? Or is the best option to include an sbt task that serves as an alias for run-main xxx?

推荐答案

主要类的列表收集在 discoveredMainClasses 中,您可以将其转换为显式添加自己的:

The list of main classes is collected in discoveredMainClasses and you can transform that to add your own explicitly:

discoveredMainClasses in Compile += "org.example.Main"

这篇关于配置 sbt 项目以在“sbt run"中包含外部 Main 方法;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆