IntelliJ Setup: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
→‎Build and Config Project Setup: Adding "before launch" tasks for IntelliJ IDEA 2020.3
Use better sections
Line 1: Line 1:
This guide assumes that you have a recent enough version of JAVA JDK, ANT, and IntelliJ Idea.  Completing [[Compiling from Source]] is a requirement for this guide, although experienced developers can skip to whatever step is appropriate.
This guide assumes that you have a recent enough version of JAVA JDK, ANT, and IntelliJ Idea.  Completing [[Compiling from Source]] is a requirement for this guide, although experienced developers can skip to whatever step is appropriate.


=== Build and Config Project Setup ===
== Build and Config Project Setup ==
#From the IntelliJ IDEA '''File''' Menu, choose '''New'''>'''New Project from Existing Sources...'''
# From the IntelliJ IDEA '''File''' Menu, choose '''New'''>'''New Project from Existing Sources...'''
##Choose the directory with the kolmafia build.xml file and press '''Open'''
#Choose the directory with the kolmafia build.xml file and press '''Open'''
##Choose '''Create Project from Existing Sources''' and press '''Next'''
#Choose '''Create Project from Existing Sources''' and press '''Next'''
##Enter the name KoLmafia and press '''Next'''
#Enter the name KoLmafia and press '''Next'''
##Verify that the project is visible to IDEA and press Finish
#Verify that the project is visible to IDEA and press Finish
#Add the Ant Build File
## Open the Ant Toolbar Item (typically on the right side, and not very large)
## Choose the '''+''' button to add a build file
## Choose build.xml from the file selector and press Open
## Verify that a list of ANT targets appears in the Ant Toolbar
#Check Project Settings
## From the '''File''' Menu, choose '''Project Structure...'''
## Select '''Project''' on the Left Menu
### set the '''Name''' to kolmafia
### set the '''Project SDK''' to any SDK version 1.8 or higher
### set the project language level to 8
### set the project compiler output to the build subdirectory
## Select the '''libraries''' tab
### Choose the '''+''' button to add library
### Select Type: Java
### Open the lib/jar directory and select all jars
### Select add to kolmafia  ''default is to name the library after the first jar.  This can be changed on the next step.''
### Select the '''Name''' field and enter "kol-library-jars"
### Choose the '''+''' button to add another library
### Open the src/jar directory and select all jars
### Select add to kolmafia
### Select the '''Name''' field and enter "kol-source-jars"
## Select '''Modules''' in the Left Menu
### In the '''Paths''' tab, select '''Inherit project compile output path'''
## Close the Project Settings window
#Add Run/Debug Configuration
## From the '''Run''' Menu choose '''Edit Configurations...'''
## Choose the '''+''' button to add a new configuration
## Select '''Application'''
## In the '''Name''' Field, enter "KoLmafia"
## In the '''Main Class''' Field, select the Selector '''[...]''', wait for it to populate the field, and choose KoLmafia
## Add any VM or program arguments needed (typically none)
## for the working directory, add the directory of your KoLmafia user data (e.g.  ~/Library/Application\ Support/kolmafia )
## Add the following "before launch" tasks. For IntelliJ IDEA 2020.3, click ''Modify options'' at top right and select ''Add before launch task''. For older versions of IntelliJ, set the "before launch" tasks at bottom (may need to scroll to see the bottom of the configurations window).
### Select the '''+''' button at the bottom of the  the before launch group
### Select Run ANT target '''set.released.false''' and drag it above the Build task.
### Select Run ANT target '''set.version''' and drag it above the Build task.
### Select Run ANT target '''unset.properties'''.  Leave it below the Build Task
## Choose '''Apply'''
## Choose '''Close'''


== Add the Ant Build File ==
# Open the Ant Toolbar Item (typically on the right side, and not very large)
# Choose the '''+''' button to add a build file
# Choose build.xml from the file selector and press Open
# Verify that a list of ANT targets appears in the Ant Toolbar


== Check Project Settings ==
# From the '''File''' Menu, choose '''Project Structure...'''
# Select '''Project''' on the Left Menu
## set the '''Name''' to kolmafia
## set the '''Project SDK''' to any SDK version 1.8 or higher
## set the project language level to 8
## set the project compiler output to the build subdirectory
# Select the '''libraries''' tab
## Choose the '''+''' button to add library
## Select Type: Java
## Open the lib/jar directory and select all jars
## Select add to kolmafia  ''default is to name the library after the first jar.  This can be changed on the next step.''
## Select the '''Name''' field and enter "kol-library-jars"
## Choose the '''+''' button to add another library
## Open the src/jar directory and select all jars
## Select add to kolmafia
## Select the '''Name''' field and enter "kol-source-jars"
# Select '''Modules''' in the Left Menu
## In the '''Paths''' tab, select '''Inherit project compile output path'''
# Close the Project Settings window


Test by pressing the run arrow next to your config name in the toolbar at the top of the window.
== Add Run/Debug Configuration ==
# From the '''Run''' Menu choose '''Edit Configurations...'''
# Choose the '''+''' button to add a new configuration
# Select '''Application'''
# In the '''Name''' Field, enter "KoLmafia"
# In the '''Main Class''' Field, select the Selector '''[...]''', wait for it to populate the field, and choose KoLmafia
# Add any VM or program arguments needed (typically none)
# for the working directory, add the directory of your KoLmafia user data (e.g.  ~/Library/Application\ Support/kolmafia )
# Add the following "before launch" tasks. For IntelliJ IDEA 2020.3, click ''Modify options'' at top right and select ''Add before launch task''. For older versions of IntelliJ, set the "before launch" tasks at bottom (may need to scroll to see the bottom of the configurations window).
## Select the '''+''' button at the bottom of the  the before launch group
## Select Run ANT target '''set.released.false''' and drag it above the Build task.
## Select Run ANT target '''set.version''' and drag it above the Build task.
## Select Run ANT target '''unset.properties'''.  Leave it below the Build Task
# Choose '''Apply'''
# Choose '''Close'''


====== Optional Steps ======
Test by pressing the Run arrow next to your config name in the toolbar at the top of the window.


== Optional Steps ==
* Setup SVN to update from IntelliJ (can still be done from the command line or a tool)
* Setup SVN to update from IntelliJ (can still be done from the command line or a tool)
*# TODO: FIXME...
*# TODO: FIXME...
* For easier coding, download the [[:File:KoLMafia Style.xml|KoLMafia Style Definitions]] and import them in the IntelliJ Code Style Preferences.
* To use the Reformat Code feature, download the [[:File:KoLMafia Style.xml|KoLMafia Style Definitions]] and import them in the IntelliJ Code Style Preferences.

Revision as of 03:06, 9 February 2021

This guide assumes that you have a recent enough version of JAVA JDK, ANT, and IntelliJ Idea. Completing Compiling from Source is a requirement for this guide, although experienced developers can skip to whatever step is appropriate.

Build and Config Project Setup

  1. From the IntelliJ IDEA File Menu, choose New>New Project from Existing Sources...
  2. Choose the directory with the kolmafia build.xml file and press Open
  3. Choose Create Project from Existing Sources and press Next
  4. Enter the name KoLmafia and press Next
  5. Verify that the project is visible to IDEA and press Finish

Add the Ant Build File

  1. Open the Ant Toolbar Item (typically on the right side, and not very large)
  2. Choose the + button to add a build file
  3. Choose build.xml from the file selector and press Open
  4. Verify that a list of ANT targets appears in the Ant Toolbar

Check Project Settings

  1. From the File Menu, choose Project Structure...
  2. Select Project on the Left Menu
    1. set the Name to kolmafia
    2. set the Project SDK to any SDK version 1.8 or higher
    3. set the project language level to 8
    4. set the project compiler output to the build subdirectory
  3. Select the libraries tab
    1. Choose the + button to add library
    2. Select Type: Java
    3. Open the lib/jar directory and select all jars
    4. Select add to kolmafia default is to name the library after the first jar. This can be changed on the next step.
    5. Select the Name field and enter "kol-library-jars"
    6. Choose the + button to add another library
    7. Open the src/jar directory and select all jars
    8. Select add to kolmafia
    9. Select the Name field and enter "kol-source-jars"
  4. Select Modules in the Left Menu
    1. In the Paths tab, select Inherit project compile output path
  5. Close the Project Settings window

Add Run/Debug Configuration

  1. From the Run Menu choose Edit Configurations...
  2. Choose the + button to add a new configuration
  3. Select Application
  4. In the Name Field, enter "KoLmafia"
  5. In the Main Class Field, select the Selector [...], wait for it to populate the field, and choose KoLmafia
  6. Add any VM or program arguments needed (typically none)
  7. for the working directory, add the directory of your KoLmafia user data (e.g. ~/Library/Application\ Support/kolmafia )
  8. Add the following "before launch" tasks. For IntelliJ IDEA 2020.3, click Modify options at top right and select Add before launch task. For older versions of IntelliJ, set the "before launch" tasks at bottom (may need to scroll to see the bottom of the configurations window).
    1. Select the + button at the bottom of the the before launch group
    2. Select Run ANT target set.released.false and drag it above the Build task.
    3. Select Run ANT target set.version and drag it above the Build task.
    4. Select Run ANT target unset.properties. Leave it below the Build Task
  9. Choose Apply
  10. Choose Close

Test by pressing the Run arrow next to your config name in the toolbar at the top of the window.

Optional Steps

  • Setup SVN to update from IntelliJ (can still be done from the command line or a tool)
    1. TODO: FIXME...
  • To use the Reformat Code feature, download the KoLMafia Style Definitions and import them in the IntelliJ Code Style Preferences.