aedan
aedan

Reputation: 217

How make sbt use my jar from my local repository?

I am trying to install SBT in my Linux VM(CentOS) with a very strict security.

It can't access

I already extracted the SBT zip file and add the bin path to the environment variable.

As expected I can't run SBT.

[admin@xxx]$ sbt
Getting org.scala-sbt sbt 0.13.12 ...

:: problems summary ::
:::: WARNINGS
            module not found: org.scala-sbt#sbt;0.13.12

    ==== local: tried

      /home/admin/.ivy2/local/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml

      -- artifact org.scala-sbt#sbt;0.13.12!sbt.jar:

      /home/admin/.ivy2/local/org.scala-sbt/sbt/0.13.12/jars/sbt.jar

    ==== Maven Central: tried

      https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.pom

      -- artifact org.scala-sbt#sbt;0.13.12!sbt.jar:

      https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar

    ==== typesafe-ivy-releases: tried

      https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml

    ==== sbt-ivy-snapshots: tried

      https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml

            ::::::::::::::::::::::::::::::::::::::::::::::

            ::          UNRESOLVED DEPENDENCIES         ::

            ::::::::::::::::::::::::::::::::::::::::::::::

            :: org.scala-sbt#sbt;0.13.12: not found

            ::::::::::::::::::::::::::::::::::::::::::::::


:::: ERRORS
    Server access Error: Connection timed out url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.pom

    Server access Error: Connection timed out url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar

    Server access Error: Connection timed out url=https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml

    Server access Error: Connection timed out url=https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml


:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-sbt#sbt;0.13.12: not found
Error during sbt execution: Error retrieving required libraries
(see /home/admin/.sbt/boot/update.log for complete log)
Error: Could not retrieve sbt 0.13.12

I manage to make it use my repository by adding repositories file

repositories

[repositories]
  local
  my-maven-proxy-releases: http://nexuspro.company.com/nexus/service/local/repositories/

Then I run SBT command with this parameters:

sbt -Dsbt.repository.config=/sbt/conf/repositories

Now my problem is that SBT seems use default directory structure which is different from my repository.

<my repository>/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar

So my question now is how can I set SBT to use my jar? Maybe force it to use absolute path of my jar

<my repository>/sbt-0.13.12.jar

Upvotes: 3

Views: 4478

Answers (2)

aedan
aedan

Reputation: 217

This will be useful for you guys who have no internet connection but needs to use sbt.

This is based on thirstycrow's third option.

First you need to update your sbt in an environment with access to internet.

sbt update

If you need a certain version of sbt you need to edit your build.properties before calling sbt update

Then you copy your .ivy2\cache to to the target environment(no internet)

Then set your cache as your repository

repositories

[repositories]
local
cache: file://home/admin/.ivy2/cache, [organisation]/[module]/[type]s/[module]-[revision].[type], [organisation]/[module]/ivy-[revision].xml

Then call sbt with parameter pointing to your repository file

sbt -Dsbt.repository.config=/sbt/conf/repositories

Upvotes: 2

thirstycrow
thirstycrow

Reputation: 2824

A proper way of doing this is to proxy those two repositories with your company's private repository. I wonder whether the latest version of nexus has added support for proxying/serving ivy repositories. If not, you'll have to switch to artifactory.

An alternative is to proxy the required repositories with a locally installed artifactory, and make it available to your vm through an ssh tunnel. I played this trick when I did not have the privilege to manage the company repository.

If the above ideas do not work for you. The last chance is to build your project somewhere the required repositories can be accessed. And then copy the ~/.ivy directory to your virtual machine. That's where ivy stores the fetched artifacts.

Upvotes: 1

Related Questions