Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import $ivy in Ammonite

Tags:

scala

ammonite

I need to import sikulixapi in an Ammonite script. I could be able to do so.

So if I do from the interactive console of Ammonite this:

@ 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

But jxgrabkey does exist in Maven.

This fails also:

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

I'm not using any HTTP proxy.

Other versions of sikulixapi have other problems:

@ 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

Tried with Ammonite 1.2.1, 1.3.3 and 1.4.0.

like image 593
david.perez Avatar asked Sep 19 '25 18:09

david.perez


2 Answers

jxgrabkey:jxgrabkey:1.0 exists on a Maven repository, but per your mvnrepository link, it's not on Maven Central, but at http://labs.consol.de/maven/repository (see the target of the POM and JAR links).

So that extra repository has to be added to the Ammonite session, like

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

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

Then the dependency can be added fine.

Note that I changed the protocol to https (http redirects to https, but protocol changing redirections aren't supported by coursier, which is the library that loads dependencies in Ammonite).

like image 64
Alex Archambault Avatar answered Sep 22 '25 09:09

Alex Archambault


Recent versions of ammonite offer simpler ways of adding repositories:

import $repo.`https://labs.consol.de/maven/repository`
like image 27
Pablo Francisco Pérez Hidalgo Avatar answered Sep 22 '25 11:09

Pablo Francisco Pérez Hidalgo