简体   繁体   English

如何将罐子添加到sbt

[英]How to add jar to sbt

I want to build a sbt custom task where I want use "org.springframework.security.crypto.bcrypt.BCrypt". 我想构建一个sbt自定义任务,并在其中使用“ org.springframework.security.crypto.bcrypt.BCrypt”。

How can I make 我该怎么做

"org.springframework.security" % "spring-security-crypto" % "5.1.2.RELEASE"

available in the sbt classpath so that I can import "org.springframework.security.crypto.bcrypt.BCrypt" in "build.sbt"? 在sbt类路径中可用,以便我可以在“ build.sbt”中导入“ org.springframework.security.crypto.bcrypt.BCrypt”?

As @RajkumarNatarajan already mentioned, you can just create an SBT plugin , it is basically just another scala project that you then publish to a repository and latter uses it in your projects - this is useful if you need your task in many projects. 正如@RajkumarNatarajan已经提到的,您可以只创建一个SBT 插件 ,它基本上只是另一个scala项目,然后将其发布到存储库中,后者在您的项目中使用它-如果您在许多项目中需要执行任务,这将非常有用。

If you only need your task for one project, and do not want to create a plugin , you can add your dependencies in the project/build.sbt file , then create your task in the project/Task.scala file . 如果你只需要你的任务为一个项目,并且不希望创建一个插件 ,可以在添加依赖project/build.sbt 文件 ,然后创建在你的任务 project/Task.scala 文件 This way you can use your task in your main build.sbt file , the dependency will be available to your task, but will not be added to your project and will be available to your task. 这样,您可以在build.sbt文件中使用任务 ,该依赖关系将对您的任务可用,但不会被添加到您的项目中,并且对您的任务可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM