我是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
或publish
IF 期间,它们可能可能产生空罐。 strong>编译的源代码事先不可用。
您可能要检查我的拉取请求,其中我准备了带有测试方案的测试项目。 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不会重新启动。这是我第二次打电话给包裹。
在第一次运行时如何生产合适的罐子?
答案 0 :(得分:0)
好吧,原来我应该用
productDirectories in Compile := Seq(weavedClassesDest.value),
代替
products in Compile := Seq(weavedClassesDest.value),
现在它似乎工作了