当前位置: 首页 > 知识库问答 >
问题:

truthy不适用于sbt new

海嘉赐
2023-03-14

我用giter8创建了一个模板项目,并尝试添加条件表达式。

defaults.properties中我添加了:

param=true

在我添加的模板文件中:

  $if(param.truthy)$
  ....
  $endif$

在生成项目时,使用:

g8 file://proj.g8

一切正常
在交互部分,参数将有两个选项:

参数[是/否]:

生成的文件将包括基于参数值的附加文本

但是,当我生成项目时:

sbt new file://proj.g8

参数被视为字符串。
在交互部分,没有是/否选项:

参数[yes]:

我得到以下错误:

由于模板文件出错而退出:/tmp/giter8-135496483100759/src/main/g8/build。sbt,上下文[匿名]44:6内部错误:org。stringtemplate。v4.编译器。STException:context[匿名]44:6没有这样的属性或无法访问:java。lang.String。真实原因:org。stringtemplate。v4.misc。STNoSuchPropertyException:没有这样的属性:java。lang.String。truthy at组织。stringtemplate。v4.misc。ObjectModelAdapter。位于org的throwNoSuchProperty(ObjectModelAdapter.java:167)。stringtemplate。v4.misc。ObjectModelAdapter。位于org的getProperty(ObjectModelAdapter.java:89)。stringtemplate。v4.解释器。org上的getObjectProperty(解释器:1200)。stringtemplate。v4.解释器_org上的exec(解释器:210)。stringtemplate。v4.解释器。org上的exec(解释器:145)。stringtemplate。org上的v4.ST.write(ST.java:427)。stringtemplate。org上的v4.ST.render(ST.java:497)。拍板器。scalasti。giter8的ST.render(ST.scala:285)。G8美元。giter8的applyTemplate(g8.scala:102)。G8美元。在giter8写入(g8.scala:154)。G8美元。在giter8处写入(g8.scala:138)。G8美元$anonfun$writeTemplates$3(g8.scala:396)在scala。util。控制例外$捕获$scala上的anonfun$opt$1(例外。scala:242)。util。控制例外$捕获。在scala上应用(异常。scala:224)。util。控制例外$捕获。giter8的opt(异常。scala:242)。G8美元$anonfun$writeTemplates$2(g8.scala:396)位于scala。收集不变的流动位于giter8的foreach(Stream.scala:530)。G8美元。giter8上的writeTemplates(g8.scala:386)。G8美元$scala的anonfun$applyT$1(g8.scala:257)。util。美元RightProjection。giter8的平面图(scala:702)。G8美元。applyT(g8,scala:249)位于giter8。G8美元。giter8上的fromDirectory(g8.scala:62)。JgitHelper美元$anonfun$在scala运行$3(JgitHelper.scala:64)。util。美元RightProjection。giter8的平面图(scala:702)。JgitHelper美元。在giter8上运行(JgitHelper.scala:63)。Giter8.$anonfun$在scala运行$2(Giter8.scala:34)。选项giter8的地图(可选缩放:146)。在sbtgiter8resolver上运行(Giter8.scala:33)。Giter8TemplateResolver。在sun上运行(Giter8TemplateResolver.scala:31)。反映NativeMethodAccessorImpl。在sun调用0(本机方法)。反映NativeMethodAccessorImpl。在sun上调用(NativeMethodAccessorImpl.java:62)。反映DelegatingMethodAccessorImpl。在java上调用(DelegatingMethodAccessorImpl.java:43)。lang.reflect。方法在sbt调用(方法java:498)。TemplateCommandUtil$。在sbt调用(TemplateCommand.scala:100)。TemplateCommandUtil$。在sbt运行模板(TemplateCommand.scala:78)。TemplateCommandUtil$$anonfun$run$1(TemplateCommand.scala:58)位于sbt。TemplateCommandUtil$$anonfun$run$1$adapted(TemplateCommand.scala:54)在scala。收集LinearSEQ已优化。在scala中查找(LinearSeqOptimized.scala:111)。收集LinearSEQ已优化。在scala中查找$(LinearSeqOptimized.scala:108)。收集不变的列表在sbt查找(列表scala:86)。TemplateCommandUtil$。在sbt运行(TemplateCommand.scala:54)。TemplateCommandUtil$。在sbt运行模板(TemplateCommand.scala:41)。TemplateCommandUtil$$sbt上的anonfun$templateCommand$2(templateCommand.scala:24)。命令$$sbt上的anonfun$applyEffect$4(命令scala:134)。命令$$sbt上的anonfun$applyEffect$2(命令scala:130)。MainLoop美元。sbt处的processCommand(MainLoop.scala:153)。MainLoop美元$sbt的anonfun$下一个$2(MainLoop.scala:136)。州$$非1美元。runCmd 1美元(州级:242),sbt。州$$非1美元。sbt的过程(状态:248)。MainLoop美元$sbt的anonfun$下一个$1(MainLoop.scala:136)。内部的util。错误处理$。sbt的wideConvert(ErrorHandling.scala:16)。MainLoop美元。下一步(MainLoop.scala:136)在sbt。MainLoop美元。在sbt运行(MainLoop.scala:129)。MainLoop美元$sbt上的anonfun$runWithNewLog$1(MainLoop.scala:107)。io。使用。在sbt处应用(使用scala:22)。MainLoop美元。在sbt运行WithNewLog(主循环。scala:101)。MainLoop美元。sbt处的runAndClearLast(主循环。scala:57)。MainLoop美元。在sbt运行LoggedLoop(MainLoop.scala:42)。MainLoop美元。sbt运行记录(MainLoop.scala:34)。StandardMain美元。sbt的runManaged(主规模:113)。xMain公司。在xsbt上运行(Main.scala:76)。靴子启动$$anonfun$运行$1。在xsbt上应用(Launch.scala:109)。靴子启动$。在xsbt上使用ContextLoader(Launch.scala:128)。靴子启动$。在xsbt上运行(Launch.scala:109)。靴子启动$$anonfun$应用$1。在xsbt上应用(Launch.scala:35)。靴子启动$。在xsbt上发布(发布,scala:117)。靴子启动$。在xsbt上应用(Launch.scala:18)。靴子启动$。xsbt上的runImpl(Boot.scala:41)。靴子启动$。xsbt上的main(Boot.scala:17)。靴子靴子主(启动scala)

在giter8。G8$STErrorH_execTimeError(g8.scala:396)在giter8。G8$STErrorHscala.util.control.TimeError(xception.scala:242)在scala.util.control.ErrorMatch.applyTimeError(ErrorMxception.scala:224)在scala.util.control.v4。我atch.optObjectProperty(Ixception.scala:242)在org.stringtemplate.v4。解释器。andler.run(Interpreter.java:210)在org.stringtemplate.v4。我nterpreter.exec(我nterpreter.java:145)在org.stringtemplate.v4。ST. write(ST. java: 427)在org.stringtemplate.v4。ST.渲染(ST. java: 497)在org.clapper.scalasti.ST.渲染(ST. scala: 285)在giter8。G8$. ApplyTemboard(g8.scala:102)在giter8。G8$. write(g8.scala:154)在giter8。G8$.$anonfun$WriteTemplates3美元(g8.scala:110)在andler.run异常$Catch。$anonfun$opt1美元(Eg8.scala:105)在org.stringtemplate.v4.misc.异常$Canager.run(Eanager.java:137)在org.stringtemplate.异常$Cnterpreter.get(Enterpreter.java:1203)在giterg8$.$anonfunyT1美元(g8. scala: 257)在scar. util。giter8上的$RightProject.平面图(Either. scala: 702)。giter8上的G8$. ApplyT(g8. scala: 249)。giter8上的G8$. fromDirectory(g8. scala: 62)。Scala. util上的JgitHelper$.$anonfun$run3美元(JgitHelper. scala: 64)。giter8上的$RightProject.平面图(Either. scala: 702)。giter8上的JgitHelper$. run(JgitHelper. scala: 63)。Giter8.$anonfun$run2美元(giter8. scala: 34)在scala。giter8上的Option. map(Option. scala: 146)。giter8. run(giter8. scala: 33)在sbtg在sbt上的TemplateCommand dUtil$.$anonplay$run1美元(TemplateCommand. scala: 58)。在sbt上的TemplateCommand dUtil$.$anonfun$run1美元$适应(TemplateCommand. scala: 54)。在scala.集合上的LinearSeqOptimized. search(LinearSeqOptimized. scala: 111)。在scala.集合上的LinearSeqOptimized. scala: 108)。在sbt上的List. search(List. scala: 86)。在sbt上的TemplateOrdUtil$. run(TemplateCommand. scala: 54)。在sbt上的TemplateORdUtil$. runTemboard(TemplateCommand. scala: 41)。TemplateORdUtil$.$anonfun$templateORd2美元(TemplateCommand. scala: 24)。命令$。$anonfun$应用效果4美元(ErrorHandling$. wideConversion(ErrorHandling. scala: 16)at sbt。在sbt的MainLoop$. Next(MainLoop. scala: 136)。在sbt的MainLoop$. runLoggedLoop(MainLoop. scala: 129)。在sbt. io的MainLoop$.$anonfun$runSusNewLog1美元(MainLoop. scala: 107)。在sbt的Using. Application(Using. scala: 22)。在sbt的MainLoop$. runSusNewLog(MainLoop. scala: 101)。在sbt的MainLoop$. runAndClearLast(MainLoop. scala: 57)。在sbt的MainLoop$. runLoggedLoop(MainLoop. scala: 42)。在sbt的MainLoop$. runLogged(MainLoop. scala: 34)。在xst. xMain. run(Main. scala: 76)的Standard ardMain$.在xsbt. boot引导$. runImpl(Boot. scala: 41)。在xsbt. boot引导$. main(Boot. scala: 17)。主要(Boot. scala)

我正在为g8sbt-giter8插件使用版本0.11.0-M3

我如何解决这个问题?

编辑:更多详细信息:
我正在使用sbt 1.1.1(用于g8项目和我机器上的sbt启动器)
我在g8项目的文件项目/插件中添加了插件。sbt带

addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.11.0-M3")

如果我从模板中删除truthy部分,则项目将从sbt new中正确生成

此问题已在sbt 1.2.0中修复。要修复此问题,应使用:sbt-Dsbt。版本=1.2.0新file://proj.g8


共有1个答案

于嘉许
2023-03-14

内部用于sbt new的giter8版本是固定的,添加sbt-giter8插件不会更改它。sbt 1.1.1使用sbt-giter8-解析器v0.1.3,它使用giter8 0.7.2(不支持条件)。

您可以更新sbt-giter8-解析器,在本地发布并尝试替换默认的Giter8TemplatePlugin,但我认为这不值得。直接使用g8直到sbt更新。

曾试图支持模板中设置的任意giter8版本,但出现了一些问题,此功能已恢复。

 类似资料:
  • 问题内容: 嗨,我只是简单地尝试在www.example.com上获取h1标签,该标签显示为“ Example Domain”。该代码适用于http://www.example.com,但不适用于https://www.exmaple.com。我该如何解决这个问题?谢谢 问题答案: PhantomJSDriver不支持(所有)DesiredCapabilities。 你会需要: 记录在这里:htt

  • 所以我使用这种方法写入文件,它在windows上运行完全正常,但在mac上运行时,它会创建文件,但它们是空的。 我知道数据是正确的,因为它打印正确。感谢您的任何帮助,这真的让我绊倒了。

  • 列名称的类型为int[] 上述查询适用于postgresql,但不适用于hsqldb,甚至适用于sql 尝试的hsqldb版本:2.2.9和2.3.0 在hsqldb中工作的sql是从table_name中选择x,unnest(column_name)y(x)x和y不是该表的列。

  • 我能够成功地打电话给邮递员: /mfp/api/az/v1/token和 /mfpadmin/management-apis/2.0/runtimes/mfp/applications 我正在获取从/mfp/api/az/v1/token接收的承载令牌,并将其添加到/mfp/applications的授权标头中。 我收到了来自两者的200个响应,并从每个API中获取了预期的信息。 然后,我选择从P

  • 我一直在使用声纳3.2 同样的配置,当我升级到SonarQube 4.4时 声纳项目属性: 请帮助整理这些例外 问候, KP

  • 我已经看过并尝试了几乎所有关于这个话题的其他帖子,但运气不好。 我使用的是python 3.6,所以我使用的是以下AMI