OSDN Git Service

Macのアプリケーションバンドル作成方法の変更
authorseraphy <seraphy@users.osdn.me>
Sun, 18 Nov 2018 18:24:36 +0000 (03:24 +0900)
committerseraphy <seraphy@users.osdn.me>
Sun, 18 Nov 2018 18:25:54 +0000 (03:25 +0900)
MavenのAppBundleプラグインをやめて、Antから各種コマンドを直接呼び出すように変更。

pom.xml
src/main/attachment/bundle/CharacterManaJ.app/Contents/Info.plist [new file with mode: 0644]
src/main/attachment/bundle/CharacterManaJ.app/Contents/MacOS/java_launch.sh

diff --git a/pom.xml b/pom.xml
index 7b61229..283e5a7 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+<project xmlns="http://maven.apache.org/POM/4.0.0"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
        <modelVersion>4.0.0</modelVersion>\r
 \r
@@ -77,7 +78,7 @@
                                <!-- 実行可能jar本体のパッケージを行う (package時) -->\r
                                <groupId>org.apache.maven.plugins</groupId>\r
                                <artifactId>maven-jar-plugin</artifactId>\r
-                               <version>2.6</version>\r
+                               <version>3.1.0</version>\r
                                <configuration>\r
                                        <finalName>${project.artifactId}</finalName>\r
                                        <archive>\r
                                </os>\r
                        </activation>\r
                        <properties>\r
-                               <!-- ${hava.home}は、\r
-                               /Library/Java/JavaVirtualMachines/jdkXXX.jdk/Contents/Home/jre/ を指すので\r
-                               /Library/Java/JavaVirtualMachines/jdkXXX.jdk/ を指すように親を3つ戻す -->\r
-                               <copyJrePath>${java.home}/../../../</copyJrePath>\r
-                       </properties>\r
+                               <copyJrePath>${java.home}</copyJrePath>\r
+                       </properties>\r
                        <build>\r
                                <plugins>\r
                                        <plugin>\r
-                                               <!-- MacのAppBundleを作成する\r
-                                                       https://github.com/federkasten/appbundle-maven-plugin\r
-                                                       https://stackoverflow.com/questions/39193868/bundle-java-program-for-mac-users-with-maven-from-gnu-linux\r
-                                               -->\r
-                                               <groupId>sh.tak.appbundler</groupId>\r
-                                               <artifactId>appbundle-maven-plugin</artifactId>\r
-                                               <version>1.2.0</version>\r
-                                               <configuration>\r
-                                                       <mainClass>${mainClass}</mainClass>\r
-                                                       <iconFile>icon.icns</iconFile>\r
-                                                       <workingDirectory>$APP_ROOT/../</workingDirectory>\r
-                                                       <generateDiskImageFile>true</generateDiskImageFile>\r
-                                                       <jvmOptions>\r
-                                                               <jvmOption>-splash:$APP_ROOT/Contents/Resources/splash.png</jvmOption>\r
-                                                               <jvmOption>-Xms96m</jvmOption>\r
-                                                               <jvmOption>-Xmx128m</jvmOption>\r
-                                                       </jvmOptions>\r
-                                                       <additionalResources>\r
-                                                               <fileSet>\r
-                                                                       <directory>src/main/attachment</directory>\r
-                                                                       <includes>\r
-                                                                               <include>README_mac.txt</include>\r
-                                                                       </includes>\r
-                                                               </fileSet>\r
-                                                               <fileSet>\r
-                                                                       <directory>src/main/attachment/bundle</directory>\r
-                                                                       <includes>\r
-                                                                               <include>**/*</include>\r
-                                                                       </includes>\r
-                                                               </fileSet>\r
-                                                       </additionalResources>\r
-                                               </configuration>\r
+                                               <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-antrun-plugin -->\r
+                                               <groupId>org.apache.maven.plugins</groupId>\r
+                                               <artifactId>maven-antrun-plugin</artifactId>\r
+                                               <version>1.8</version>\r
                                                <executions>\r
                                                        <execution>\r
-                                                               <id>MakeDMG</id>\r
-                                                               <configuration>\r
-                                                                       <diskImageFile>${project.build.directory}/${project.artifactId}_${project.version}.dmg</diskImageFile>\r
-                                                               </configuration>\r
                                                                <phase>package</phase>\r
-                                                               <goals>\r
-                                                                       <goal>bundle</goal>\r
-                                                               </goals>\r
-                                                       </execution>\r
-                                                       <execution>\r
-                                                               <id>MakeDMGWithJRE</id>\r
                                                                <configuration>\r
-                                                                       <jrePath>${copyJrePath}</jrePath>\r
-                                                                       <diskImageFile>${project.build.directory}/${project.artifactId}_${project.version}_with_JRE.dmg</diskImageFile>\r
+                                                                       <tasks>\r
+                                                                               <delete dir="${project.build.directory}/appbundle"/>\r
+                                                                               <mkdir dir="${project.build.directory}/appbundle"/>\r
+                                                                               <copy todir="${project.build.directory}/appbundle">\r
+                                                                                       <fileset dir="${project.basedir}/src/main/attachment/bundle">\r
+                                                                                               <include name="**/*"/>\r
+                                                                                       </fileset>\r
+                                                                               </copy>\r
+                                                                               <copy todir="${project.build.directory}/appbundle/CharacterManaJ.app/Contents/Resources">\r
+                                                                                       <fileset dir="${project.basedir}">\r
+                                                                                               <include name="icon.icns"/>\r
+                                                                                       </fileset>\r
+                                                                                       <fileset dir="${project.build.directory}">\r
+                                                                                               <include name="${project.artifactId}.jar"/>\r
+                                                                                       </fileset>\r
+                                                                               </copy>\r
+                                                                               <chmod dir="${project.build.directory}/appbundle/CharacterManaJ.app/Contents/MacOS"\r
+                                                                                       perm="a+rx" includes="**/*.sh"/>\r
+                                                                               <copy todir="${project.build.directory}/appbundle">\r
+                                                                                       <fileset dir="${project.basedir}/src/main/attachment">\r
+                                                                                               <include name="README_mac.txt"/>\r
+                                                                                       </fileset>\r
+                                                                               </copy>\r
+\r
+                                                                               <delete file="${project.build.directory}/${project.artifactId}${project.version}.dmg"/>\r
+                                                                               <exec executable="hdiutil">\r
+                                                                                       <arg value="create"/>\r
+                                                                                       <arg value="-srcfolder"/>\r
+                                                                                       <arg value="${project.build.directory}/appbundle"/>\r
+                                                                                       <arg value="-volname"/>\r
+                                                                                       <arg value="${project.artifactId}_${project.version}.dmg"/>\r
+                                                                                       <arg value="${project.build.directory}/${project.artifactId}_${project.version}.dmg"/>\r
+                                                                               </exec>\r
+                                                                               <exec executable="hdiutil">\r
+                                                                                       <arg value="internet-enable"/>\r
+                                                                                       <arg value="-yes"/>\r
+                                                                                       <arg value="${project.build.directory}/${project.artifactId}_${project.version}.dmg"/>\r
+                                                                               </exec>\r
+\r
+                                                                               <delete dir="${project.build.directory}/appbundle/CharacterManaJ.app/Contents/Plugins/JRE"/>\r
+                                                                               <copy todir="${project.build.directory}/appbundle/CharacterManaJ.app/Contents/Plugins/JRE">\r
+                                                                                       <fileset dir="${copyJrePath}">\r
+                                                                                               <include name="**/*"/>\r
+                                                                                       </fileset>\r
+                                                                               </copy>\r
+                                                                               <chmod dir="${project.build.directory}/appbundle/CharacterManaJ.app/Contents/Plugins/JRE"\r
+                                                                                       perm="a+rx" includes="bin/*"/>\r
+                                                                               <delete file="${project.build.directory}/${project.artifactId}${project.version}_with_jre.dmg"/>\r
+                                                                               <exec executable="hdiutil">\r
+                                                                                       <arg value="create"/>\r
+                                                                                       <arg value="-srcfolder"/>\r
+                                                                                       <arg value="${project.build.directory}/appbundle"/>\r
+                                                                                       <arg value="-volname"/>\r
+                                                                                       <arg value="${project.artifactId}_${project.version}.dmg"/>\r
+                                                                                       <arg value="${project.build.directory}/${project.artifactId}_${project.version}_with_jre.dmg"/>\r
+                                                                               </exec>\r
+                                                                               <exec executable="hdiutil">\r
+                                                                                       <arg value="internet-enable"/>\r
+                                                                                       <arg value="-yes"/>\r
+                                                                                       <arg value="${project.build.directory}/${project.artifactId}_${project.version}_with_jre.dmg"/>\r
+                                                                               </exec>\r
+                                                                       </tasks>\r
                                                                </configuration>\r
-                                                               <phase>package</phase>\r
                                                                <goals>\r
-                                                                       <goal>bundle</goal>\r
+                                                                       <goal>run</goal>\r
                                                                </goals>\r
                                                        </execution>\r
                                                </executions>\r
diff --git a/src/main/attachment/bundle/CharacterManaJ.app/Contents/Info.plist b/src/main/attachment/bundle/CharacterManaJ.app/Contents/Info.plist
new file mode 100644 (file)
index 0000000..6128d40
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+  <dict>
+    <key>CFBundleDevelopmentRegion</key>
+    <string>English</string>
+    <key>CFBundleExecutable</key>
+    <string>java_launch.sh</string>
+    <key>CFBundleIconFile</key>
+    <string>icon.icns</string>
+    <key>CFBundleIdentifier</key>
+    <string>charactermanaj.CharacterManaJ</string>
+    <key>CFBundleDisplayName</key>
+    <string>CharacterManaJ</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundleName</key>
+    <string>CharacterManaJ</string>
+    <key>CFBundlePackageType</key>
+    <string>APPL</string>
+    <key>CFBundleSignature</key>
+    <string>????</string>
+    <key>CFBundleVersion</key>
+    <string>1</string>
+    <key>NSHumanReadableCopyright</key>
+    <string>seraphy@users.osdn.me</string>
+    <key>NSHighResolutionCapable</key>
+    <true/>
+    <key>NSSupportsAutomaticGraphicsSwitching</key>
+    <true/>
+  </dict>
+</plist>
index 59e52d1..a58a640 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/bash
 
 APPNAME="CharacterManaJ"
-JARNAME="CharacterManaJ-0.9.9.9.jar"
+JARNAME="CharacterManaJ.jar"
 
 # JVMオプション
 declare -a jvm_options=()
@@ -48,10 +48,10 @@ fi
 PLUGINS_JRE_DIR="$(realpath "${SCRIPT_DIR}/../Plugins/JRE")"
 if [[ -x ${PLUGINS_JRE_DIR}/Home/bin/java ]]; then
     # バンドル内にある場合(パターン1)
-    JAVA_HOME="$(realpath "${PLUGINS_JRE_DIR}/Home/bin")"
+    JAVA_HOME="$(realpath "${PLUGINS_JRE_DIR}/Home")"
 elif [[ -x ${PLUGINS_JRE_DIR}/bin/java ]]; then
     # バンドル内にある場合(パターン2)
-    JAVA_HOME="$(realpath "${PLUGINS_JRE_DIR}/bin")"
+    JAVA_HOME="$(realpath "${PLUGINS_JRE_DIR}")"
 else
     # バンドル内にない場合で、環境変数JAVA_HOMEがあれば、それを用いる。
     # 環境変数JAVA_HOMEがなければ、/usr/libexec/java_home があれば、それを使う