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

First cut at a getting started guide which is more useful than what we had #208

Merged
merged 12 commits into from
Apr 2, 2014
Original file line number Diff line number Diff line change
@@ -44,4 +44,8 @@ You can see the license file is now included in the distribution.

TODO - Describe linuxPackageMappings

TODO - Transition into Writing documentation (like man pages).
With control over mappings, you can rework any aspect of the native packager defaults just be overriding
which files are used. However, sometimes the defaults don't need to be completely replaced, just altered a bit.

Next, let's look at :doc:`how to provide our own BASH template <OverridingTemplates>` that the native packager will use when generating
the script.
70 changes: 70 additions & 0 deletions src/sphinx/GettingStartedApplications/OverridingTemplates.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Overriding templates
####################

While the native packager tries to provide robust BASH/BAT scripts for your applications, they may not always be enough.
The native packager provides a mechanism where the template used to create each script can be directly overridden.

Let's override the default BASH template. To do so, we'll create a file in ``src/templates/bash-template``

.. code-block:: bash
#!/usr/bin/env bash
realpath() {
# TODO - The original bash template has a robust mechanism to find the true
# path to your application, following multiple symlinks.
#
}
addJava() {
# Here we override the original templates addJava method to do nothing,
# since this was how we were adding configuration before.
}
declare -r real_script_path="$(realpath "$0")"
# We have to provide an app_home for the default bash declarations to work.
declare -r app_home="$(realpath "$(dirname "$real_script_path")")"
# The auto-generated classpath relies on this variable existing
# and pointing at the lib directory.
declare -r lib_dir="$(realpath "${app_home}/../lib")"
# This line tells the native packager template engine to inject
# all of its settings into this spot in the bash file.
${{template_declares}}
# Here we make use of two of the injected settings for the bash file:
# * app_classpath - represents the full list of JARs for this applciation.
# * app_mainclass - represents the class with a main method we should call.
exec java -cp $app_classpath $app_mainclass $@
Similarly the windows BAT template can be overridden by placing a new template in ``src/templates/bat-template``

.. code-block:: bat
@REM A bat starter script
@echo off
@REM Here we need to set up a "home" variable for our classpath.
@REM The APP_ENV_NAME variable is replaced by the packager template engine
@REM with an "environment variable friendly" name for the app.
if "%@@APP_ENV_NAME@@_HOME%"=="" set "@@APP_ENV_NAME@@_HOME=%~dp0\\.."
set "APP_LIB_DIR=%@@APP_ENV_NAME@@_HOME%\lib\"
@REM - This tells the template engine to inject any custom defines into our bat file here.
@@APP_DEFINES@@
@REM - Here we use the provided APP_CLASSPATH and APP_MAIN_CLASS parameters
java -cp "%APP_CLASSPATH%" %APP_MAIN_CLASS% %*
While we just replaced the default templates with simpler templates, this should really only be done if:

1. There is a bug in one of the script templates you need to workaround
2. There is a deficiency in the features of one of the templates you need to fix.

In general, the templates are intended to provide enough utility that customization is only necessary for truly custom scripts.

Next, let's look at how to :doc:`document the application <WritingDocumentation>`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Getting Started with sbt-native-packager
########################################
Getting Started with Applications
#################################

The sbt-native-packager is an sbt plugin for bundling your application for a variety of platforms.

@@ -15,4 +15,5 @@ neeeded to generate the best package possible.
MyFirstProject.rst
AddingConfiguration.rst
GeneratingFiles.rst
OverridingTemplates.rst
WritingDocumentation.rst
27 changes: 27 additions & 0 deletions src/sphinx/GettingStartedServers/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Getting Started with Servers
############################

The sbt-native-packager is an sbt plugin for bundling your server for a variety of platforms.

**Note:** Please follow the :ref:`Installation` instructions for how to set it up on a project.

The sbt-native-packager attempts to make building packages for different operating systems easier. While it provides
some basic abstractions around packaging, it also allows you to dig down into the nuts and bolts of each platform as
neeeded to generate the best package possible.

Currently the native package supports the following installation targets for servers:

+---------------+--------------------+-----------+
| Platform | Service Manager | Working |
+===============+====================+===========+
| Ubuntu | Upstart | X |
+---------------+--------------------+-----------+
| Ubuntu | System V | X |
+---------------+--------------------+-----------+
| CentOS | System V | X |
+---------------+--------------------+-----------+
| Fedora | System V | X |
+---------------+--------------------+-----------+
| Windows | Windows Services | |
+---------------+--------------------+-----------+

3 changes: 2 additions & 1 deletion src/sphinx/index.rst
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ to allow native packages to be created for all major operating systems, includin
:maxdepth: 1

installation.rst
/GettingStarted/index.rst
/GettingStartedApplications/index.rst
/GettingStartedServers/index.rst
/DetailedTopics/index.rst