• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

IntelliJ: Adding a new language to an existing project

 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I've used IntelliJ Java and Kotlin development for several years but I still have problem with Modules in the Project Structure.  I have an existing Kotlin project and I want to add a Python module because I have a quick and dirty utility that helps build one of the files.  Modules in Project Structure looks like this:



Now I want to add a Python module to the Wordle project.  How do I do that?

(I case anyone is interested in the Wordle project I wrote, it's here.)
 
Author
Posts: 49
18
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can give you my personal opinion on this. I'd like to caveat this: I have struggled with this particular issue on more than one occasion, and I haven't found an "official" way to do this comfortably.

What you really need is a multi module project. The top level of your project won't have code, and you'll need two modules, a Kotlin one and a Python one. Given your existing structure, that actually means you'll have to move your kotlin stuff "down" a level into its own module (e.g. create a folder under Wordle called "Kotlin" and then under that one you'll have main/kotlin and test/kotlin). You'll need to make your top-level Kotlin folder a new IntelliJ IDEA module. Then you can create a new module (e.g. called Python) and put your python stuff in there.

This is a bit fiddly. I have struggled with moving a project with a single module (or effectively no modules) into multi modules. The best way to create a multi module project is to start with an "empty" project and then create each module individually, but that doesn't work well if you have existing code.

Another approach is not to introduce separate modules, but instead to use separate source folders.  E.g. you can create a "python" folder under the Wordle folder and "Mark directory as" a source root. I have not tried this for non-JVM languages, so this may not work for Python, it may have to be a separate module.

I appreciate this advice is not super clear, but I hope it helps!  More info in the docs:

https://www.jetbrains.com/help/idea/creating-and-managing-modules.html
https://www.jetbrains.com/help/idea/add-items-to-project.html#create-module
https://www.jetbrains.com/help/idea/content-roots.html#configure-folders
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I got it working.  I'll tell what I did, but first a clarification: the structure I posted was the one you see if you go into Project Settings and click on the Modules tab.  My directory structure looks like this:



Taking a cue from you post, I added a Python module like this:



This cleared everything up.
 
Marshal
Posts: 79978
397
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TG: I have remembered why your name looks familiar: I have a copy of a book about 97 Things I Should Know.
Knute: good to see you back again
 
Trisha Gee
Author
Posts: 49
18
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:Thanks, I got it working.  I'll tell what I did, but first a clarification: the structure I posted was the one you see if you go into Project Settings and click on the Modules tab.  



Great, I'm glad I could help!
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic