How to build three independent projects two depends on one as a dependeny?

Hello sorry, if I have 3 independent projects/services {auth-service, gateway, shared-service} located inside folder Project. gateway and auth-service both share shared-service. How do I add it as a dependency in these projects. I tried the following option but it didn’t work. Inside settings.gradle of auth-service:
rootProject.name = ‘auth-service’
include ‘:shared-service’
project (’: shared-service’). projectDir = new File(settingDir, ‘…/shared-service’)

Then in build.gradle of auth-service

compile project (’: shared-service’)

Here is the output log::
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compile() for arguments [project ‘:shared-service’] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
at org.gradle.internal.metaobject.AbstractDynamicObject$CustomMissingMethodExecutionFailed.(AbstractDynamicObject.java:190)

The compile configuration was deprecated a long time ago and removed in Gradle 7. Use implementation instead.

You could also consider using a composite build instead. In your auth-service/settings.gradle:

includeBuild '../shared-service'

In auth-service/build.gradle:

dependencies {
    implementation 'shared-group-id:shared-service'
}