Victor Harlan Lacson
Victor Harlan Lacson

Reputation: 375

Gradle - How to refer a directory/jar file library from root-project to a sub-project for dependency

I have Gradle-Java project. I want to use a local library in a directory inside root project and use this library to sub projects.

something like this

root-project |-resources/libraries |-subproject1 |-subproject2 |-.. |-.. and so on

for example I want to use a library.jar from resources/library folder .I have seen some examples on subproject's build.gradle

depdencies{ compiles files('dir/some-files') }

but as far as my knowledge goes this only refer to files inside the subproject(kindly correct me I am wrong). I have seen also something like(or I am just imagining)

@root-project settings.gradle

include 'resource/library'

@sub-project build.gralde

compile project(':resources/library')

but i dont know what to do next to access the content. I want to know how to do this in gradle so I can put some dependencies in where multiple sub projects may use that library from root-project's directory.

I know it will be easy if I just uploaded that library to maven or jcenter. But Im reluctant since its a crappy one.

I will be grateful if someone teaches me or give some advice.

Upvotes: 2

Views: 2543

Answers (1)

Victor Harlan Lacson
Victor Harlan Lacson

Reputation: 375

I found a solution to what I want to achieve here in case someone like me might have the same question.

dependencies {
compile files{'$rootDir/some-files
}

my bad I am googling wrong qusetion to the wrong key word.

Upvotes: 2

Related Questions