{scrollbar}
{anchor:top}
h1. 6.9. Branding the Console
This chapter will guide you how to brand the Karaf console.
By branding, it means that you can define your own welcome message and console prompt.
h2. Create your branding bundle
At startup, Karaf is looking for a bundle which export {{org.apache.karaf.branding}} package containing a {{branding.properties}}
file.
So you need to create a very simply bundle just containing a {{org/apache/karaf/branding/branding.properties}} file.
The Maven POM of your branding bundle should looks like:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>your.group.id</groupId>
<artifactId>your.branding.artifact.id</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>Your Branding Bundle Name</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.2</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</bundle-SymbolicName>
<Import-Package>*</Import-Package>
<Private-Package>!*</Private-Package>
<Export-Package>
org.apache.karaf.branding
</Export-Package>
<Spring-Context>*;public-context:=false</Spring-Context>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
{code}
Now, add a {{src/main/resources/org/apache/karaf/branding/branding.properties}} looking like:
{{code}}
welcome = \
\u001B[36m __ __ ____ \u001B[0m\r\n\
\u001B[36m / //_/____ __________ _/ __/ \u001B[0m\r\n\
\u001B[36m / ,< / __ `/ ___/ __ `/ /_ \u001B[0m\r\n\
\u001B[36m / /| |/ /_/ / / / /_/ / __/ \u001B[0m\r\n\
\u001B[36m /_/ |_|\\__,_/_/ \\__,_/_/ \u001B[0m\r\n\
\r\n\
\u001B[1m Apache Karaf\u001B[0m (${project.version})\r\n\
\r\n\
Hit '\u001B[1m<tab>\u001B[0m' for a list of available commands\r\n\
and '\u001B[1m[cmd] --help\u001B[0m' for help on a specific command.\r\n\
Hit '\u001B[1m<ctrl-d>\u001B[0m' or '\u001B[1mosgi:shutdown\u001B[0m' to shutdown Karaf.\r\n
{{code}}
As you can see, the {{branding.properties}} contains one property:
* welcome is the welcome message displayed when you start Karaf.
As you can see, welcome string supports ASCII escaped format. For instance \u001B[1m switch the foreground in bold and \u001B[0m
switch back to normal.
h2. Installing the branding bundle
Build your branding bundle:
{code}
mvn install
{code}
and simply drop the generated jar file into the Karaf lib directory.
Start Karaf and you will see your branded Karaf console.
[#top]
{scrollbar} |