The Kotlin Programming Language
Java Kotlin JavaScript HTML Protocol Buffer Lex
Latest commit 40ff7c6 Dec 9, 2016 @zarechenskiy zarechenskiy Fix test data
Permalink
Failed to load latest commit information.
.idea Allow to turn the first parameter of a SAM-converted lambda into the … Dec 9, 2016
android-studio Prepare building plugins modules against 1.8 JDK Apr 4, 2016
annotations Remove KotlinSignature annotations from project code Oct 13, 2015
ant CLI, Ant: add kotlin-reflect.jar to classpath by default, support "-n… Aug 9, 2016
build-common KT-12877: add JsNonModule with support on front-end Dec 3, 2016
compiler Kapt3: Fix '$' in function generic signatures (KT-15148) Dec 9, 2016
core Kapt3: Fix '$' in function generic signatures (KT-15148) Dec 9, 2016
eval4j Eval4J: loadClass should return prepared class, otherwise ClassNotPre… Aug 16, 2016
generators Allow to turn the first parameter of a SAM-converted lambda into the … Dec 9, 2016
gradle/wrapper add Gradle wrapper to project Nov 15, 2016
grammar Fix companion object definition in the grammar (KT-8566) Nov 10, 2016
idea-runner Prepare building plugins modules against 1.8 JDK Apr 4, 2016
idea Fix test data Dec 9, 2016
j2k Cleanup: remove empty primary constructor applied Dec 2, 2016
jps-plugin Rename KotlinVersion->KotlinCompilerVersion, move to module util.runtime Dec 7, 2016
js Adapt JS translator to able work with deprecated 'mod' operator Dec 9, 2016
lib Migrate build and project configuration to IntelliJ IDEA 12 (Leda) EAP Jul 25, 2012
libraries Kapt3: Allow to use ':' in annotation processor option value (KT-15139) Dec 9, 2016
license Introduce "-api-version" CLI option Oct 11, 2016
non-compiler-tests Enable tests in generators module Apr 14, 2016
plugins Kapt3, Minor: Sort stubs output in tests Dec 9, 2016
resources Add daemon client jar to libraries project Oct 12, 2016
spec-docs Minor, fix a few typos in NameResolution.adoc Apr 6, 2016
ultimate Minor: Add sam-with-receiver to Ultimate project classpath, fix cli p… Dec 9, 2016
.gitattributes Don't include test data in the language statistic for a repository Jun 1, 2015
.gitignore Misc: Extract kotlin-ultimate project Apr 9, 2016
ChangeLog.md Intentions: Convert function type receiver to parameter Dec 8, 2016
Kotlin.iml Add kotlin console repl Sep 21, 2015
ReadMe.md Update the pull request help link (#943) Aug 31, 2016
TeamCityBuild.xml Rename KotlinVersion->KotlinCompilerVersion, move to module util.runtime Dec 7, 2016
TeamCityRelay.xml Drop kotlin-bare-plugin (KT-11859) Sep 2, 2016
build.xml Minor: Add sam-with-receiver to Ultimate project classpath, fix cli p… Dec 9, 2016
common.xml Add tasks to download node.js (platform independently) and tasks to p… Oct 13, 2016
description description Nov 8, 2011
download_android_sdk.xml Download full copy of the Android SDK (needed to run the all Android … Apr 8, 2016
gradlew add Gradle wrapper to project Nov 15, 2016
gradlew.bat add Gradle wrapper to project Nov 15, 2016
jslib_files.xml JS: prototyping coroutines Nov 16, 2016
node_utils.xml Add tasks to download node.js (platform independently) and tasks to p… Oct 13, 2016
update_dependencies.xml Update proguard to 5.3 version Nov 14, 2016
upload_plugins.gradle fix build script Nov 15, 2016

ReadMe.md

TeamCity (simple build status) Maven Central GitHub license

Kotlin Programming Language

Welcome to Kotlin! Some handy links:

Editing Kotlin

Build environment requirements

In order to build Kotlin distribution you need to have:

  • Apache Ant 1.9.4 and higher
  • JDK 1.6, 1.7 and 1.8
  • Setup environment variables as following:

    JAVA_HOME="path to JDK 1.6"
    JDK_16="path to JDK 1.6"
    JDK_17="path to JDK 1.7"
    JDK_18="path to JDK 1.8"
    

Building

To build this project, first time you try to build you need to run this:

ant -f update_dependencies.xml

which will setup the dependencies on

  • intellij-core: is a part of command line compiler and contains only necessary APIs.
  • idea-full: is a full blown IntelliJ IDEA Community Edition to be used in former plugin module.

Then, you need to run

ant -f build.xml

which will build the binaries of the compiler and put them into the 'dist' directory. You may need to increase the heap size for Ant using ANT_OPTS.

OPTIONAL: Maven distribution is built separately, run

mvn package

from 'libraries' directory after building the compiler. Refer to libraries/ReadMe.md for details.

Working with the project in IntelliJ IDEA

The root kotlin project already has an IntelliJ IDEA project, you can just open it in IntelliJ IDEA.

You may need to set the Project SDK (File -> Project Structure -> Project). You may also need to add tools.jar to your SDK: File -> Project Structure -> SDKs -> -> Classpath, then choose the tools.jar in the JDK's lib directory.

If you are not dealing with Android, you may need to disable the Android Plugin in order to compile the project.

Since Kotlin project contains code written in Kotlin itself, you will also need a Kotlin plugin to build the project in IntelliJ IDEA. To keep the plugin version in sync with the rest of the team and our Continuous Integration server you should install the according to the instructions below.

If you want to have an IntelliJ IDEA installation without the Kotlin plugin which is separate to your default IntelliJ IDEA installation which has the Kotlin plugin see this document which describes how to have multiple IntelliJ IDEA installations using different configurations and plugin directories.

From this root project there are Run/Debug Configurations for running IDEA or the Compiler Tests for example; so if you want to try out the latest and greatest IDEA plugin

  • VCS -> Git -> Pull
  • Run IntelliJ IDEA
  • a child IntelliJ IDEA with the Kotlin plugin will then startup
  • you can now open the kotlin libraries project to then work with the various kotlin libraries etc.

Using a pre-built Kotlin IntelliJ IDEA plugin

There are several options for getting Kotlin plugin. A stable version can be obtained as any other plugin for IntelliJ IDEA:

Preferences -> Plugins -> Install JetBrains plugin... -> Search with "Kotlin" string

The most recent version of the plugin can be downloaded from the IDEA Plugin and Tests CI build. When downloading is finished you can install it with "Install plugin from disk...":

Preferences -> Plugins -> Install plugin from disk...

You can now open any Kotlin based projects.

Note for contributors: If you are planning to contribute to Kotlin project you probably want to have locally the same version of plugin that build server is using for building. As this version is constantly moving, the best way to always be updated is to let IntelliJ IDEA notify you when it is time to renew your plugin.

Open

Preferences -> Plugins -> Browse Repositories -> Manage Repositories...

and add the following URL to your repositories:

https://teamcity.jetbrains.com/guestAuth/repository/download/bt345/bootstrap.tcbuildtag/updatePlugins.xml

Then update the list of plugins in "Browse Repositories", you'll see two versions of Kotlin there, install the one with the higher version number.

Contributing

We love contributions! There's lots to do on Kotlin and on the standard library so why not chat with us about what you're interested in doing? Please join the #kontributors channel in our Slack chat and let us know about your plans.

If you want to find some issues to start off with, try this query which should find all Kotlin issues that marked as "up-for-grabs".

Currently only committers can assign issues to themselves so just add a comment if you're starting work on it.

A nice gentle way to contribute would be to review the standard library docs and find classes or functions which are not documented very well and submit a patch.

In particular it'd be great if all functions included a nice example of how to use it such as for the hashMapOf() function. This is implemented using the @sample macro to include code from a test function. The benefits of this approach are twofold; First, the API's documentation is improved via beneficial examples that help new users and second, the code coverage is increased.

Also the JavaScript translation could really use your help. See the JavaScript contribution section for more details.

If you want to work on the compiler

The Kotlin compiler is written in Java and Kotlin (we gradually migrate more and more of it to pure Kotlin). So the easiest way to work on the compiler or IntelliJ IDEA plugin is

You can now run the various Run/Debug Configurations such as

  • IDEA
  • All Compiler Tests
  • All IDEA Plugin Tests

If you want to work on the Kotlin libraries

Then build via

cd libraries
mvn install

Some of the code in the standard library is created by generating code from templates. See the README in the stdlib section for how run the code generator. The existing templates can be used as examples for creating new ones.

Submitting patches

The best way to submit a patch is to fork the project on github then send us a pull request via github.

If you create your own fork, it might help to enable rebase by default when you pull by executing git config --global pull.rebase true. This will avoid your local repo having too many merge commits which will help keep your pull request simple and easy to apply.

Commit comments

If you include in your comment this text (where KT-1234 is the Issue ID in the Issue Tracker, the issue will get automatically marked as fixed.

#KT-1234 Fixed