简体   繁体   English

如何在我的应用程序中包含 Skylark 配置解析器?

[英]How do I include a Skylark configuration parser in my application?

I like the idea of configuring my Java application with restricted Python code.我喜欢使用受限制的 Python 代码配置我的 Java 应用程序的想法。 This restrained Python configuration language goes by the name of Skylark.这种内敛的 Python 配置语言名为 Skylark。 I found a Go library for Skylark support , but I need a Java one.我找到了一个支持 SkylarkGo 库,但我需要一个 Java

Which maven artifact from the bazel project or buck project can I add to my pom.xml dependencies section to get Skylark support library?我可以将 bazel 项目或 buck 项目中的哪个 maven 工件添加到我的pom.xml依赖项部分以获取 Skylark 支持库?

Until #2367 is resolved, the following worked for me.#2367解决之前,以下对我有用 Build Skylark_deploy.jar with Bazel and add it to your Maven project as a system dependency.使用 Bazel 构建 Skylark_deploy.jar 并将其作为系统依赖项添加到您的 Maven 项目中。 This results in your classpath being a mess, essentially, but it is quick to set up and enables practical experimentation.这本质上会导致您的类路径变得一团糟,但它可以快速设置并启用实际实验。

Warning: Skylark has not yet stabilized its API, so anything under com.google.devtools is subject to unannounced change.警告:Skylark 尚未稳定其 API,因此 com.google.devtools 下的任何内容都可能会发生未经宣布的更改。

Build Skylark_deploy.jar with Bazel使用 Bazel 构建 Skylark_deploy.jar

git clone git@github.com:bazelbuild/bazel.git --depth 1
cd bazel
bazel build //src/main/java/com/google/devtools/skylark:Skylark
bazel build //src/main/java/com/google/devtools/skylark:Skylark_deploy.jar

Check that it works, either of the two command below should start Skylark REPL检查它是否有效,以下两个命令中的任何一个都应该启动 Skylark REPL

bazel-bin/src/main/java/com/google/devtools/skylark/Skylark
java -jar bazel-bin/src/main/java/com/google/devtools/skylark/Skylark_deploy.jar

The Skylark_deploy.jar is currently 9.4MiB in size. Skylark_deploy.jar 目前的大小为 9.4MiB。

Add it to your Maven project as a system dependency将其作为系统依赖项添加到您的 Maven 项目中

<systemPath>${project.basedir}/lib/Skylark_deploy.jar</systemPath>

Or use Gradle或者使用 Gradle

compile files('lib/Skylark_deploy.jar')

See https://github.com/bazelbuild/bazel/blob/0f99c3cc0b7b82e198c8f365254493fc4713edcd/src/main/java/com/google/devtools/starlark/cmd/Starlark.java for initial inspiration.请参阅https://github.com/bazelbuild/bazel/blob/0f99c3cc0b7b82e198c8f365254493fc4713edcd/src/main/java/com/google/devtools/starlark/cmd/Starlark.java以获得初步灵感。 (Skylark was renamed to Starlark at one point.) (Skylark 曾一度更名为 Starlark。)

See https://github.com/google/copybara/blob/d4f9bd37ddf6eb51f1072ffb4e61332f7c410624/java/com/google/copybara/config/SkylarkParser.java and then https://github.com/google/copybara/blob/d4f9bd37ddf6eb51f1072ffb4e61332f7c410624/java/com/google/copybara/Core.java for even better inspiration.https://github.com/google/copybara/blob/d4f9bd37ddf6eb51f1072ffb4e61332f7c410624/java/com/google/copybara/config/SkylarkParser.java然后https://github.com/google/copybara/blob/d4f9bd37ddf6eb51f1072ffb4e61332f7c410624/java/ com/google/copybara/Core.java以获得更好的灵感。

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

相关问题 我如何将这种Azure配置的子域获取到我的android应用程序 - How do i get my subdomain for this azure configuration to my android application 如何在我的Web应用程序之外移动spring xml配置? - How do I move my spring xml configuration outside of my web application? 如何在应用程序中使用ua-parser? - How can I use ua-parser in my application? 如何在我的dropwizard应用程序中的单元测试中创建配置对象? - How do I create configuration object in a unit test in my dropwizard application? 如何使用配置类在 Spring Boot 中为我的应用程序配置属性? - How do I use a configuration class to configure properties for my application in Spring Boot? 如何为 java/jsf 代码制作自己的解析器? - How do I make my own parser for java/jsf code? 如何将Spring Security配置“包含”到应用程序中 - How to “include” Spring Security configuration into application 如何包括Webstart应用程序的外部配置 - How to include external configuration for webstart application 如何解决我的应用程序中的解析器错误? - how to solve parser error in my application? 如何指定要在Java Webstart应用程序中使用的注销配置? - How do I specify a logback configuration for use in a Java webstart application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM