Share this page to your:

As part of picking up some Kotlin skills I needed to build a jar library file with Kotlin source files. I'm coming from a Java/Maven/Eclipse skill set which I know pretty well and my Kotlin tool chain involves Gradle and AndroidStudio, derived from IntelliJ. So there is quite a lot different.

Still, the task is fundamentally the same.

  • Compile the source into .class files
  • Add the .class files to a .jar file
  • Add manifest details to the jar file
  • Get a pom.xml file somehow (it is manually created for Maven but generated here)
  • Create a source jar file and a javadocs jar file
  • Send all those to a local Maven repository
  • Publish to Maven Central

Maven Central has particular requirements for publishing such as supplying source, javadocs and signing everything. These are all reasonable, but doing them for Kotlin is different. I found lots of examples but nothing that took me through the whole process, whcih turns out to be reasonably easy once you know. Also there have been some changes to the process so I went down rat holes working with things that have been superseded and adding solutions to problems that are no longer there. The result is this library and the build/publish setup is tested and working and fairly simple. Lots of people have done a lot of work to make it this easy, so the credit for this goes to them, including but not limited to:

Previous Post Next Post