SBT package produces empty JAR after enhancing compiled classes



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am an author of a SBT plugin: https://github.com/atais/sbt-eclipselink-static-weave

It's purpose is to enhance compiled classes using provided StaticWeaveProcessor.



To achieve this step I have overriden the compile step with:



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
)


Problem



Projects using this plugin compile properly, but they might produce an empty jar, during package or publish IF the compiled sources are not available beforehand.



You might want to check my pull-request where I have prepared a test project with test scenario.
https://github.com/atais/sbt-eclipselink-static-weave/pull/2



Details



I have tried printing all the settings and mappings, but they seem fine.



However, I have found, that Package.Configuration step is using cacheStoreFactory: CacheStoreFactory which I think is my problem.



during the function makeJar(sources.toSeq, jar.file, manifest, log) there is a log.debug(sourcesDebugString(sources)) which gives empty result on first run:



[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]


but properly lists files on the second:



[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 is not restarted between this runs. It's just second time I call package.



How could I produce proper jar on first run?










share|improve this question
























  • I am afraid I miss the question. What do you expect to achieve? You want the jar not to be empty? Or you want SBT restarted?

    – Suma
    Nov 15 '18 at 21:56











  • Jar should not be empty

    – Atais
    Nov 15 '18 at 22:57

















1















I am an author of a SBT plugin: https://github.com/atais/sbt-eclipselink-static-weave

It's purpose is to enhance compiled classes using provided StaticWeaveProcessor.



To achieve this step I have overriden the compile step with:



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
)


Problem



Projects using this plugin compile properly, but they might produce an empty jar, during package or publish IF the compiled sources are not available beforehand.



You might want to check my pull-request where I have prepared a test project with test scenario.
https://github.com/atais/sbt-eclipselink-static-weave/pull/2



Details



I have tried printing all the settings and mappings, but they seem fine.



However, I have found, that Package.Configuration step is using cacheStoreFactory: CacheStoreFactory which I think is my problem.



during the function makeJar(sources.toSeq, jar.file, manifest, log) there is a log.debug(sourcesDebugString(sources)) which gives empty result on first run:



[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]


but properly lists files on the second:



[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 is not restarted between this runs. It's just second time I call package.



How could I produce proper jar on first run?










share|improve this question
























  • I am afraid I miss the question. What do you expect to achieve? You want the jar not to be empty? Or you want SBT restarted?

    – Suma
    Nov 15 '18 at 21:56











  • Jar should not be empty

    – Atais
    Nov 15 '18 at 22:57













1












1








1








I am an author of a SBT plugin: https://github.com/atais/sbt-eclipselink-static-weave

It's purpose is to enhance compiled classes using provided StaticWeaveProcessor.



To achieve this step I have overriden the compile step with:



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
)


Problem



Projects using this plugin compile properly, but they might produce an empty jar, during package or publish IF the compiled sources are not available beforehand.



You might want to check my pull-request where I have prepared a test project with test scenario.
https://github.com/atais/sbt-eclipselink-static-weave/pull/2



Details



I have tried printing all the settings and mappings, but they seem fine.



However, I have found, that Package.Configuration step is using cacheStoreFactory: CacheStoreFactory which I think is my problem.



during the function makeJar(sources.toSeq, jar.file, manifest, log) there is a log.debug(sourcesDebugString(sources)) which gives empty result on first run:



[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]


but properly lists files on the second:



[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 is not restarted between this runs. It's just second time I call package.



How could I produce proper jar on first run?










share|improve this question
















I am an author of a SBT plugin: https://github.com/atais/sbt-eclipselink-static-weave

It's purpose is to enhance compiled classes using provided StaticWeaveProcessor.



To achieve this step I have overriden the compile step with:



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
)


Problem



Projects using this plugin compile properly, but they might produce an empty jar, during package or publish IF the compiled sources are not available beforehand.



You might want to check my pull-request where I have prepared a test project with test scenario.
https://github.com/atais/sbt-eclipselink-static-weave/pull/2



Details



I have tried printing all the settings and mappings, but they seem fine.



However, I have found, that Package.Configuration step is using cacheStoreFactory: CacheStoreFactory which I think is my problem.



during the function makeJar(sources.toSeq, jar.file, manifest, log) there is a log.debug(sourcesDebugString(sources)) which gives empty result on first run:



[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]


but properly lists files on the second:



[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 is not restarted between this runs. It's just second time I call package.



How could I produce proper jar on first run?







scala sbt sbt-plugin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 9:04







Atais

















asked Nov 15 '18 at 17:18









AtaisAtais

5,49734673




5,49734673












  • I am afraid I miss the question. What do you expect to achieve? You want the jar not to be empty? Or you want SBT restarted?

    – Suma
    Nov 15 '18 at 21:56











  • Jar should not be empty

    – Atais
    Nov 15 '18 at 22:57

















  • I am afraid I miss the question. What do you expect to achieve? You want the jar not to be empty? Or you want SBT restarted?

    – Suma
    Nov 15 '18 at 21:56











  • Jar should not be empty

    – Atais
    Nov 15 '18 at 22:57
















I am afraid I miss the question. What do you expect to achieve? You want the jar not to be empty? Or you want SBT restarted?

– Suma
Nov 15 '18 at 21:56





I am afraid I miss the question. What do you expect to achieve? You want the jar not to be empty? Or you want SBT restarted?

– Suma
Nov 15 '18 at 21:56













Jar should not be empty

– Atais
Nov 15 '18 at 22:57





Jar should not be empty

– Atais
Nov 15 '18 at 22:57












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324777%2fsbt-package-produces-empty-jar-after-enhancing-compiled-classes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53324777%2fsbt-package-produces-empty-jar-after-enhancing-compiled-classes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo