Usage

Besides your maven projects for development that produce artifacts like jars, wars, ears, etc. you create a maven projects for your deployment packages. There you set the packaging to "solaris" and add dependencies to your development project(s) as needed. If you have more than one deployment package, you should use a parent project with packaging "pom" where each deployment package is inherited from.

Resources

Typically there are resources such as start-/stop-skripts, additional config files, license files, etc. that should be deployed without modification. Such files should be put under src/main/resources/ROOT/<PATH> where PATH is the absolute installation path on the deployment machine (e.g. opt/foo or var/log/bar).

Templates

Templates are like resources but contain variables that will be replaced by maven when building the package. This can be done in the same way as for regular resources using filtered resources (see here).

You may want to create a configuration package from a single maven project with different results for various target systems. Be aware that this is agains the philosophy of maven that says "one artifact per project". Anyways you can use a varibale in the declaration of the according filter:

<filter>src/main/filters/filter-${package.profile}.properties</filter>
         
Then you need to supply the profile when calling maven. E.g.:
mvn -Dpackage.profile=linux-test
        

In any case you will need the following templates located at "src/main/templates":

  • A file named "pkginfo" with the following content:
CLASSES="none"
PKG=${project.artifactId}
NAME="${project.name}"
DESC="${project.description}"
VERSION=${project.version}
ARCH=none
CATEGORY=application
ISTATES="S s 1 2 3"
RSTATES="S s 1 2 3"
         
  • A file named "prototype.template" with the following content (The first line is needed others are an example.):
i pkginfo=${project.build.outputDirectory}/pkginfo
d none / 0755 root root
d none /opt 0755 root sys
d none /var 0755 root sys
s none /opt/foo/var=/var/foo
         

Dependencies

To include your development artifacts in the package, add the master development project(s) as dependency. To include them in the package use the maven-dependency-plugin that can copy these including all transitive dependnecies from the local repository to a configurable directory that should be ${project.build.outputDirectory}/ROOT/<PATH> where PATH is the absolute installation path on the deployment machine (e.g. opt/foo/lib).

Parent POM

The parent POM for the deployment packages should look similar to this example:

<project>
  <modelVersion>4.0.0</modelVersion>
  <!-- fill out the ... with real values -->
  <groupId>...</groupId>
  <artifactId>...</artifactId>
  <name>...</name>
  <version>...</version>
  <description>...</description>
  <packaging>solaris</packaging>
  <build>  
    <outputDirectory>target/package</outputDirectory>
    <!-- if you want to separate templates from resources -->
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
      </resource>
      <resource>
        <directory>src/main/templates</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>solaris-maven-plugin</artifactId>
        <!-- IMPORTANT: the extensions flag is required to activate the 'solaris' packaging -->
        <extensions>true</extensions>
        <!-- these are all the defaults and should fit -->
        <configuration>         
          <!-- <packageName>${project.artifactId}</packageName> -->
          <!-- <packageFilename>${project.artifactId}-${project.version}.pkg</packageFilename> -->
          <!-- <outputDirectory>${project.build.outputDirectory}</outputDirectory> -->
          <!-- <outputRootFolder>ROOT</outputRootFolder> -->
          <!-- <packageRoot>/</packageRoot> -->
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>