I’m working on a (first) custom gradle plugin for my team’s projects to use.
I’m creating it for both common tasks but also to have access to the same classes/members across each project’s build.gradle files.
When I apply the plugin inside a project’s build.gradle, I can only see (IDE completion) the Java classes in my plugin.
I can’t see any of the Kotlin classes, but if I sync gradle or build/assemble, it works without any issues (i.e. the task/build does not fail).
But the non-Java class I import is red/unresolved.
Am I missing something?
t
tapchicoma
10/13/2019, 5:48 PM
depends on how you publish/consume your plugin
j
Justin
10/14/2019, 2:24 PM
@tapchicoma what do you mean? what do I need to do to be able to see the kotlin classes in my plugin?
t
tapchicoma
10/14/2019, 3:01 PM
do you also publish your plugin sources artifact? If yes - does it includes plugin kotlin files?
t
trevjones
10/14/2019, 4:32 PM
fwiw code completion in build.gradle files is usually not ideal due to the dynamics making tooling hard. Things I recently did that make things much better are, 1: use build.gradle.kts wherever possible, 2: add plugin dependencies to the
api
configuration of the
buildSrc
project which enables that full loading ahead of time.
with those two things you can usually cmd+click into sources from your build files, or even just cmd+o to jump straight to a class that is defined within a plugin jar.
j
Justin
10/15/2019, 2:02 AM
@tapchicoma I currently am just publishing it to mavenLocal(), and the plugin is written mostly in kotlin, yes
@trevjones thanks for the information; if it’s just for use in my
build.gradle
(or
build.gradle.kts
), then wouldn’t I want to do
implementation
instead of
api
? I wouldn’t want the plugin to be accessible to anyone using my library’s (the consumer of the plugin) artifact