Skip to content

Commit

Permalink
Update intellij guide (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment authored Jul 30, 2023
1 parent 211c138 commit 6c78001
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 42 deletions.
Binary file not shown.
Binary file removed docs/assets/images/ide/new_ij/new_ij_auto_import.png
Binary file not shown.
Binary file not shown.
Binary file added docs/assets/images/ide/new_ij/new_ij_indexing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/ide/new_ij/new_ij_jar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/images/ide/new_ij/new_ij_new_project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/assets/images/ide/old_ij/old_ij_artifact.png
Binary file not shown.
Binary file removed docs/assets/images/ide/old_ij/old_ij_gradle.png
Binary file not shown.
Binary file added docs/assets/images/ide/old_ij/old_ij_indexing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/ide/old_ij/old_ij_jar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/images/ide/old_ij/old_ij_new_project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/assets/images/ide/old_ij/old_ij_settings.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
150 changes: 108 additions & 42 deletions docs/setup/intellij.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,88 +2,154 @@

[ ![Download](https://img.shields.io/maven-central/v/net.dv8tion/JDA?color=blue) ](https://mvnrepository.com/artifact/net.dv8tion/JDA/latest)

=== "Newer versions of IntelliJ IDEA"
=== "New UI of IntelliJ IDEA"

1. Navigate to "New Project" from any view
1. Select Gradle -> Java as the type of Project and make sure the correct JDK is selected (Java 8 or higher)

![new_project](../assets/images/ide/new_ij/new_ij_new_project.png)

1. Provide a title for your project and define your GroupId and optionally the ArtifactId and initial Version in the "Artifact Coordinates" subsection

![artifact_setup](../assets/images/ide/new_ij/new_ij_artifact_setup.png)

1. Optionally enable Auto-Importing of the Gradle file in the Gradle settings. This is also the place where you could switch the runner for your project (By default, Gradle is used to run your application and tests)
1. Let IntelliJ index your project.

![gradle_settings](../assets/images/ide/new_ij/new_ij_gradle_settings.png)
![auto_import](../assets/images/ide/new_ij/new_ij_auto_import.png)
![indexing](../assets/images/ide/new_ij/new_ij_indexing.png)

1. Let IntelliJ index your project.
1. Open `build.gradle`
1. Open `build.gradle.kts`
1. Populate the build file with the following
```groovy
```kotlin
plugins {
id'application'
id'com.github.johnrengelman.shadow' version '5.2.0'
application
id("com.github.johnrengelman.shadow") version "7.1.2"
}
mainClassName = 'com.example.jda.Bot' // (1)
version '1.0'
def jdaVersion = 'JDA_VERSION_HERE' // (2)
sourceCompatibility = targetCompatibility = 1.8

application.mainClass = "com.example.discordbot.Bot" // (1)
group = "org.example"
version = "1.0"

val jdaVersion = "JDA_VERSION_HERE" // (2)

repositories {
mavenCentral()
}

dependencies {
implementation("net.dv8tion:JDA:$jdaVersion")
}
compileJava.options.encoding = 'UTF-8'

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.isIncremental = true

// Set this to the version of java you want to use,
// the minimum required for JDA is 1.8
sourceCompatibility = "1.8"
}
```

1. Replace the `mainClassName` value with the path to your main class later on!
1. Replace the `mainClass` value with the path to your main class later on!

1. Replace the `JDA_VERSION_HERE` with the one mentioned in the [latest release](https://github.com/DV8FromTheWorld/JDA/releases/latest)

1. Reload Gradle and wait for it to finish

![reload gradle](../assets/images/ide/new_ij/new_ij_reload_gradle.png)

1. If IntelliJ IDEA didn't already do so automatically, set up a source folder as `src/main/java`
1. Create your group package. Example: `me.name.bot`
1. Create your group package. Example: `com.example.discordbot`
1. Make your main class. Example: `Bot.java`.
Your directory tree should look like this:
```
ProjectName -> src/main/java -> me/name/bot -> Bot.java
ProjectName -> src/main/java -> com/example/discordbot -> Bot.java
-> gradle/wrapper -> gradle-wrapper.properties
-> gradle/wrapper -> gradle-wrapper.jar
-> build.gradle
-> settings.gradle
-> build.gradle.kts
-> settings.gradle.kts
```
1. Configure the `mainClassName` value in the `build.gradle` to your class. Example: `me.name.bot.Bot`
1. To build your finished project simply use the `shadowJar` task in your Gradle tool window on right hand side of your editor. This will build a jar in `build/libs`. The one with the `-all` suffix is the shadow jar.
1. Configure the `mainClass` value in the `build.gradle.kts` to your class. Example: `com.example.discordbot.Bot`
1. To build your finished project simply use the `shadowJar` task in your Gradle tool window on right hand side of your editor.
> You can also run your project with the `run` Gradle task!

![shadowjar](../assets/images/ide/new_ij/new_ij_shadowjar.png)

1. This will build a jar in `build/libs`. The one with the `-all` suffix is the shadow jar.

![jar location](../assets/images/ide/new_ij/new_ij_jar.png)

1. [Setup Logback](./logging.md)
1. Continue with [Getting Started](../using-jda/getting-started.md)


=== "Older versions of IntelliJ IDEA"
=== "Older UI of IntelliJ IDEA"

1. Open the Project view
1. Create a new Project
1. Navigate to "New Project" from any view
1. Select Gradle -> Java as the type of Project and make sure the correct JDK is selected (Java 8 or higher)

![project](../assets/images/ide/old_ij/old_ij_new_project.png)
![new_project](../assets/images/ide/new_ij/new_ij_new_project.png)

1. Select `Gradle` > `Java`
1. Configure your SDK to use Java 1.8
1. Let IntelliJ index your project.

![gradle](../assets/images/ide/old_ij/old_ij_gradle.png)
![indexing](../assets/images/ide/old_ij/old_ij_indexing.png)

1. Click `Next` and fill in your groupId and your artifactId. Example: `me.name` and `bot`
1. Open `build.gradle.kts`
1. Populate the build file with the following
```kotlin
plugins {
application
id("com.github.johnrengelman.shadow") version "7.1.2"
}

![artifact](../assets/images/ide/old_ij/old_ij_artifact.png)
application.mainClass = "com.example.discordbot.Bot" // (1)
group = "org.example"
version = "1.0"

1. Check `Use auto-import` and click `Next` > `Finish`
val jdaVersion = "JDA_VERSION_HERE" // (2)

![settings](../assets/images/ide/old_ij/old_ij_settings.png)
repositories {
mavenCentral()
}

dependencies {
implementation("net.dv8tion:JDA:$jdaVersion")
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.isIncremental = true

// Set this to the version of java you want to use,
// the minimum required for JDA is 1.8
sourceCompatibility = "1.8"
}
```

1. Replace the `mainClass` value with the path to your main class later on!

1. Replace the `JDA_VERSION_HERE` with the one mentioned in the [latest release](https://github.com/DV8FromTheWorld/JDA/releases/latest)

1. Reload Gradle and wait for it to finish

![reload gradle](../assets/images/ide/old_ij/old_ij_reload_gradle.png)

1. If IntelliJ IDEA didn't already do so automatically, set up a source folder as `src/main/java`
1. Create your group package. Example: `com.example.discordbot`
1. Make your main class. Example: `Bot.java`.
Your directory tree should look like this:
```
ProjectName -> src/main/java -> com/example/discordbot -> Bot.java
-> gradle/wrapper -> gradle-wrapper.properties
-> gradle/wrapper -> gradle-wrapper.jar
-> build.gradle.kts
-> settings.gradle.kts
```
1. Configure the `mainClass` value in the `build.gradle.kts` to your class. Example: `com.example.discordbot.Bot`
1. To build your finished project simply use the `shadowJar` task in your Gradle tool window on right hand side of your editor.
> You can also run your project with the `run` Gradle task!

![shadowjar](../assets/images/ide/old_ij/old_ij_shadowjar.png)

1. This will build a jar in `build/libs`. The one with the `-all` suffix is the shadow jar.

![jar location](../assets/images/ide/old_ij/old_ij_jar.png)

1. [Setup Logback](./logging.md)
1. Continue with [Getting Started](../using-jda/getting-started.md)

0 comments on commit 6c78001

Please sign in to comment.