Hello, it’s still me. Small question I can’t seem ...
# getting-started
d
Hello, it’s still me. Small question I can’t seem to solve by myself. I’ve put in a project which is used as a parent by another maven project this extension function:
Copy code
fun RestClientBuilder.withKotlinSupport(): RestClientBuilder {
    KotlinRestClientFactoryConfigurer.configure(this)
    return this
}
Now this class just adds the KotlinModule for Jackson. The problem is that if I build my
RestClient
with the
RestClientBuilder
on the child project, there is no way I can see
withKotlinSupport
. Could you tell me a way to identify which is the problem?
k
Of course the parent project can't see stuff in the child project, that how it's supposed to work. Maybe you can write a method in the parent project along the lines of
setBuildConfigurator(configurator: (Builder) -> Unit)
.
d
mmm…it’s the exact opposite. I can’t see it from child project.
k
withKotlinSupport is part of the child project, right?
d
no, the extension you see is part of the parent
I want to use it on the children
but I cannot see it
k
Did you import the file that contains the extension?
d
what do you mean?
k
Well when you want to use an extension function from another file you have to actually import that file, as the extension doesn't actually "belong" the the receiver type.
d
that I didn’t do
wait
@karelpeeters sorry I cannot find on google a way to import the file, can you tell me how to do it?
k
Just do
import package.FileName
like always.
d
ahahhh ok 😄
The file is called
namespace.kt
, the content is this:
Copy code
package com.lastminute.appfw.libs.rest

import com.lastminute.appfw.extensions.KotlinRestClientFactoryConfigurer
import org.springframework.core.ParameterizedTypeReference

fun RestClientBuilder.withKotlinSupport(): RestClientBuilder {
    KotlinRestClientFactoryConfigurer.configure(this)
    return this
}

inline fun <reified T: Any> typeRef(): ParameterizedTypeReference<T> = object: ParameterizedTypeReference<T>(){}
but it’s I can’t find a way to import it.
k
import com.lastminute.appfw.libs.rest.namespace
doesn't work?
d
it says unresolved reference on namespace
k
And namespace.kt and the file you're trying to use it in are in the same project?
d
nope. namespace.kt is on parent, the file where I want to use it is on child project.
k
Do you also get this error if you build he entire project with Maven? Maybe Idea hasn't realized something has changed.
d
the very same error 😞
should I put the extension inside an object?
k
No it should really work like this.
Maybe try asking in #general or #maven, I'm out of ideas 😞
Other stuff is accessible in the child project, right?
d
well, nope. Nada de nada.
k
Well then your problem is maven, not extension functions. I've never actually used maven myself, so I can't really help there.
d
I’m doing research
it was a maven problem after all
thank you very much
k
No problem, and glad to hear you managed to fix it!