Я являюсь автором плагина 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 скомпилированные источники не доступны заранее.
Возможно, вы захотите проверить мой pull-запрос, где я подготовил тестовый проект с тестовым сценарием.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 не перезапускается между этими запусками.Это всего лишь второй раз, когда я вызываю пакет.
Как я мог изготовить правильную банку при первом запуске?