Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javaOptions should not come after mainclass #598

Closed
woshilaiceshide opened this issue Jun 11, 2015 · 10 comments
Closed

javaOptions should not come after mainclass #598

woshilaiceshide opened this issue Jun 11, 2015 · 10 comments
Labels
bug documentation Documentation should be extended or updated universal Zip, tar.gz, tgz and bash issues

Comments

@woshilaiceshide
Copy link

to reproduce the bug with sbt-native-packager(1.0.2) in a give sbt project,

  1. in project/plugins.sbt:
    addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.10.2")
  2. in build.sbt:
    javaOptions in Universal ++= (AspectjKeys.weaverOptions in Aspectj).value
  3. type "dist"
  4. in the target/universal/xxx-xxx.zip/bin/xxx, we will find that "-javaagent:.../aspectjweaver-1.8.5.jar" is fed to mainclass as the application's argument, which is not expected.

I use the following statement in build.sbt as a workaround:
bashScriptExtraDefines += s"""addJava "${(AspectjKeys.weaverOptions in Aspectj).value.mkString(" ")}""""

@woshilaiceshide
Copy link
Author

the workaround mentioned in the previous is wrong, use the following:
bashScriptExtraDefines ++= (AspectjKeys.weaverOptions in Aspectj).value.map("addJava " + _)

@muuki88 muuki88 added bug universal Zip, tar.gz, tgz and bash issues documentation Documentation should be extended or updated labels Jun 11, 2015
@muuki88
Copy link
Contributor

muuki88 commented Jun 12, 2015

Sorry, this was a point of missing documentation. Prefixing arguments with -J makes the start script recognize these as jvm arguments. So in your case

javaOptions in Universal ++= (AspectjKeys.weaverOptions in Aspectj).value.map { prop =>
   "-J" + prop
}

I know this is counter-intuitive to what javaOptions means. However it's better than the
bashScriptExtraDefines IMHO.

You can test your settings easly by starting the bash script with -d, e.g.

sbt stage
./target/universal/stage/bin/test-project-simple -d

@muuki88 muuki88 closed this as completed Jun 12, 2015
muuki88 added a commit that referenced this issue Jun 15, 2015
FIX #599 #598 Extended docs for application customization
@woshilaiceshide
Copy link
Author

why not make javaOptions goes before mainClass automatically?
"javaOptions" implies "java's options, not app's options".

@muuki88
Copy link
Contributor

muuki88 commented Jun 17, 2015

I agree that this is a bit confusing. We kept it this way as the configuration files worked the same way before. So you don't have to change anything.

An additional setting appOptions would be appropriate. If you want to do a pull request? However I'm not sure how much this feature is used and how big the impact would be.

@woshilaiceshide
Copy link
Author

I WILL make a pull request, in which the javaOptions will be "java's options", and "appOptions" will be "app's options".
This will happen after this busy week.

@muuki88
Copy link
Contributor

muuki88 commented Jun 19, 2015

Awesome @woshilaiceshide :)

It would be really awesome if previous javaOptions in Universal configurations would still work.
The easiest way would be to alter (prefixing with -J, beside some exceptions, see bashscript) the settings before they get written to the application.ini file.

A new appOptions setting would then be written unchanged. I hope we can keep things backwards compatible and don't have to touch the bashscript and avoid using the bashScriptExtraDefines

@muuki88 muuki88 reopened this Jun 19, 2015
@woshilaiceshide
Copy link
Author

I am very sorry for the above promise.
If you do not mind, should I delay my pull request for some weeks.
My busy days make my time fly recently.
Your reply is expected.

@muuki88
Copy link
Contributor

muuki88 commented Jun 26, 2015

That's no problem. Just ping when you need any help after you started :)

@muuki88 muuki88 closed this as completed Mar 20, 2016
@kayvank
Copy link

kayvank commented Jul 6, 2016

I had a similar issue and using the suggesion above resolved it.

javaOptions in Universal ++= (AspectjKeys.weaverOptions in Aspectj).value.map { prop =>
  "-J" + prop
}

@muuki88
Copy link
Contributor

muuki88 commented Jul 6, 2016

Thanks for sharing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug documentation Documentation should be extended or updated universal Zip, tar.gz, tgz and bash issues
Projects
None yet
Development

No branches or pull requests

3 participants