|
| 1 | +# Setup Kotlin DataFrame in Maven |
| 2 | + |
| 3 | +<web-summary> |
| 4 | +Set up Kotlin DataFrame in your Maven project, configure dependencies, and start using the API with full IDE support. |
| 5 | +</web-summary> |
| 6 | + |
| 7 | +<card-summary> |
| 8 | +Learn how to add Kotlin DataFrame to your Maven project. |
| 9 | +</card-summary> |
| 10 | + |
| 11 | +<link-summary> |
| 12 | +Guide for integrating Kotlin DataFrame in a Maven project, with setup instructions and example code. |
| 13 | +</link-summary> |
| 14 | + |
| 15 | +Kotlin DataFrame can be added as a usual Maven dependency to your Kotlin project. |
| 16 | + |
| 17 | +## Create a Kotlin project |
| 18 | + |
| 19 | +1. In IntelliJ IDEA, select **File** | **New** | **Project**. |
| 20 | +2. In the panel on the left, select **New Project**. |
| 21 | +3. Name the new project and change its location, if necessary. |
| 22 | + |
| 23 | + > Select the **Create Git repository** checkbox to place the new project under version control. |
| 24 | + > You can enable this later at any time. |
| 25 | + > {type="tip"} |
| 26 | +
|
| 27 | +4. From the **Language** list, select **Kotlin**. |
| 28 | +5. Select the **Maven** build system. |
| 29 | +6. From the **JDK list**, select the [JDK](https://www.oracle.com/java/technologies/downloads/) |
| 30 | +that you want to use in your project. The minimum supported version is JDK 8. |
| 31 | + * If the JDK is installed on your computer, but not defined in the IDE, select **Add JDK** |
| 32 | + and specify the path to the JDK home directory. |
| 33 | + * If you don't have the necessary JDK on your computer, select **Download JDK**. |
| 34 | +7. Select the **Add sample code** checkbox to create a file with a sample `"Hello World!"` application. |
| 35 | +8. Click **Create**. |
| 36 | + |
| 37 | +You have successfully created a project with Maven. |
| 38 | + |
| 39 | +## Add Kotlin DataFrame Maven dependency |
| 40 | + |
| 41 | +In your Maven build file (`pom.xml`), add the Kotlin DataFrame library as a dependency: |
| 42 | + |
| 43 | +```xml |
| 44 | +<dependency> |
| 45 | + <groupId>org.jetbrains.kotlinx</groupId> |
| 46 | + <artifactId>dataframe</artifactId> |
| 47 | + <version>%dataFrameVersion%</version> |
| 48 | +</dependency> |
| 49 | +``` |
| 50 | + |
| 51 | +This will add [general Kotlin DataFrame dependency](Modules.md#dataframe-general), |
| 52 | +i.e., [core API and implementation](Modules.md#dataframe-core) as well as all |
| 53 | +[IO modules](Modules.md#io-modules) (excluding [experimental ones](Modules.md#experimental-modules)). |
| 54 | +You can add only the [core API module](Modules.md#dataframe-core) |
| 55 | +and the specific [modules](Modules.md) you need. |
| 56 | + |
| 57 | + |
| 58 | +## Hello World |
| 59 | + |
| 60 | +Let’s create your first [`DataFrame`](DataFrame.md) — a simple "Hello, World!" style example: |
| 61 | + |
| 62 | +```kotlin |
| 63 | +import org.jetbrains.kotlinx.dataframe.api.dataFrameOf |
| 64 | +import org.jetbrains.kotlinx.dataframe.api.print |
| 65 | + |
| 66 | +fun main() { |
| 67 | + val df = dataFrameOf( |
| 68 | + "name" to listOf("Alice", "Bob"), |
| 69 | + "age" to listOf(25, 30) |
| 70 | + ) |
| 71 | + |
| 72 | + df.print() |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +## Kotlin DataFrame Compiler Plugin |
| 77 | + |
| 78 | +[Kotlin DataFrame Compiler Plugin](Compiler-Plugin.md) enables automatic generation of |
| 79 | +[extension properties](extensionPropertiesApi.md) and updates [data schemas](schemas.md) |
| 80 | +on-the-fly in Maven projects, making development with Kotlin DataFrame faster, |
| 81 | +more convenient, and fully type- and name-safe. |
| 82 | + |
| 83 | +> Requires Kotlin 2.2.20-Beta1 or higher. |
| 84 | +> { style = "note" } |
| 85 | +
|
| 86 | +To enable the plugin in your Maven project, add it to the `plugins` section: |
| 87 | + |
| 88 | +```xml |
| 89 | +<plugin> |
| 90 | + <artifactId>kotlin-maven-plugin</artifactId> |
| 91 | + <groupId>org.jetbrains.kotlin</groupId> |
| 92 | + <version>%compilerPluginKotlinVersion%</version> |
| 93 | + |
| 94 | + <configuration> |
| 95 | + <compilerPlugins> |
| 96 | + <plugin>kotlin-dataframe</plugin> |
| 97 | + </compilerPlugins> |
| 98 | + </configuration> |
| 99 | + |
| 100 | + <dependencies> |
| 101 | + <dependency> |
| 102 | + <groupId>org.jetbrains.kotlin</groupId> |
| 103 | + <artifactId>kotlin-maven-dataframe</artifactId> |
| 104 | + <version>%compilerPluginKotlinVersion%</version> |
| 105 | + </dependency> |
| 106 | + </dependencies> |
| 107 | +</plugin> |
| 108 | +``` |
| 109 | + |
| 110 | +## Project Example |
| 111 | + |
| 112 | +See [the Maven example project with the Kotlin DataFrame Compiler Plugin enabled on GitHub](https://github.com/Kotlin/dataframe/tree/master/examples/kotlin-dataframe-plugin-maven-example). |
| 113 | + |
| 114 | + |
| 115 | +## Next Steps |
| 116 | + |
| 117 | +* Once you’ve set up Kotlin DataFrame in your Maven project, continue with the [](quickstart.md) |
| 118 | + to learn the basics of working with Kotlin DataFrame. |
| 119 | +* Explore [detailed guides and real-world examples](Guides-And-Examples.md) |
| 120 | + to see how Kotlin DataFrame helps with different data tasks. |
| 121 | +* Check out various |
| 122 | + [IDEA examples using Kotlin DataFrame on GitHub](https://github.com/Kotlin/dataframe/tree/master/examples/idea-examples). |
| 123 | +* Learn more about the [compiler plugin](Compiler-Plugin.md). |
0 commit comments