ReadMe.md 9.6 KB
Newer Older
1
<a href="https://kotlinslackin.herokuapp.com"><img src="https://kotlinslackin.herokuapp.com/badge.svg" height="20"></a>
Z
Zalim Bashorov 已提交
2 3 4 5
[![TeamCity (simple build status)](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/bt345.svg)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=bt345&branch_Kotlin=%3Cdefault%3E&tab=buildTypeStatusDiv)
[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlin/kotlin-maven-plugin.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.jetbrains.kotlin%22)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)

6 7
# Kotlin Programming Language

8
Welcome to [Kotlin](https://kotlinlang.org/)! Some handy links:
9

10 11
 * [Kotlin Site](https://kotlinlang.org/)
 * [Getting Started Guide](https://kotlinlang.org/docs/tutorials/getting-started.html)
12
 * [Try Kotlin](http://try.kotlinlang.org/)
13 14 15 16
 * [Kotlin Standard Library](https://kotlinlang.org/api/latest/jvm/stdlib/index.html)
 * [Issue Tracker](https://youtrack.jetbrains.com/issues/KT)
 * [Forum](https://discuss.kotlinlang.org/)
 * [Kotlin Blog](https://blog.jetbrains.com/kotlin/)
A
Alexander Udalov 已提交
17
 * [Follow Kotlin on Twitter](https://twitter.com/kotlin)
18
 * [Public Slack channel](https://kotlinslackin.herokuapp.com/)
19
 * [TeamCity CI build](https://teamcity.jetbrains.com/project.html?tab=projectOverview&projectId=Kotlin)
20 21 22

## Editing Kotlin

23
 * [Kotlin IntelliJ IDEA Plugin](https://kotlinlang.org/docs/tutorials/getting-started.html)
24
 * [Kotlin Eclipse Plugin](https://kotlinlang.org/docs/tutorials/getting-started-eclipse.html)
25
 * [Kotlin TextMate Bundle](https://github.com/vkostyukov/kotlin-sublime-package)
26

27 28 29 30
## Build environment requirements

In order to build Kotlin distribution you need to have:

Z
Zalim Bashorov 已提交
31
- Apache Ant 1.9.4 and higher
32 33 34 35 36 37 38 39
- 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"

40 41
## Building

42
To build this project, first time you try to build you need to run this:
43 44 45 46 47 48 49 50 51 52 53

    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
J
Jason Yeo 已提交
54

A
Andrey Breslav 已提交
55
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
56
[ANT_OPTS](https://web.liferay.com/community/wiki/-/wiki/Main/Ant+opts).
57

A
Andrey Breslav 已提交
58
**OPTIONAL:** Maven distribution is built separately, run
59

L
Leonid Shalupov 已提交
60
    mvn package
61

62
from 'libraries' directory after building the compiler. Refer to [libraries/ReadMe.md](libraries/ReadMe.md) for details.
63

D
Dmitry Jemerov 已提交
64
## Working with the project in IntelliJ IDEA
65

D
Dmitry Jemerov 已提交
66
The [root kotlin project](https://github.com/JetBrains/kotlin) already has an IntelliJ IDEA project, you can just open it in IntelliJ IDEA.
67

A
Andrey Breslav 已提交
68 69 70 71 72 73
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 -> <Your JDK> -> 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.

74
Since Kotlin project contains code written in Kotlin itself, you will also need a Kotlin plugin to build the project in IntelliJ IDEA.
75
To keep the plugin version in sync with the rest of the team and our [Continuous Integration server](https://teamcity.jetbrains.com/project.html?projectId=Kotlin&tab=projectOverview)
76
you should install the according to the [instructions below](#plugin-for-contributors).
77

D
Dmitry Jemerov 已提交
78
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
79
plugin [see this document](https://devnet.jetbrains.com/docs/DOC-181) which describes how to have multiple IntelliJ IDEA installations using different configurations and plugin directories.
80

D
Dmitry Jemerov 已提交
81
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
82 83

* VCS -> Git -> Pull
D
Dmitry Jemerov 已提交
84 85
* Run IntelliJ IDEA
* a child IntelliJ IDEA with the Kotlin plugin will then startup
D
Dmitry Jemerov 已提交
86
* you can now open the [kotlin libraries project](https://github.com/JetBrains/kotlin/tree/master/libraries) to then work with the various kotlin libraries etc.
87

D
Dmitry Jemerov 已提交
88
### <a name="pre-built-plugin"></a>Using a pre-built Kotlin IntelliJ IDEA plugin
89

D
Dmitry Jemerov 已提交
90
There are several options for getting Kotlin plugin. A stable version can be obtained as any other plugin for IntelliJ IDEA:
91

D
Dmitry Jemerov 已提交
92
    Preferences -> Plugins -> Install JetBrains plugin... -> Search with "Kotlin" string
93

94
The most recent version of the plugin can be downloaded from the
95
[IDEA Plugin and Tests CI build](https://teamcity.jetbrains.com/project.html?projectId=project67&tab=projectOverview). When downloading is
96
finished you can install it with "Install plugin from disk...":
97

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

100
You can now open any Kotlin based projects.
101

A
Andrey Breslav 已提交
102
<a name="plugin-for-contributors"></a>
103
**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.
D
Dmitry Jemerov 已提交
104
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.
105

J
Jason Yeo 已提交
106
Open
107 108 109 110 111

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

and add the following URL to your repositories:

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

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.
115

116 117
# Contributing

118
We love contributions! There's [lots to do on Kotlin](https://youtrack.jetbrains.com/issues/KT) and on the
D
Dmitry Jemerov 已提交
119 120 121
[standard library](https://youtrack.jetbrains.com/issues/KT?q=Subtask+of%3A+KT-2554+%23Unresolved) so why not chat with us
about what you're interested in doing? Please join the #kontributors channel in [our Slack chat](http://kotlinslackin.herokuapp.com/)
and let us know about your plans.
122

123
If you want to find some issues to start off with, try [this query](https://youtrack.jetbrains.com/issues/KT?q=tag:%20%7BUp%20For%20Grabs%7D%20%23Unresolved) which should find all Kotlin issues that marked as "up-for-grabs".
124 125 126

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

127
A nice gentle way to contribute would be to review the [standard library docs](https://kotlinlang.org/api/latest/jvm/stdlib/index.html)
D
Dmitry Jemerov 已提交
128
and find classes or functions which are not documented very well and submit a patch.
129

D
Dmitry Jemerov 已提交
130
In particular it'd be great if all functions included a nice example of how to use it such as for the
131
[`hashMapOf()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/hash-map-of.html) function.
I
Ilya Gorbunov 已提交
132
This is implemented using the [`@sample`](https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/collections/Maps.kt#L64)
133
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.
134 135 136 137

Also the [JavaScript translation](https://github.com/JetBrains/kotlin/blob/master/js/ReadMe.md) could really use your help. See the [JavaScript contribution section](https://github.com/JetBrains/kotlin/blob/master/js/ReadMe.md) for more details.


138 139
## If you want to work on the compiler

D
Dmitry Jemerov 已提交
140
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
141

142
* download a clean [IDEA 15 EAP build](https://confluence.jetbrains.com/display/IDEADEV/IDEA+15+EAP)
143
* [install the Kotlin plugin](#pre-built-plugin)
144 145 146 147 148 149 150 151 152 153 154
* open the [root kotlin project](https://github.com/JetBrains/kotlin) in IDEA (opening the kotlin directory)

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

155
* download a clean [IDEA 15 EAP build](https://confluence.jetbrains.com/display/IDEADEV/IDEA+15+EAP)
156
* [install the Kotlin plugin](#pre-built-plugin)
D
Dmitry Jemerov 已提交
157
* open the [kotlin libraries project](https://github.com/JetBrains/kotlin/tree/master/libraries)
158 159 160 161 162 163

Then build via

    cd libraries
    mvn install

164
Some of the code in the standard library is created by generating code from templates. See the [README](https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/ReadMe.md) in the stdlib section for how run the code generator. The existing templates can be used as examples for creating new ones.
165

D
Dmitry Jemerov 已提交
166
## Submitting patches
167

168 169
The best way to submit a patch is to [fork the project on github](https://help.github.com/articles/fork-a-repo/) then send us a
[pull request](https://help.github.com/articles/creating-a-pull-request/) via [github](https://github.com).
170

J
Jason Yeo 已提交
171 172 173 174
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.
175 176 177

## Commit comments

178
If you include in your comment this text (where KT-1234 is the Issue ID in the [Issue Tracker](https://youtrack.jetbrains.com/issues/KT), the issue will get automatically marked as fixed.
179 180

    #KT-1234 Fixed