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. triggered package or run 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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -