https://kotlinlang.org logo
#announcements
Title
# announcements
m

Mjahangiry75

05/27/2021, 7:56 AM
how can I use
implementation project(":module")
in kotlin build script
c

CLOVIS

05/27/2021, 7:58 AM
Just add parenthesis,
implementation
is a function
m

Mjahangiry75

05/27/2021, 8:00 AM
That works for third-party libraries I want to import my own module
j

Javier

05/27/2021, 8:02 AM
it is the same
m

Mjahangiry75

05/27/2021, 8:04 AM
I just used
implementation(":module")
but doesn't work
g

gildor

05/27/2021, 8:08 AM
but doesn’t work
Because you removed “project”, check link by Clovis, it includes correct declaration
Copy code
implementation(project(":module"))
m

Mjahangiry75

05/27/2021, 8:12 AM
here is my project structure
g

gildor

05/27/2021, 8:12 AM
??
m

Mjahangiry75

05/27/2021, 8:12 AM
Copy code
implementation(project(":instagram4j"))
g

gildor

05/27/2021, 8:12 AM
okay, it looks right
m

Mjahangiry75

05/27/2021, 8:12 AM
but it doesn't work too
g

gildor

05/27/2021, 8:12 AM
what kind error do you have?
m

Mjahangiry75

05/27/2021, 8:13 AM
Copy code
Could not resolve project :instagram4j.
Required by:
    project :
g

gildor

05/27/2021, 8:16 AM
looks that you have some issue in project structure, hard to say What looks strange, that both of those projects are in different directories, which in case of Gradle may work, but only with additional configuration
g

gildor

05/27/2021, 8:32 AM
yep, it looks like the case, when you just added 2 projects to Idea, without adding them to the same Gradle project, in this case, as Ryan suggested, composite build is way to go
c

CLOVIS

05/27/2021, 8:35 AM
Did you add the project in
settings.gradle.kts
?
m

Mjahangiry75

05/27/2021, 8:36 AM
yes I did
c

CLOVIS

05/27/2021, 8:37 AM
Oh, good eyes @gildor. That's probably it
g

gildor

05/27/2021, 8:42 AM
Hard to say without any additional information, your original question was about “kotlin build script” but it hardly related on this, it’s not about syntax, it’s about your project structure
m

Mjahangiry75

05/27/2021, 8:46 AM
yes you are right, when I found the syntax then the real problem shows up
Actually I imported project from github that is a gradle java module to my own project that is gradle kotlin module too
g

gildor

05/27/2021, 8:52 AM
You really don’t want to just add another Gradle project just as one more module in your settings.gradle, it probably will not work, because it essentially changes whole structure of another project What you really want is to use composite builds for this
c

CLOVIS

05/27/2021, 9:03 AM
When you import someone else's project, do it from MavenCentral or similar, don't clone the repo. It's much, much easier.
m

Mjahangiry75

05/27/2021, 9:04 AM
Actually I want to modify it
p

Paul Woitaschek

05/27/2021, 9:06 AM
Then an included build is probably the best fit on quick iterations.
Well even better would be to merge your changes upstream 😉
m

Mjahangiry75

05/27/2021, 10:06 AM
I tried @Ryan Simon & @gildor suggestions and it works like a charm
thank you buddies
@Paul Woitaschek that's just a test, not worth to create a PR
6 Views