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

别来无恙 提交于 2019-12-11 17:54:59

问题


I have a case where I need to a jar file located in root folder of the project.

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?


回答1:


You did not specify the file protocol. 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")



回答2:


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). 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


来源:https://stackoverflow.com/questions/54176184/how-to-add-a-jar-file-located-in-root-folder-to-library-dependency-in-sbt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!