Re: Importing pleasings into build_defs

61 views
Skip to first unread message

Peter Ebden

unread,
Sep 3, 2019, 8:01:24 AM9/3/19
to Marc Guilera, please-build
I think we covered this on Gitter in the end, but for posterity / anyone else reading: you can subinclude from inside a build_defs file just as you can from a normal BUILD file. In this case you'd just add 

subinclude("///pleasings//kotlin")

or similar to the top of your own kotlin.build_defs.

On Tue, 3 Sep 2019 at 11:18, Marc Guilera <marcgu...@gmail.com> wrote:
The general question is: How can I import/use functions from a pleasing inside of a build_defs file? 

In my example I am trying to create a set of rules around the kotlin pleasing which internally will use its functions but with some extra functionality convenient for my project (default srcs, resources, etc). 

My code looks like:

kotlin/BUILD

subinclude(""pleasings/kotlin")
filegroup(
 name = "
kotlin",
 srcs = ["
kotlin.build_defs"],
 deps = ["
:kotlin_pleasing"],
 visibility = ["
PUBLIC"]
)


kotlin/kotlin.build_defs

def kt_library(
 name
:str,
 srcs
:list = None,
 resources
:list = None,
 deps
:list = [],
 exported_deps
:list = [],
 test_only
:bool = False,
 visibility
:list = None):
 
if not srcs:
 srcs
= glob(["src/main/kotlin/**/*.kt"])
 
 
if not resources:
 resources
= glob(["src/main/resources/**"])

 result
= kotlin_library(
 name
= name,
 srcs
= srcs,
 resources
= resources,
 deps
= deps,
 exported_deps
= exported_deps,
 visibility
= visibility
 
)

 
return result


From elsewhere I would use kt_library instead of kotlin_library. Now, the issue is that kotlin_library does not exist in the scope of the build_defs and I would like to use it. How can I import it?

Thanks!

--
You received this message because you are subscribed to the Google Groups "please-build" group.
To unsubscribe from this group and stop receiving emails from it, send an email to please-build...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/please-build/0c2323ba-1889-4b80-ba06-f301cf929288%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages