mojohaus / appassembler

https://www.mojohaus.org/appassembler/
MIT License
93 stars 49 forks source link

Add posibility to change the current working directory/folder #56

Open lukaszm89 opened 7 years ago

lukaszm89 commented 7 years ago

When creating bat and sh files with assemble there should be possibility to force script to set up working directory before java execution. The problem here is that when executing bat file from different directory then app/bin application base path is set to that other directory rather than app directory. An example: When we create new File(".") in our application and print its absolute path D:\test_app> bin\test_app.bin -> D:\test_app\. but when we try to run the same bat file but from different current directory: D:\other_dir\my_stuff> D:\test_app\bintest_app.bin -> D:\other_dir\my_stuff\.

This can be done with: pushd %BASEDIR% before calling java and then popd and the end of the script to revert this change. This will ensure that app always has set correct working directory and for example logging libraries that are using relative paths will log to correct directory inside our app folder and not inside current user directory.