Skip to content

Commit

Permalink
Fix #1076 add more documentation on bash and bat script configuration (
Browse files Browse the repository at this point in the history
  • Loading branch information
muuki88 authored Dec 15, 2017
1 parent b767a2d commit 0e02bbd
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 8 deletions.
74 changes: 66 additions & 8 deletions src/sphinx/archetypes/java_app/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,53 @@ There are generally two types of configurations:
* Configuring the JVM and the process
* Configuring the application itself

You have three options to define your runtime and application configurations.
You have two options to define your runtime and application configurations.

Configuration file
^^^^^^^^^^^^^^^^^^

The start scripts provided by the ``BatStartScriptPlugin`` and ``BashStartScriptPlugin`` can both load an external
configuration file during execution. You can define the configuration file location for both with these two settings.


``bashScriptConfigLocation``
The location of the bash script on the target system.

**Default** ``${app_home}/../conf/application.ini``

``batScriptConfigLocation``
The location of the bat script on the target system.

**Default** ``%APP_HOME%\conf\application.ini``


The configuration path is the path on the **target** system. This means that native-packager needs to process this path
to create a valid ``universal:mapping``s entry.
* ``${app_home}/../`` is removed
* ``%APP_HOME%`` is removed and ``\`` is being replaced with ``/``

This means you can either

1. Create a configuration path relative to the application directory (recommended)
2. Create an absolute path that has to match your target **and** build system

**Example**

.. code-block:: scala
// configure two different files for bash and bat
bashScriptConfigLocation := Some("${app_home}/../conf/jvmopts-bash")
batScriptConfigLocation := Some("%APP_HOME%\\conf\\jvmopts-bat")
Now we know how to configure the location of our configuration file. The next step is to learn how to provide content
for the configuration file.

Via build.sbt
^^^^^^^^^^^^^
"""""""""""""

First, you can specify your options via the ``build.sbt``.
You can specify your options via the ``build.sbt``.

.. code-block:: scala
Expand All @@ -34,8 +75,11 @@ First, you can specify your options via the ``build.sbt``.
For the ``-X`` settings you need to add a suffix ``-J`` so the start script will
recognize these as vm config parameters.

When you use the ``javaOptions in Universal`` sbt-native-packager will generate configuration files
if you haven't set the ``batScriptConfigLocation`` and/or ``bashScriptConfigLocation`` to ``None``.

Via Application.ini
^^^^^^^^^^^^^^^^^^^
"""""""""""""""""""

The second option is to create ``src/universal/conf/application.ini`` with the following template

Expand Down Expand Up @@ -77,13 +121,27 @@ The default configuration looks like this
.. code-block:: scala
bashScriptConfigLocation := Some("${app_home}/../conf/application.ini")
batScriptConfigLocation := Some("%APP_HOME%\\conf\\application.ini")
Add code to the start scripts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The second option is to add code to the generated start scripts via these settings.

``bashScriptExtraDefines``
A list of extra definitions that should be written to the bash file template.

``batScriptExtraDefines``
A list of extra definitions that should be written to the bat file template.


.. _bash-script-defines:

BashScript defines
^^^^^^^^^^^^^^^^^^
""""""""""""""""""

The last option is to use the ``bashScriptExtraDefines``. Generally you can add arbitrary
The bash script accepts extra commands via ``bashScriptExtraDefines``. Generally you can add arbitrary
bash commands here, but for configurations you have two methods to add jvm and app parameters.

.. code-block:: scala
Expand All @@ -105,9 +163,9 @@ bash commands here, but for configurations you have two methods to add jvm and a
.. _bat-script-defines:

BatScript defines
^^^^^^^^^^^^^^^^^
"""""""""""""""""

The Windows batch script accepts extra commands in ``batScriptExtraDefines``. It offers
The Windows batch script accepts extra commands via ``batScriptExtraDefines``. It offers
two methods to add jvm and app parameters using similar syntax to the BASH script.

.. code-block:: scala
Expand Down
8 changes: 8 additions & 0 deletions src/sphinx/archetypes/java_app/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ have sensible defaults.
``batScriptTemplateLocation``
The location of the bat script template.

``bashScriptConfigLocation``
The location of the bash script on the target system.
**Default** ``${app_home}/../conf/application.ini``

``batScriptConfigLocation``
The location of the bat script on the target system.
**Default** ``%APP_HOME%\conf\application.ini``

``bashScriptExtraDefines``
A list of extra definitions that should be written to the bash file template.

Expand Down

0 comments on commit 0e02bbd

Please sign in to comment.