Why no package manager for Kotlin (or java)?


#1

Hello guys,

I’ve just started to learn Kotlin from PHP community with no Java background. I’m trying to find out something like composer in PHP or npm or yarn in NodeJS, those packages dependency management tool in Kotlin (or java, actually I don’t care about java…).
I found a post in StackOverflow, it seems such tool in java world is maven. But I can not figure out what it really does, without saying they use gradle nowadays.
I mean I want a tool:
<Tool> search <keyword> can list me libraries contains <keyword>
<Tool> show <package> can show me the <package> details with versions list
<Tool> install <package>@<version> can check dependencies and install the <package> automatically for the specified <version>

And for now it seems in Java world (Kotlin), I should write down:

dependencies {
    compile "org.jetbrains.anko:anko:$anko_version"
}

by hand, and try to figure out $anko_version by myself. I don’t see it is wisdom (or maybe I don’t know the convenient way.)

It seems I didn’t get the point.


#2

Sorry, WAT?
Java packaging and dependency management is two orders wuperior to anything you can find for JavaScript (I don’t know about PHP, but I think that situation there is not better). Kotlin mostly uses gradle as a build and dependency management tool (you can also use maven, but it is not recommended if you are not forced to do so).

In Java you do not have local environment where you can install packages, you use packages directly and they are downloaded on-demand, so install action does not make sense. For the rest see maven central.

The example you have shown is taken from gradle build script and version could be ommited. In this case the latest available version will be used, but of course it is not recommended since in that case you can’t control what version you use.


#3

I actually try to understand why there’s the difference. I mean, Ex.:
Ubuntu linux package: apt-get install
Python lib: pip install
Golang lib: go get
PHP lib: composer require
NodeJs lib: npm or yarn add

Maybe because java needs to compile the code. (But then I thought golang also need to do compiling…)
So maybe java has a lot and large libraries? (So that’s why it requires downloaded on-demand)

Not quite sure…


#4

I am not sure where your problem is. If you want to know the build/dependency tool for kotlin, it is gradle. The reason for maven support or just some basic build system in IDEs is simple. Maven is supported to make switching from java possible as a lot of Java projects are build using maven. And basic build systems in IDEs just make sense as it makes it a lot easier for people to learn programming without having to learn an entire build system as well.


#5

I think that that misunderstanding comes from the fact that Java does have dependency management and build system while JS, Python, etc do not.

Just believe me that after java, JS or Python “environment” looks like stone hammer. In gradle/maven you con not only have different dependency versions for different projects, but in fact different transitive dependency versions in the same project. And you do not need to think about “installing” packages at all. Just download the code and the build system manages dependencies itself.


#6

Java/Kotlin get compiled into packages (JARs, WARs, etc.). The build tools, like Gradle, do dependency management. You use versions in dependencies to prevent version updates from breaking your code. When you do a build, your dependencies get downloaded into a shared repository directory (~/.m2/repository by default). When you package up the build for deployment to a server, those dependencies get copied into the package, making it a stand-alone deployment.