0

In my multi-module project built by Gradle, a few repeated dependency declarations can be aggregated into a utility function

The easiest way to define such function that can be used by all submodules is to do it in buildSrc:

What is the purpose of gradle's buildSrc folder?

Unfortunately, its classpath resolving seems to be broken. If I import any function from the kotlin-dsl module:

import org.gradle.kotlin.dsl.`implementation`

I got the following error:

e: /home/peng/git/shapesafe/buildSrc/src/main/kotlin/init.kt: (5, 30): Unresolved reference: `implementation`

How could this happen?

tribbloid
  • 4,026
  • 14
  • 64
  • 103

1 Answers1

0

This means, that you have imported nothing at all:

Unresolved reference: implementation

You'd probably would have to import some more:

import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.kotlin
import org.gradle.kotlin.dsl.*

... where * also includes implementation.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • why would I have imported nothing? this is a legitimate path – tribbloid Nov 28 '21 at 23:10
  • @tribbloid The error message tells the opposite; "unresolved reference" means that the import did not happen, maybe due to the back-ticks used, where I'd not be too certain, that they're legitimate syntax. Have you tried to replace that broken import with the one's suggested? – Martin Zeitler Nov 29 '21 at 06:08