https://kotlinlang.org logo
Title
s

Seri

01/15/2019, 9:46 PM
Does anybody have favorite articles or example projects for using buildSrc for handling build logic?
d

DALDEI

01/16/2019, 1:10 AM
I've just started doing this. First motivation was to generate json schema from kotlin classes during the build. I have a buildSrc that exposes a task that searches the classpath for classes with a n annotation and then generates JSON schema from them. Ive started making some primative 'dsl' for builds -- things that are not quite real 'tasks' but more complicated then a function call. I have added a major hack to work around stale local dependencies and version numbers. In a common plugin, it registers a task to all library builds that generate a versions.properties file that maps a project structure to the dependancy notation + version. Then the same plugin ..... when applied to a downstream build reads the versions file and creates the exact version dependency and artifact IDs This allows me to do something like this: dependencies { compile depends( "project-dir:sub-dir" ) } and this turns into the right compile "whatever-the-group-id-is:the-actual-artifact-id:the-exact-version" These are collected in a directory tree per build (multiple sub-projects) and merged into one big directory that contains the properties files and the actual published artfacts -- This simulates what I have the CI server doing (team city) where multiple chained dependent builds get their artifacts from specific upstream builds, tracking the version numbers. THere is certianly a better way to do this, but I have tried too many worse ways that I ended up with this --