scala 进口$ivy in Ammonite

oknrviil  于 2023-08-05  发布在  Scala
关注(0)|答案(3)|浏览(109)

我需要在Ammonite脚本中导入sikulixapi。我可以做到。
所以如果我在Ammonite的交互式控制台上这样做:

@ import $ivy.`com.sikulix:sikulixapi:1.1.0` 
https://repo1.maven.org/maven2/com/sikulix/sikulixapi/1.1.0/sikulixapi-1.1.0.pom
  100,0% [##########] 5,3 KiB (37,6 KiB / s)
https://repo1.maven.org/maven2/com/nativelibs4java/bridj/0.6.2/bridj-0.6.2.pom
  100,0% [##########] 18,1 KiB (226,0 KiB / s)
https://repo1.maven.org/maven2/com/sikulix/sikulixlibslux/1.1.0/sikulixlibslux-1.1.0.pom
  100,0% [##########] 2,6 KiB (20,8 KiB / s)
https://repo1.maven.org/maven2/org/swinglabs/swing-layout/1.0.3/swing-layout-1.0.3.pom
  100,0% [##########] 858 B (6,5 KiB / s)
https://repo1.maven.org/maven2/com/nativelibs4java/nativelibs4java-parent/1.8/nativelibs4j…
  100,0% [##########] 16,8 KiB (204,3 KiB / s)
Failed to resolve ivy dependencies:
  jxgrabkey:jxgrabkey:1.0 
    not found: /home/jenkins/.ivy2/local/jxgrabkey/jxgrabkey/1.0/ivys/ivy.xml
    not found: https://repo1.maven.org/maven2/jxgrabkey/jxgrabkey/1.0/jxgrabkey-1.0.pom

字符串
但是jxgrabkey确实存在于Maven中。
这也失败了:

@ import $ivy.`jxgrabkey:jxgrabkey:1.0` 
Failed to resolve ivy dependencies:abkey/jxgrabkey/1.0/jxgrabkey-1.0.pom.sha1


我没有使用任何HTTP代理。
其他版本的sikulixapi还有其他问题:

@ import $ivy.`com.sikulix:sikulixapi:1.1.2` 
Failed to resolve ivy dependencies:
  com.sikulix:sikulix2tigervnc:2.0.0-SNAPSHOT 
    not found: /home/jenkins/.ivy2/local/com.sikulix/sikulix2tigervnc/2.0.0-SNAPSHOT/ivys/ivy.xml
    not found: https://repo1.maven.org/maven2/com/sikulix/sikulix2tigervnc/2.0.0-SNAPSHOT/sikulix2tigervnc-2.0.0-SNAPSHOT.pom
  com.github.vidstige:jadb:-v1.0-g94ebf38-23 
    not found: /home/jenkins/.ivy2/local/com.github.vidstige/jadb/-v1.0-g94ebf38-23/ivys/ivy.xml
    not found: https://repo1.maven.org/maven2/com/github/vidstige/jadb/-v1.0-g94ebf38-23/jadb--v1.0-g94ebf38-23.pom

@ import $ivy.`com.sikulix:sikulixapi:1.1.1` 
https://repo1.maven.org/maven2/com/sikulix/sikulixapi/1.1.1/sikulixapi-1.1.1.pom
100,0% [##########] 6,6 KiB (46,5 KiB / s)
https://repo1.maven.org/maven2/com/melloware/jintellitype/1.3.9/jintellitype-1.3.9.pom
100,0% [##########] 9,9 KiB (216,3 KiB / s)
Failed to resolve ivy dependencies:
  com.github.vidstige:jadb:-v1.0-g94ebf38-23 
    not found: /home/jenkins/.ivy2/local/com.github.vidstige/jadb/-v1.0-g94ebf38-23/ivys/ivy.xml
    not found: https://repo1.maven.org/maven2/com/github/vidstige/jadb/-v1.0-g94ebf38-23/jadb--v1.0-g94ebf38-23.pom


尝试使用Ammonite 1.2.1、1.3.3和1.4.0。

z5btuh9x

z5btuh9x1#

jxgrabkey:jxgrabkey:1.0存在于Maven存储库中,但根据your mvnrepository link,它不在Maven Central中,而是在http://labs.consol.de/maven/repository中(请参阅POM和JAR链接的目标)。
因此,必须将额外的存储库添加到Ammonite会话中,如

@ interp.repositories() ++= Seq(coursier.MavenRepository("https://labs.consol.de/maven/repository"))

@ import $ivy.`com.sikulix:sikulixapi:1.1.0`

字符串
然后可以精细地添加依赖性。
请注意,我将协议更改为https(http重定向为https,但coursier不支持协议更改重定向,coursier是在Ammonite中加载依赖项的库)。

af7jpaap

af7jpaap2#

ammonite的最新版本提供了更简单的添加存储库的方法:

import $repo.`https://labs.consol.de/maven/repository`

字符串

owfi6suc

owfi6suc3#

a3var答案正确。遵循相同的技术,我成功导入了sikulixapi 1.1.1:

interp.repositories() ++= Seq(coursier.MavenRepository("https://jitpack.io"))
import $ivy.`com.sikulix:sikulixapi:1.1.1`

字符串

相关问题