Is there a pip / easy_install for Scala? [closed]

扶醉桌前 提交于 2019-12-03 11:34:15

问题


I want to organize my Scala packages and love how Python solves this issue with pip.

Can you recommend a similar tool for the management of Scala packages?

EDIT: I am looking for an easy installation of new packages with all it's dependencies like

 >>> pip install <a_package> # installs a_package with all dependencies.

回答1:


The most directly similar is probably Scala Build Tool. Specifically, Library Dependencies. The Java ecosystem includes many libraries and build tools, Scala is built on Java. So you gain the ability to leverage things like -

  • Maven
  • Gradle
  • Scala Build Tool

Further, because everything is run inside a virtual machine; there is no "system" level install. You can start with your CLASSPATH and for more investigate class loading.

#!/bin/sh
# From http://www.scalaclass.com/node/10 - CLASSPATH
L=`dirname $0`/../lib
cp=`echo $L/*.jar|sed 's/ /:/g'`
exec scala -classpath "$cp" "$0" "$@"
!#
import com.my.Goodness
val goodness = new Goodness
world.hello



回答2:


Pythonistas install system wide packages which are then used by all of the python projects. This lead to a bunch of problems which virtualenv tries to solve. Scala guys and in general Java people have per-project definition which is written for dependency management tool -- either mvn (xml), sbt (scala), gradle (groovy), etc.

Most of these tools have system-wide cache, so usually it downloads some version of dependency only once, then puts it in a particular place on your disk. When you need to run/assemble your java or scala program it constructs so called CLASSPATH variable which is consists of patches to required libraries. Then CLASSPATH variable (aka PYTHONPATH in python world) is used by runtime environment to lookup required parts. Again, CLASSPATH varies a lot from project to project, whereas PYTHONPATH is quite constant. I do believe there are might be tools that do the very same job pip does, but it isn't accepted way in JVM world.



来源:https://stackoverflow.com/questions/19962443/is-there-a-pip-easy-install-for-scala

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