|
| 1 | + |
| 2 | +# Creating a project using JBotSim |
| 3 | +> The steps described here have been generated with a IntelliJ IDEA 2018.3.3 (Ultimate Edition) |
| 4 | +> (Build #IU-183.5153.38, built on January 9, 2019) |
| 5 | +
|
| 6 | + |
| 7 | +## Pre requisite |
| 8 | +The guidance provided here suppose that you have a |
| 9 | +[usable](https://www.jetbrains.com/help/idea/install-and-set-up-product.html) *IntelliJ IDEA* instance. |
| 10 | + |
| 11 | +## Introduction |
| 12 | + |
| 13 | +In this documentation, we focus on creating a project that will: |
| 14 | +* allow you to run JBotSim's [*Hello World*](./README.md#helloworld-class), |
| 15 | +* make *IntelliJ IDEA*'s [Quick Documentation](https://www.jetbrains.com/help/idea/viewing-reference-information.html#inline-quick-documentation) |
| 16 | +on JBotSim symbols available. |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +The configuration process takes place in the following two steps. |
| 21 | +* First, the [project creation](#project-creation). You will either be: |
| 22 | + * [creating a Java project](#creating-a-java-project) or |
| 23 | + * [creating a Gradle project](#creating-a-gradle-project). |
| 24 | +* Then, the [configuration of your dependency to JBotSim](#adding-the-jbotsim-dependency): |
| 25 | + * using the [Maven central version](#using-the-maven-central-version) with |
| 26 | + * a [Java project](#java-project) or |
| 27 | + * a [Gradle project](#gradle-project); |
| 28 | + * using the [standalone jar version](#using-the-standalone-jar-version) with |
| 29 | + * a [Java project](#java-project-standalone) or |
| 30 | + * a [Gradle project](#gradle-project-standalone). |
| 31 | + |
| 32 | +## Project creation |
| 33 | + |
| 34 | +### Creating a Java project |
| 35 | + |
| 36 | +* Starting the new project wizard: |
| 37 | + |
| 38 | + `File` > `New` > `Project...` |
| 39 | + |
| 40 | +* Creating a Java project |
| 41 | + |
| 42 | + * Select: `Java` |
| 43 | + * Make sure a *Project SDK* is selected (either 8 or 10) -- should be set by default |
| 44 | + * Nothing more to select. You can deselect anything selected in there. |
| 45 | + * Hit `Next`. |
| 46 | + |
| 47 | +* Choosing a template |
| 48 | + |
| 49 | + * You can optionally select the `Java Hello World` template. |
| 50 | + |
| 51 | + This will generate a `Main.java` file. |
| 52 | + * Hit `Next`. |
| 53 | + |
| 54 | +* Choosing your project's name and directory |
| 55 | + |
| 56 | + * Provide a project name |
| 57 | + * Provide a directory |
| 58 | + |
| 59 | + This field is automatically filled by *IntelliJ IDEA* depending on your project's name. In most cases, you will want |
| 60 | + to leave it as is. |
| 61 | + * Hit `Finish`. |
| 62 | + |
| 63 | + After some automatic configuration, the project should be created. |
| 64 | + |
| 65 | +### Creating a Gradle project |
| 66 | + |
| 67 | +* Starting the new project wizard: |
| 68 | + |
| 69 | + `File` > `New` > `Project...` |
| 70 | + |
| 71 | +* Creating a Java project |
| 72 | + |
| 73 | + * Select: `Gradle` |
| 74 | + * Make sure a Project SDK is chosen (either 8 or 10) -- should be set by default |
| 75 | + * In "Additional Libraries and Frameworks", make sure "Java" is ticked. |
| 76 | + * Hit `Next`. |
| 77 | + |
| 78 | +* *GroupId* and *ArtifactId* Screen |
| 79 | + * Fill in the fields: |
| 80 | + * `GroupId`: your namespace (*e.g.* `com.example`) |
| 81 | + * `ArtifactId`: your application/library name (*e.g.* `jbotsim-app`) |
| 82 | + * `Version`: leave as is (usually `1.0-SNAPSHOT`) |
| 83 | + * Hit `Next`. |
| 84 | + |
| 85 | +* Gradle configuration screen |
| 86 | + * tick `Use auto-import` |
| 87 | + * make sure `Use default gradle wrapper` radio button is selected |
| 88 | + * you can leave the rest as is |
| 89 | + * Hit `Next`. |
| 90 | + |
| 91 | + |
| 92 | +* Project name and location screen |
| 93 | + * these should already be filled in. Only modify those fields if you know you have to. |
| 94 | + * Hit `Finish`. |
| 95 | + |
| 96 | + After some automatic configuration, the project should be created. |
| 97 | + |
| 98 | + |
| 99 | +## Adding the JBotSim dependency |
| 100 | + |
| 101 | +### Using the Maven Central version |
| 102 | + |
| 103 | +This method takes advantage of the fact that JBotSim has been published on *Maven Central*. |
| 104 | + |
| 105 | + |
| 106 | +Any JBotSim classes, source code and documentation will automatically be downloaded for you. |
| 107 | + |
| 108 | +#### Java project |
| 109 | + |
| 110 | +***Adding the JBotSim project jar as a dependency*** |
| 111 | + * Open the Project Structure popup |
| 112 | + |
| 113 | + `File` > `Project Structure` |
| 114 | + |
| 115 | + * Open the "New Project Library" popup: |
| 116 | + * select `Libraries` in the left panel |
| 117 | + * click `+` |
| 118 | + * choose `From Maven ...`. |
| 119 | + |
| 120 | + * In the "Download Library from Maven Repository" popup: |
| 121 | + * provide the following dependency: `io.jbotsim:jbotsim-all:1.0.0` |
| 122 | + * make sure to tick `JavaDocs` |
| 123 | + * Hit `OK`. |
| 124 | + * Confirm that you want to add it to your (only) module. |
| 125 | + |
| 126 | + And you are done! You can copy paste the example. |
| 127 | + |
| 128 | +***Documentation*** |
| 129 | +* if you have ticked "JavaDocs", the documentation should already be available. |
| 130 | +* you can also provide the *javadoc-only* *jar*, containing only the javadoc, by using the same process described |
| 131 | +[here](#java-project-standalone). |
| 132 | +* providing the url to the online javadoc is still possible |
| 133 | + * open Project Structure |
| 134 | + * in `Libraries`, select your maven dependency |
| 135 | + * click on `Specify Documentation URL` |
| 136 | + * provide the javadoc url |
| 137 | + |
| 138 | +#### Gradle project |
| 139 | + |
| 140 | +Simply add the following line to your `build.gradle`: |
| 141 | + |
| 142 | +``` |
| 143 | +dependencies { |
| 144 | + implementation "io.jbotsim:jbotsim-all:1.0.0" |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | + |
| 149 | +### Using the standalone jar version |
| 150 | + |
| 151 | +> Using the standalone version should be reserved to already existing projects and offline usages. |
| 152 | +> Please consider using the [Maven Central version](#using-the-maven-central-version). |
| 153 | +
|
| 154 | + |
| 155 | +#### Java project standalone |
| 156 | + |
| 157 | +***Adding the JBotSim project jar as a dependency*** |
| 158 | + * Open the Project Structure popup |
| 159 | + |
| 160 | + `File` > `Project Structure` |
| 161 | + |
| 162 | + * Open the "New Project Library" popup: |
| 163 | + * select `Libraries` in the left panel |
| 164 | + * click `+` |
| 165 | + * choose `Java`. |
| 166 | + |
| 167 | + * In the popup, provide the JBotSim full *jar* (from the location you stored it) |
| 168 | + * Confirm that you want to add it to your (only) module. |
| 169 | + |
| 170 | + And you are done! You can copy paste the example. |
| 171 | + |
| 172 | +***Documentation*** |
| 173 | +* if you have provided the *classes + javadoc* jar, intellij will automatically find the documentation. |
| 174 | + |
| 175 | + Be careful on not distributing your application with this version of the *jar*. |
| 176 | + |
| 177 | +* if you have provided the *classes only* jar, can add documentation by: |
| 178 | + * providing the *javadoc-only* *jar*, containing only the javadoc, by using the same process. |
| 179 | + |
| 180 | + * providing the url to the online javadoc |
| 181 | + * open Project Structure |
| 182 | + * select your .jar in modules |
| 183 | + * click on `Specify Documentation URL` |
| 184 | + * provide the javadoc url |
| 185 | + |
| 186 | + |
| 187 | +#### Gradle project standalone |
| 188 | + |
| 189 | +>Creating a *gradle* project with the fat-jar makes sense if you are really afraid of (or not able to use) *maven* at |
| 190 | +>the time you create your project but consider using it later. |
| 191 | +
|
| 192 | +>Please see [gradle-related *maven* configuration](#gradle-project). |
| 193 | +
|
| 194 | + |
| 195 | +***Adding the JBotSim project jar as a dependency*** |
| 196 | + * Put the jar in a directory inside your project |
| 197 | + |
| 198 | + *e.g.* directory `mylibs` |
| 199 | + |
| 200 | + * In the `build.gradle` file, add the following statement: |
| 201 | + |
| 202 | + ``` |
| 203 | + dependencies { |
| 204 | + compile files('mylibs/jbotsim-full-1.0.0.jar') |
| 205 | + } |
| 206 | + ``` |
| 207 | + |
| 208 | + And you are done! You can copy paste the example. |
| 209 | + |
| 210 | + |
| 211 | +***Documentation*** |
| 212 | +* you can also provide the *javadoc-only* *jar*, containing only the javadoc, by using the same process described |
| 213 | +[here](#java-project-standalone). |
| 214 | +* providing the url to the online javadoc can work, but should be linked to another (possibly empty) lib, or your jvm. |
| 215 | +
|
0 commit comments