scalaammonitecoursier

How to pin the version of a SNAPSHOT dependency in an Ammonite script


Ammonite can download dependencies from Maven repositories.

I'm using a SNAPSHOT dependency, and I'd like to use always the cached version, in order to avoid using possible untested newer versions. Is this possible?

I know that Ammonite uses lately Coursier and before Ivy, so some information I've found maybe outdated.

Some ideas I'm having is to install the current SNAPSHOT version in a local repository with another name.


Solution

  • Create a local .ivy2/local repository with the following directory structure:

    organization/moduleId/version/ivys
                                  jars
                                  poms
    

    Create a new ivy.xml inside ivys directory like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
        <info organisation="myorg" module="mymod" revision="someVersion" status="integration" e:scalaVersion="2.12" e:sbtVersion="0.13">
            <description>
            my module
            </description>
        </info>
        <configurations>
            <conf name="compile" visibility="public" description=""/>
            <conf name="runtime" visibility="public" description="" extends="compile"/>
            <conf name="test" visibility="public" description="" extends="runtime"/>
            <conf name="provided" visibility="public" description=""/>
            <conf name="optional" visibility="public" description=""/>
            <conf name="sources" visibility="public" description=""/>
            <conf name="docs" visibility="public" description=""/>
            <conf name="pom" visibility="public" description=""/>
        </configurations>
        <publications>
            <artifact name="sikulix2tigervnc" type="pom" ext="pom" conf="pom"/>
            <artifact name="sikulix2tigervnc" type="jar" ext="jar" conf="compile"/>
        </publications>
        <dependencies>
        </dependencies>
    </ivy-module>
    

    Place in the jars directory the *.jar with proper name and in poms the *.pom.

    Problem is that Coursier won't donwload transitive dependencies, so add extra import $ivy.....