简体   繁体   English

如何从project.clj文件中访问leiningen属性

[英]How to access leiningen properties from within the project.clj file

For the particular build I'm working on I need to make a call to an external command-line app using the lein-shell plugin. 对于我正在处理的特定构建,我需要使用lein-shell插件调用外部命令行应用程序。 When invoking the shell command I'd like to pass in the artifact-id and version properties that I've defined in defproject to keep the resulting artifacts the app creates consistent. 在调用shell命令时,我想传入我在defproject定义的artifact-id和version属性,以保持应用程序创建的生成工件的一致性。

In Maven I would use the ${artifactId} and ${version} properties to accomplish this. 在Maven中,我将使用${artifactId}${version}属性来完成此任务。 Is there analogous functionality in Leiningen? Leiningen有类似的功能吗?

I don't know of anything that gives you this functionality out of the box, but it's pretty straightforward to write some custom middleware to transform the project map before it gets handed off to the shell task. 我不知道任何能为您提供开箱即用功能的东西,但是在将项目映射转移到shell任务之前编写一些自定义中间件来转换项目映射非常简单。 You could hard-wire the properties in question, or get fancy and walk the project map and do the template subtitution you describe in a more general fashion. 您可以硬连接有问题的属性,或者获得幻想并走过项目地图并以更一般的方式执行您描述的模板替换。 See the plugins documentation for more information about writing middleware. 有关编写中间件的更多信息,请参阅插件文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM