简体   繁体   English

如何将位于根文件夹中的jar文件添加到sbt中的库依赖项

[英]How to add a jar file located in root folder to library dependency in sbt

I have a case where I need to a jar file located in root folder of the project. 我有一个需要在项目根文件夹中的jar文件的情况。

在此处输入图片说明 I have tried the below : 我尝试了以下方法:

"ccp.mts.test" % "mts-test_2.12-0.2" % "2.0" from "/mts-test_2.12-0.2.jar"

It did not work. 这没用。 Then I tried like below : 然后我尝试如下:

unmanagedJars in Compile += file("lib/mts-test_2.12-0.2.jar")

This also didn't work. 这也没有用。

How can I do it? 我该怎么做?

You did not specify the file protocol. 您未指定file协议。 Try the following 尝试以下

libraryDependencies += "org.aspectj" % "aspectjrt" % "1.9.2" from ("file://./aspectjrt-1.9.2.jar")

EDIT 编辑

I am modifying my answer based on your comment. 我正在根据您的评论修改我的答案。

In order to provide the absolute path, you can use the following code snippet 为了提供绝对路径,您可以使用以下代码段

val currentDirectory = new java.io.File(".").getCanonicalPath
libraryDependencies += "org.aspectj" % "aspectjrt" % "1.9.2" from ("file://" + currentDirectory + "/aspectjrt-1.9.2.jar")

Under Windows, a work-around is to go to C:\\Users\\myuser\\.ivy2\\cache\\ccp.mts.test\\mts-test\\ivydata-2.8.0.properties (change myuser and ivydata-2.8.0 as appropritate). 在Windows下,解决方法是转到C:\\Users\\myuser\\.ivy2\\cache\\ccp.mts.test\\mts-test\\ivydata-2.8.0.properties (将myuserivydata-2.8.0更改为适当)。 Then edit the file which should look something like this: 然后编辑看起来像这样的文件:

artifact\:ccp.mts.test\#jar\#jar\#2009603053.location=\\mydirectory\\lib\\mts-test_2.12-0.2.jar
artifact\:ccp.mts.test\#jar\#jar\#2009603053.exists=true
artifact\:ccp.mts.test\#jar\#jar\#2009603053.is-local=true
resolver=sbt-chain

and change the first line to 并将第一行更改为

artifact\:ccp.mts.test\#jar\#jar\#2009603053.location=C\:\\mydirectory\\lib\\mts-test_2.12-0.2.jar

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

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