How do I use my own Kotlin library in a different IntelliJ project?

已回答

I am creating a library in IntelliJ and compiling it using Gradle. The library produces a `.jar` file in the `lib/build/libs/` folder which is my library. This is in its own project. Now, if I would like to use and try out the library in a different project, what's the best option for me to not have to manually copy over the `.jar` every time I make a change to the `.jar`?

评论操作 固定链接

> Now, if I would like to use and try out the library in a different project

You can set up these projects into a single Gradle multi module project and use the dependencies between Gradle projects. See

https://docs.gradle.org/current/userguide/multi_project_builds.html 

https://docs.gradle.org/current/userguide/declaring_dependencies_between_subprojects.html 

See also this Gradle tutorial: https://docs.gradle.org/current/samples/sample_building_java_applications_multi_project.html

 

Or you can publish this library to a remote/local repository and then use it from a different projects. Note that you will need to re-publish it each time when you want to use updated library in another projects. You can check this tutorial: https://www.jetbrains.com/help/idea/add-a-gradle-library-to-the-maven-repository.html

0

请先登录再写评论。