Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add external module to a gradle project in Intellij IDEA 14?

I extracted some part of my code and resources to a new local module in Intellij IDEA 14, because the copies of them are used in several projects. I want to use the module as a support module for my gradle projects.

When the project is not based on gradle, module could be added to my project easily by adding dependency in 'project structure'. But it doesn't work in a gradle project.

How can I use the code and resources from my local module in a gradle project?

What should I do for the support module and my gradle project? I've read the user guide of gradle but still can't find a solution.

UPDATE: below is the project structure

External Gradle project
--external_project
----lib
--------src
--------build.gradle
----settings.gradle

Current Gradle project    
--current_project
----app
--------src
--------build.gradle
----settings.gradle

I'm getting a error message when gradle builds, Error:Configuration with name 'default' not found.

like image 985
ProtossShuttle Avatar asked Dec 25 '22 15:12

ProtossShuttle


1 Answers

You can link any module by full path

1) Add module in your project settings.gradle

include ':app', ':mylib'
project(':mylib').projectDir = new File("/path-to-project/external_project/lib")

2) Add dependency in build.gradle of app module

dependencies {
    compile project(':mylib')
}
like image 62
Stas Parshin Avatar answered Dec 30 '22 16:12

Stas Parshin