我是一个SBT插件的作者:https://github.com/atais/sbt-eclipselink-static-weave
它的目的是使用提供的增强编译的类。
为了实现这一步,我已经用以下方法覆盖了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或publish 期间生成一个空jar,如果编译的源代码事先不可用的话。
您可能需要检查我的拉请求,在那里我准备了一个测试项目和测试场景。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不会重新启动。这是我第二次打电话给包裹。
我怎么能第一次生产出合适的罐子呢?
发布于 2021-07-27 14:44:56
好吧,原来我应该用
productDirectories in Compile := Seq(weavedClassesDest.value),而不是
products in Compile := Seq(weavedClassesDest.value),现在它似乎起作用了
https://stackoverflow.com/questions/53324777
复制相似问题