SBT 包在增强编译后生成空 JAR 类
SBT package produces empty JAR after enhancing compiled classes
我是 SBT 插件的作者:https://github.com/atais/sbt-eclipselink-static-weave
它的目的是增强编译类使用提供的StaticWeaveProcessor
。
为了完成这一步,我已经覆盖了 compile
步骤:
override def projectSettings: Seq[Def.Setting[_]] = Seq(
...
// https://www.scala-sbt.org/1.0/docs/Howto-Dynamic-Task.html#build.sbt+v2
compile in Compile := Def.taskDyn {
val c = (compile in Compile).value
Def.task {
(copyResources in Compile).value // we need to copy META-INF folder first, https://github.com/sbt/sbt/issues/3934
weaveTask.value
c
}
}.value
)
问题
使用此插件的项目可以正确编译,但它们 可能 在 package
或 [=17] 期间生成 空 jar =] IF 事先没有编译好的源代码。
您可能想查看我的拉取请求,我在其中准备了一个带有测试场景的测试项目。
https://github.com/atais/sbt-eclipselink-static-weave/pull/2
详情
我已经尝试打印所有设置和映射,但它们看起来还不错。
但是,我发现 Package.Configuration
步骤正在使用 cacheStoreFactory: CacheStoreFactory
,我认为这是我的问题。
在函数 makeJar(sources.toSeq, jar.file, manifest, log)
中有一个 log.debug(sourcesDebugString(sources))
在第一个 运行:
上给出空结果
[info] Finished EclipseLink static weaving in 610 ms.
[info] Packaging /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/test_2.12-0.1.0-SNAPSHOT.jar ...
[debug] Input file mappings:
[debug]
但正确列出了第二个文件:
[info] Finished EclipseLink static weaving in 559 ms.
[info] Packaging /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/test_2.12-0.1.0-SNAPSHOT.jar ...
[debug] Input file mappings:
[debug] META-INF/persistence.xml
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/META-INF/persistence.xml
[debug] META-INF
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/META-INF
[debug] com
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com
[debug] META-INF/orm-rtb.xml
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/META-INF/orm-rtb.xml
[debug] com/github/atais/entity
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github/atais/entity
[debug] com/github
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github
[debug] com/github/atais
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github/atais
[debug] com/github/atais/entity/EntityB.class
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github/atais/entity/EntityB.class
[debug] com/github/atais/entity/EntityA.class
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github/atais/entity/EntityA.class
SBT 在 运行 秒之间未重新启动。这是我第二次调用 package.
我怎样才能在第一个 运行 上生成合适的 jar?
好的,原来我应该用
productDirectories in Compile := Seq(weavedClassesDest.value),
而不是
products in Compile := Seq(weavedClassesDest.value),
现在似乎可以正常工作了
我是 SBT 插件的作者:https://github.com/atais/sbt-eclipselink-static-weave
它的目的是增强编译类使用提供的StaticWeaveProcessor
。
为了完成这一步,我已经覆盖了 compile
步骤:
override def projectSettings: Seq[Def.Setting[_]] = Seq(
...
// https://www.scala-sbt.org/1.0/docs/Howto-Dynamic-Task.html#build.sbt+v2
compile in Compile := Def.taskDyn {
val c = (compile in Compile).value
Def.task {
(copyResources in Compile).value // we need to copy META-INF folder first, https://github.com/sbt/sbt/issues/3934
weaveTask.value
c
}
}.value
)
问题
使用此插件的项目可以正确编译,但它们 可能 在 package
或 [=17] 期间生成 空 jar =] IF 事先没有编译好的源代码。
您可能想查看我的拉取请求,我在其中准备了一个带有测试场景的测试项目。 https://github.com/atais/sbt-eclipselink-static-weave/pull/2
详情
我已经尝试打印所有设置和映射,但它们看起来还不错。
但是,我发现 Package.Configuration
步骤正在使用 cacheStoreFactory: CacheStoreFactory
,我认为这是我的问题。
在函数 makeJar(sources.toSeq, jar.file, manifest, log)
中有一个 log.debug(sourcesDebugString(sources))
在第一个 运行:
[info] Finished EclipseLink static weaving in 610 ms.
[info] Packaging /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/test_2.12-0.1.0-SNAPSHOT.jar ...
[debug] Input file mappings:
[debug]
但正确列出了第二个文件:
[info] Finished EclipseLink static weaving in 559 ms.
[info] Packaging /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/test_2.12-0.1.0-SNAPSHOT.jar ...
[debug] Input file mappings:
[debug] META-INF/persistence.xml
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/META-INF/persistence.xml
[debug] META-INF
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/META-INF
[debug] com
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com
[debug] META-INF/orm-rtb.xml
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/META-INF/orm-rtb.xml
[debug] com/github/atais/entity
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github/atais/entity
[debug] com/github
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github
[debug] com/github/atais
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github/atais
[debug] com/github/atais/entity/EntityB.class
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github/atais/entity/EntityB.class
[debug] com/github/atais/entity/EntityA.class
[debug] /home/atais/Documents/sbt-eclipselink-static-weave/sbt-test/target/scala-2.12/classes-weaved/com/github/atais/entity/EntityA.class
SBT 在 运行 秒之间未重新启动。这是我第二次调用 package.
我怎样才能在第一个 运行 上生成合适的 jar?
好的,原来我应该用
productDirectories in Compile := Seq(weavedClassesDest.value),
而不是
products in Compile := Seq(weavedClassesDest.value),
现在似乎可以正常工作了