Reputation: 53
I'm currently looking to start two new projects using IntelliJ - one which is an Android project and another that is just a standard Java project.
I want to use a lot of the same code within both projects, but don't want to copy files into projects. At a later stage, it is likely that this code will be used in other projects too.
At the moment I'm having difficulty working out how to include the common code within both projects - I have created new modules but then it seems that the import does not recognize code from the module.
Therefore the structure of directories would be something like:
|- Android Project
|- Java Project
|- Android Library
|- Java Library
|- Common Library
So you would have:
Could someone please advise as to how this is to be configured in IntelliJ?
In the case of the Android project, I am playing around with the module settings and dependencies and can get it to work briefly, but then these changes get lost whenever there is a Gradle sync.
Thanks.
Upvotes: 5
Views: 1730
Reputation: 13940
What you're probably looking for is a structure that utilizes a project of modules. (very much like Visual Studio solutions).
You may usually create a project in Intellij. But that project can have many modules.
To set it up, I would start by adding an empty project. After you create the empty project start adding modules. Once you have your modules in place, you'll need to add the module dependencies in the Project Structure settings.
Read more about your options on the the Dependency Tab.
Upvotes: 1