سؤال

For some reason I cannot simultaneously specify main class for run and packaging jar in SBT 0.12.3.

The problem is that sbt publish-local doesn't put name of main class to jar's manifest if I don't set it explicitly.

But interestingly enough this

mainClass in (Compile,run) := Some("Hi")

and

mainClass in (Compile,packageBin) := Some("Hi")

work separately but this

mainClass in (Compile,run,packageBin) := Some("Hi")

causes SBT fail with following error

C:\work\test_projects\hw\build.sbt:13: error: reassignment to val
mainClass in (run,Compile,packageBin) := Some("Hi")
                                      ^
[error] Type error in expression

Is it a bug or am I missing something ?

هل كانت مفيدة؟

المحلول

The (Compile,run) in

mainClass in (Compile,run) := Some("Hi")

is specifying the two axes of the four axes that a setting has, so (Compile,run,packageBin) doesn't make sense. If you want to grab the value from the other, you could say:

mainClass in (Compile,packageBin) <<= mainClass in (Compile,run)

For more details, check out Getting Started guide.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top