运行 MacOS 上 IDEA 中的 bnd 结构化应用程序:未解决的要求:导入包:com.apple.eawt

Running bnd-structured app in IDEA on MacOS: Unresolved requirement: Import-Package: com.apple.eawt

我正在尝试从 IntelliJ IDEA 运行 Alloy(prkiens/markdown 分支),以便我可以使用 IDEA 调试器。该项目使用 bnd 工作区,我以前从未处理过它。

我运行正在使用 macOS (High Sierra)。

我通过导入 build.gradle 将项目加载到 IntelliJ 中,并尝试设置一个 "Bnd OSGi" 配置到 运行 它。我不确定将哪个文件用作 Bnd 运行 描述符。我最好的猜测是使用 org.alloytools.alloy.dist/bnd.bnd。当我尝试 运行 时,出现以下错误:

! could not resolve the bundles: [org.alloytools.alloy.dist-5.0.0.201803130320 org.osgi.framework.BundleException: Could not resolve module: org.alloytools.alloy.dist [1]
  Unresolved requirement: Import-Package: com.apple.eawt

我在这里做错了什么?

请注意,使用 Gradle 构建项目效果很好:

./gradlew build
java -jar  org.alloytools.alloy.dist/target/org.alloytools.alloy.dist.jar

在你的 bnd.bnd 中尝试在底部添加:

Import-Package: \
!com.apple.eawt,\
*

没有列出依赖项通常会导致您描述的问题。

我认为有一个 IDEA bnd plugin 它不像 Eclipse 支持那么先进,但我认为它可以识别 bnd 文件。

不要从 dist 项目开始,因为这只是将不同的项目聚合到一个 JAR 中以供分发,并包含创建 MacOS pkg 文件的代码。要 运行 GUI,只需调试 SimpleGUI class。 bnd 确保连续构建所有必要的 JAR(至少在 Eclipse 上)。

就是说,省去一些工作,先熟悉 Eclipse 中的 bndtools。在 Eclipse 中,这一切都是自动运行的。一旦您理解了它是如何工作的,就应该很容易将该信息传输到 IDEA。 (并为其他人写一个 wiki 页面!)

更新 Lorin 在 readme

上添加了说明