Переношу старую многопроектную сборку с Groovy DSL на Kotlin DSL. В корневом build.gradle был такой блок.
subprojects {
apply plugin: 'java-library'
repositories { mavenCentral() }
}
Корень переведён механически.
subprojects {
apply(plugin = "java-library")
repositories { mavenCentral() }
}
Дальше по порядку.
Корневой скрипт компилируется. Здесь претензий нет.
В подпроекте core/build.gradle.kts строка implementation(project(":util")) внутри dependencies останавливает компиляцию скрипта с неразрешённой ссылкой на implementation. Под Groovy та же строка работала.
Необъяснимый случай - третий. Стоит добавить plugins { id("java-library") } в начало того же файла, и ошибка пропадает, хотя корень и так применял этот плагин. Плагин тот же, проект тот же, почему пропадают только аксессоры? И неужели задуманное решение - повторять блок plugins в каждом подпроекте?
Переведено с английского·Показать оригиналMoving an old multi-project build from the Groovy DSL to the Kotlin DSL. The root build.gradle had this block.
subprojects {
apply plugin: 'java-library'
repositories { mavenCentral() }
}
The root I converted mechanically.
subprojects {
apply(plugin = "java-library")
repositories { mavenCentral() }
}
In order, then.
The root script compiles. No problem there.
In the subproject core/build.gradle.kts, the line implementation(project(":util")) inside dependencies stops script compilation with an unresolved reference to implementation. The same line worked under Groovy.
Case three is the one I can't explain. Put plugins { id("java-library") } at the top of that same file and the error goes away, even though the root was already applying the plugin. Same plugin, same project, so why do only the accessors disappear? And is repeating a plugins block in every subproject really the intended fix?