1 #  Intellij and Clion
  2 [Back to Index ../](../index.md)
  3 
  4 ## Intellij and Clion
  5 
  6 Some of us use JetBrains' `IntelliJ` and `Clion` for dev work and
  7 decided to leave some project artifacts in the repo.
  8 
  9 Care must be taken with Intellij and Clion
 10 as these tools do not play well together,
 11 specifically we cannot have `Clion` and `Intellij`
 12 project artifacts rooted under each other or in the same dir.
 13 
 14 ## Intellij
 15 The `intellij` subdir under the root HAT directory
 16 contains the `.idea` project dir and the various `*.iml` files
 17 for each of the various `modules`
 18 (note the use of `Intellji`'s meaning of the word of module here)
 19 
 20 As you will note the `intellij` dir is somewhat self contained.  the various `*.iml`
 21 files refer to the source dirs using relative paths.
 22 
 23 I tend to add `Intellij` modules by hand.  There are gotchas ;)
 24 
 25 As with every intellij project, `.idea/modules.xml` 'points' to the iml files for each module (intellij's notion of module ;) )
 26 ```xml
 27 <!--
 28    └──hat
 29        └── intellij
 30             └── .idea
 31                  └── modules.xml
 32 -->
 33  <modules>
 34       <module fileurl="file://$PROJECT_DIR$/hat.iml"   />
 35       <module fileurl="file://$PROJECT_DIR$/backend_opencl.iml"  />
 36       <!-- yada yada -->
 37  </modules>
 38 
 39 ```
 40 
 41 The various `.iml` files then  have relative paths to their source/resource dirs roots.
 42 
 43 ```xml
 44 <module type="JAVA_MODULE" version="4">
 45   <component name="NewModuleRootManager" inherit-compiler-output="true">
 46     <exclude-output />
 47     <content url="file://$MODULE_DIR$/../../../hat/src/java">
 48       <sourceFolder url="file://$MODULE_DIR$/../../../hat/src/java" isTestSource="false" />
 49     </content>
 50     <orderEntry type="inheritedJdk" />
 51     <orderEntry type="sourceFolder" forTests="false" />
 52     <orderEntry type="module" module-name="hat" />
 53   </component>
 54 </module>
 55 
 56 ```
 57 
 58 Making run configurations available to other developers is probably `a bridge too far`
 59 
 60 But with some careful XML tooling we can make it easier to add 'run configurations'.
 61 
 62 ### How intellij stores run configurations
 63 
 64 I also tend to hand hack run configurations so will leave this here for reference
 65 
 66 ```xml
 67 <component name="RunManager" selected="Application.MandelTest">
 68     <configuration name="Mandel" type="Application"
 69                    factoryName="Application" temporary="true"
 70                    nameIsGenerated="true">
 71       <option name="MAIN_CLASS_NAME" value="mandel.Mandel" />
 72       <module name="mandel" />
 73       <option name="VM_PARAMETERS" value="
 74           --enable-preview
 75           --add-exports=java.base/java.lang.foreign.mapper=ALL-UNNAMED
 76           --patch-module=java.base=$PROJECT_DIR$/out/production/java_base_patch
 77           -Djava.lang.foreign.mapper.debug=true" />
 78       <extension name="coverage">
 79         <pattern>
 80           <option name="PATTERN" value="mandel.*" />
 81           <option name="ENABLED" value="true" />
 82         </pattern>
 83       </extension>
 84       <method v="2">
 85         <option name="Make" enabled="true" />
 86       </method>
 87     </configuration>
 88     <!-- more configs -->
 89 </component>
 90 ```
 91 
 92 ## Clion
 93 
 94 Thankfully Clion uses cmake, so we get to re-use the CMakeLists.txt in the various backends to build.
 95 
 96 The intent is that these cmake artifacts can be run standalone (using cmake in the appropriate dir),
 97 from within Clion and can be used by maven.  So the CMakeLists.txt files have some extra variables to
 98 help us use them in these three modes.
 99 
100 
101 
102