How do you add a generator task to resourceGenerators in a SBT autoplugin? -
i writing autoplugin
in sbt. plugin should generate files resourcemanaged
. code below (work in progress), not seeing fooo
output when run compile
see when invoke task directly yamlgen
, makes me think reason task isn't added resource generator. checked bunch of other generator plugins , pretty this. whats problem here?
import sbt._ import keys._ object sampleplugin extends autoplugin { override def trigger = allrequirements val yamlsourcefolder = settingkey[file]( "yaml-source-folder", "description" ) val yamlsources = settingkey[seq[file]]( "yaml-sources", "description" ) val outputfolder = settingkey[file]( "output-folder", "description" ) val yamlgen = taskkey[seq[file]]( "yaml-gen", "description" ) def yamlsettings(conf: configuration): seq[setting[_]] = inconfig(conf)(seq( yamlsourcefolder <<= (sourcedirectory in compile) { _ / "yamin" }, yamlsources <<= yamlsourcefolder { srcdir => (srcdir ** "*.yaml").get }, outputfolder <<= (resourcemanaged in compile) { _ / "yamout" }, yamlgen <<= (streams, yamlsources, outputfolder).map { (out, sources, outputdir) => println("fooo") // implement me (outputdir ** "*.abc").get }, resourcegenerators <+= yamlgen )) override def projectsettings = yamlsettings(compile) }
found answer mark harrah on on other forum
compile
doesn't trigger resource generation because isn't needed compilation. triggeredpackage
orrun
or other tasks need resources.
however, confuses me need add yamlgen in project directly:
val root = (project in file(".")) .enableplugins(sampleplugin) .settings( resourcegenerators in compile <+= yamlgen in compile )
Comments
Post a Comment