Mac OS X .app launcher example from BeanMinder

For Mac OS X, the BeanMinder project builds a .app launcher structure, and archives it into a .tar.gz file.

The plugin can also be configured to create a launcher shell script, and libraries directory, then archives this into a .tar.gz file. This example will be shown later.

Note that the code of the application is in the BeanMinderCore module, and that the pom.xml shown here is from a separate BeanMinderCoreOSX module.

Here are the relevant sections of the pom.xml from that module:

...
  <dependencies>
    <dependency>
      <groupId>org.devzendo</groupId>
      <artifactId>BeanMinderCore</artifactId>
      <version>0.2.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>org.devzendo</groupId>
      <artifactId>libquaqua</artifactId>
      <type>zip</type>
      <version>9.1</version>
    </dependency>
  </dependencies>
  
  <build>
    <plugins>
      <!-- Create the Mac OS X BeanMinder.app launcher structure under 
           target/macosx. -->
      <plugin>
        <groupId>org.devzendo</groupId>
        <artifactId>cross-platform-launcher-plugin</artifactId>
        <version>1.1.1</version>
        <configuration>
          <os>MacOSX</os>
          <applicationName>BeanMinder</applicationName>
          <mainClassName>org.devzendo.minimiser.MiniMiser</mainClassName>
          <iconsFileName>BeanMinder.icns</iconsFileName>
          <bundleSignature>BM</bundleSignature>
          <stubType>Universal</stubType>
        </configuration>
        <executions>
          <execution>
            <id>createlauncher</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>createlauncher</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Copy the Quaqua native libraries into the correct location in
           the Mac OS X launcher structure created above. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.devzendo</groupId>
                  <artifactId>libquaqua</artifactId>
                  <version>9.1</version>
                  <type>zip</type>
                  <overWrite>true</overWrite>
                  <includes>*</includes>
                  <outputDirectory>${project.build.directory}/macosx/BeanMinder.app/Contents/Resources/Java/lib</outputDirectory>
                </artifactItem>
              </artifactItems>
              <!-- other configurations here -->
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Package up the above .app structure into a .tar.gz archive  -->
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptorRefs>
            <descriptorRef>macosx-launcher-distribution</descriptorRef>
          </descriptorRefs>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.devzendo</groupId>
            <artifactId>cross-platform-launcher-plugin</artifactId>
            <version>1.1.0</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>attached</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
...

Mac OS X terminal program launcher example from ArchivectCommandMacOSX

The plugin can also be configured to create a launcher shell script, and libraries directory, then archives this into a .tar.gz file.

Here are the relevant sections of the pom.xml from that project; note that this project is somewhat complicated by its use of JNI (nar) artifacts:

...
    <properties>
        <appName>ArchivectCmd</appName>
    </properties>

    <profiles>
        <profile>
            <id>mac os x</id>
            <activation>
                <os>
                    <name>mac os x</name>
                </os>
            </activation>
            <build>
                <plugins>
                    <!--
                        Create the Mac OS X Archivect command launcher structure under
                        target/macosx.
                    -->
                    <plugin>
                        <groupId>org.devzendo</groupId>
                        <artifactId>cross-platform-launcher-plugin</artifactId>
                        <version>1.1.0</version>
                        <configuration>
                            <os>MacOSX</os>
                            <launcherType>Console</launcherType>
                            <applicationName>${appName}</applicationName>
                            <mainClassName>org.devzendo.archivect.ArchivectMain</mainClassName>
                            <narClassifierTypes>
                                <param>x86_64-MacOSX-g++:jni</param>
                            </narClassifierTypes>
                            <!--
                                I don't have an assigned creator code
                                <bundleSignature>BM</bundleSignature>
                            -->
                        </configuration>
                        <executions>
                            <execution>
                                <id>createlauncher</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>createlauncher</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile> <!--  mac os x -->
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.devzendo</groupId>
            <artifactId>ArchivectCommand</artifactId>
            <version>0.1.0-SNAPSHOT</version>
            <type>nar</type>
        </dependency>
    </dependencies>

...