• R/O
  • HTTP
  • SSH
  • HTTPS

CharacterManaJ: Commit

キャラクターなんとかJの本体


Commit MetaInfo

Revisiona6f80c6fb5fc3cbf48b1fcd0da50696324b41eb0 (tree)
Time2019-01-03 07:07:10
Authorseraphy <seraphy@user...>
Commiterseraphy

Log Message

Macの起動ランチャをBashから独自Objcコードに変更

Change Summary

Incremental Difference

--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,21 @@
44 /bin
55 /target/
66 .DS_Store
7+
8+# Xcode (from gitignore.io)
9+build/
10+*.pbxuser
11+!default.pbxuser
12+*.mode1v3
13+!default.mode1v3
14+*.mode2v3
15+!default.mode2v3
16+*.perspectivev3
17+!default.perspectivev3
18+xcuserdata
19+*.xccheckout
20+*.moved-aside
21+DerivedData
22+*.hmap
23+*.ipa
24+*.xcuserstate
\ No newline at end of file
--- a/pom.xml
+++ b/pom.xml
@@ -327,7 +327,7 @@
327327 </copy>
328328
329329 <chmod dir="${project.build.directory}/appbundle/CharacterManaJ.app/Contents/MacOS"
330- perm="a+rx" includes="**/*.sh"/>
330+ perm="a+rx" includes="JavaLaunch"/>
331331 <copy todir="${project.build.directory}/appbundle">
332332 <fileset dir="${project.basedir}/src/main/attachment">
333333 <include name="README_mac.txt"/>
--- /dev/null
+++ b/src/JavaLaunch/JavaLaunch.xcodeproj/project.pbxproj
@@ -0,0 +1,283 @@
1+// !$*UTF8*$!
2+{
3+ archiveVersion = 1;
4+ classes = {
5+ };
6+ objectVersion = 50;
7+ objects = {
8+
9+/* Begin PBXBuildFile section */
10+ 2EC90F9121DC4F1B00F295DC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EC90F9021DC4F1B00F295DC /* main.m */; };
11+/* End PBXBuildFile section */
12+
13+/* Begin PBXCopyFilesBuildPhase section */
14+ 2EC90F8B21DC4F1B00F295DC /* CopyFiles */ = {
15+ isa = PBXCopyFilesBuildPhase;
16+ buildActionMask = 2147483647;
17+ dstPath = /usr/share/man/man1/;
18+ dstSubfolderSpec = 0;
19+ files = (
20+ );
21+ runOnlyForDeploymentPostprocessing = 1;
22+ };
23+/* End PBXCopyFilesBuildPhase section */
24+
25+/* Begin PBXFileReference section */
26+ 2EC90F8D21DC4F1B00F295DC /* JavaLaunch */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = JavaLaunch; sourceTree = BUILT_PRODUCTS_DIR; };
27+ 2EC90F9021DC4F1B00F295DC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
28+/* End PBXFileReference section */
29+
30+/* Begin PBXFrameworksBuildPhase section */
31+ 2EC90F8A21DC4F1B00F295DC /* Frameworks */ = {
32+ isa = PBXFrameworksBuildPhase;
33+ buildActionMask = 2147483647;
34+ files = (
35+ );
36+ runOnlyForDeploymentPostprocessing = 0;
37+ };
38+/* End PBXFrameworksBuildPhase section */
39+
40+/* Begin PBXGroup section */
41+ 2EC90F8421DC4F1B00F295DC = {
42+ isa = PBXGroup;
43+ children = (
44+ 2EC90F8F21DC4F1B00F295DC /* JavaLaunch */,
45+ 2EC90F8E21DC4F1B00F295DC /* Products */,
46+ );
47+ sourceTree = "<group>";
48+ };
49+ 2EC90F8E21DC4F1B00F295DC /* Products */ = {
50+ isa = PBXGroup;
51+ children = (
52+ 2EC90F8D21DC4F1B00F295DC /* JavaLaunch */,
53+ );
54+ name = Products;
55+ sourceTree = "<group>";
56+ };
57+ 2EC90F8F21DC4F1B00F295DC /* JavaLaunch */ = {
58+ isa = PBXGroup;
59+ children = (
60+ 2EC90F9021DC4F1B00F295DC /* main.m */,
61+ );
62+ path = JavaLaunch;
63+ sourceTree = "<group>";
64+ };
65+/* End PBXGroup section */
66+
67+/* Begin PBXNativeTarget section */
68+ 2EC90F8C21DC4F1B00F295DC /* JavaLaunch */ = {
69+ isa = PBXNativeTarget;
70+ buildConfigurationList = 2EC90F9421DC4F1B00F295DC /* Build configuration list for PBXNativeTarget "JavaLaunch" */;
71+ buildPhases = (
72+ 2EC90F8921DC4F1B00F295DC /* Sources */,
73+ 2EC90F8A21DC4F1B00F295DC /* Frameworks */,
74+ 2EC90F8B21DC4F1B00F295DC /* CopyFiles */,
75+ );
76+ buildRules = (
77+ );
78+ dependencies = (
79+ );
80+ name = JavaLaunch;
81+ productName = JavaLaunch;
82+ productReference = 2EC90F8D21DC4F1B00F295DC /* JavaLaunch */;
83+ productType = "com.apple.product-type.tool";
84+ };
85+/* End PBXNativeTarget section */
86+
87+/* Begin PBXProject section */
88+ 2EC90F8521DC4F1B00F295DC /* Project object */ = {
89+ isa = PBXProject;
90+ attributes = {
91+ LastUpgradeCheck = 1010;
92+ ORGANIZATIONNAME = seraphy;
93+ TargetAttributes = {
94+ 2EC90F8C21DC4F1B00F295DC = {
95+ CreatedOnToolsVersion = 10.1;
96+ };
97+ };
98+ };
99+ buildConfigurationList = 2EC90F8821DC4F1B00F295DC /* Build configuration list for PBXProject "JavaLaunch" */;
100+ compatibilityVersion = "Xcode 9.3";
101+ developmentRegion = en;
102+ hasScannedForEncodings = 0;
103+ knownRegions = (
104+ en,
105+ );
106+ mainGroup = 2EC90F8421DC4F1B00F295DC;
107+ productRefGroup = 2EC90F8E21DC4F1B00F295DC /* Products */;
108+ projectDirPath = "";
109+ projectRoot = "";
110+ targets = (
111+ 2EC90F8C21DC4F1B00F295DC /* JavaLaunch */,
112+ );
113+ };
114+/* End PBXProject section */
115+
116+/* Begin PBXSourcesBuildPhase section */
117+ 2EC90F8921DC4F1B00F295DC /* Sources */ = {
118+ isa = PBXSourcesBuildPhase;
119+ buildActionMask = 2147483647;
120+ files = (
121+ 2EC90F9121DC4F1B00F295DC /* main.m in Sources */,
122+ );
123+ runOnlyForDeploymentPostprocessing = 0;
124+ };
125+/* End PBXSourcesBuildPhase section */
126+
127+/* Begin XCBuildConfiguration section */
128+ 2EC90F9221DC4F1B00F295DC /* Debug */ = {
129+ isa = XCBuildConfiguration;
130+ buildSettings = {
131+ ALWAYS_SEARCH_USER_PATHS = NO;
132+ CLANG_ANALYZER_NONNULL = YES;
133+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
134+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
135+ CLANG_CXX_LIBRARY = "libc++";
136+ CLANG_ENABLE_MODULES = YES;
137+ CLANG_ENABLE_OBJC_ARC = YES;
138+ CLANG_ENABLE_OBJC_WEAK = YES;
139+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
140+ CLANG_WARN_BOOL_CONVERSION = YES;
141+ CLANG_WARN_COMMA = YES;
142+ CLANG_WARN_CONSTANT_CONVERSION = YES;
143+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
144+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
145+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
146+ CLANG_WARN_EMPTY_BODY = YES;
147+ CLANG_WARN_ENUM_CONVERSION = YES;
148+ CLANG_WARN_INFINITE_RECURSION = YES;
149+ CLANG_WARN_INT_CONVERSION = YES;
150+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
151+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
152+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
153+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
154+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
155+ CLANG_WARN_STRICT_PROTOTYPES = YES;
156+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
157+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
158+ CLANG_WARN_UNREACHABLE_CODE = YES;
159+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
160+ CODE_SIGN_IDENTITY = "-";
161+ COPY_PHASE_STRIP = NO;
162+ DEBUG_INFORMATION_FORMAT = dwarf;
163+ ENABLE_STRICT_OBJC_MSGSEND = YES;
164+ ENABLE_TESTABILITY = YES;
165+ GCC_C_LANGUAGE_STANDARD = gnu11;
166+ GCC_DYNAMIC_NO_PIC = NO;
167+ GCC_NO_COMMON_BLOCKS = YES;
168+ GCC_OPTIMIZATION_LEVEL = 0;
169+ GCC_PREPROCESSOR_DEFINITIONS = (
170+ "DEBUG=1",
171+ "$(inherited)",
172+ );
173+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
174+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
175+ GCC_WARN_UNDECLARED_SELECTOR = YES;
176+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
177+ GCC_WARN_UNUSED_FUNCTION = YES;
178+ GCC_WARN_UNUSED_VARIABLE = YES;
179+ MACOSX_DEPLOYMENT_TARGET = 10.14;
180+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
181+ MTL_FAST_MATH = YES;
182+ ONLY_ACTIVE_ARCH = YES;
183+ SDKROOT = macosx;
184+ };
185+ name = Debug;
186+ };
187+ 2EC90F9321DC4F1B00F295DC /* Release */ = {
188+ isa = XCBuildConfiguration;
189+ buildSettings = {
190+ ALWAYS_SEARCH_USER_PATHS = NO;
191+ CLANG_ANALYZER_NONNULL = YES;
192+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
193+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
194+ CLANG_CXX_LIBRARY = "libc++";
195+ CLANG_ENABLE_MODULES = YES;
196+ CLANG_ENABLE_OBJC_ARC = YES;
197+ CLANG_ENABLE_OBJC_WEAK = YES;
198+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
199+ CLANG_WARN_BOOL_CONVERSION = YES;
200+ CLANG_WARN_COMMA = YES;
201+ CLANG_WARN_CONSTANT_CONVERSION = YES;
202+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
203+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
204+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
205+ CLANG_WARN_EMPTY_BODY = YES;
206+ CLANG_WARN_ENUM_CONVERSION = YES;
207+ CLANG_WARN_INFINITE_RECURSION = YES;
208+ CLANG_WARN_INT_CONVERSION = YES;
209+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
210+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
211+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
212+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
213+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
214+ CLANG_WARN_STRICT_PROTOTYPES = YES;
215+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
216+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
217+ CLANG_WARN_UNREACHABLE_CODE = YES;
218+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
219+ CODE_SIGN_IDENTITY = "-";
220+ COPY_PHASE_STRIP = NO;
221+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
222+ ENABLE_NS_ASSERTIONS = NO;
223+ ENABLE_STRICT_OBJC_MSGSEND = YES;
224+ GCC_C_LANGUAGE_STANDARD = gnu11;
225+ GCC_NO_COMMON_BLOCKS = YES;
226+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
227+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
228+ GCC_WARN_UNDECLARED_SELECTOR = YES;
229+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
230+ GCC_WARN_UNUSED_FUNCTION = YES;
231+ GCC_WARN_UNUSED_VARIABLE = YES;
232+ MACOSX_DEPLOYMENT_TARGET = 10.14;
233+ MTL_ENABLE_DEBUG_INFO = NO;
234+ MTL_FAST_MATH = YES;
235+ SDKROOT = macosx;
236+ };
237+ name = Release;
238+ };
239+ 2EC90F9521DC4F1B00F295DC /* Debug */ = {
240+ isa = XCBuildConfiguration;
241+ buildSettings = {
242+ CLANG_ENABLE_OBJC_WEAK = NO;
243+ CODE_SIGN_STYLE = Automatic;
244+ MACOSX_DEPLOYMENT_TARGET = 10.6;
245+ PRODUCT_NAME = "$(TARGET_NAME)";
246+ };
247+ name = Debug;
248+ };
249+ 2EC90F9621DC4F1B00F295DC /* Release */ = {
250+ isa = XCBuildConfiguration;
251+ buildSettings = {
252+ CLANG_ENABLE_OBJC_WEAK = NO;
253+ CODE_SIGN_STYLE = Automatic;
254+ MACOSX_DEPLOYMENT_TARGET = 10.6;
255+ PRODUCT_NAME = "$(TARGET_NAME)";
256+ };
257+ name = Release;
258+ };
259+/* End XCBuildConfiguration section */
260+
261+/* Begin XCConfigurationList section */
262+ 2EC90F8821DC4F1B00F295DC /* Build configuration list for PBXProject "JavaLaunch" */ = {
263+ isa = XCConfigurationList;
264+ buildConfigurations = (
265+ 2EC90F9221DC4F1B00F295DC /* Debug */,
266+ 2EC90F9321DC4F1B00F295DC /* Release */,
267+ );
268+ defaultConfigurationIsVisible = 0;
269+ defaultConfigurationName = Release;
270+ };
271+ 2EC90F9421DC4F1B00F295DC /* Build configuration list for PBXNativeTarget "JavaLaunch" */ = {
272+ isa = XCConfigurationList;
273+ buildConfigurations = (
274+ 2EC90F9521DC4F1B00F295DC /* Debug */,
275+ 2EC90F9621DC4F1B00F295DC /* Release */,
276+ );
277+ defaultConfigurationIsVisible = 0;
278+ defaultConfigurationName = Release;
279+ };
280+/* End XCConfigurationList section */
281+ };
282+ rootObject = 2EC90F8521DC4F1B00F295DC /* Project object */;
283+}
--- /dev/null
+++ b/src/JavaLaunch/JavaLaunch.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<Workspace
3+ version = "1.0">
4+ <FileRef
5+ location = "self:JavaLaunch.xcodeproj">
6+ </FileRef>
7+</Workspace>
--- /dev/null
+++ b/src/JavaLaunch/JavaLaunch.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+<plist version="1.0">
4+<dict>
5+ <key>IDEDidComputeMac32BitWarning</key>
6+ <true/>
7+</dict>
8+</plist>
--- /dev/null
+++ b/src/JavaLaunch/JavaLaunch.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,5 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+<plist version="1.0">
4+<dict/>
5+</plist>
--- /dev/null
+++ b/src/JavaLaunch/JavaLaunch.xcodeproj/xcshareddata/xcschemes/JavaLaunch.xcscheme
@@ -0,0 +1,91 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<Scheme
3+ LastUpgradeVersion = "1010"
4+ version = "1.3">
5+ <BuildAction
6+ parallelizeBuildables = "YES"
7+ buildImplicitDependencies = "YES">
8+ <BuildActionEntries>
9+ <BuildActionEntry
10+ buildForTesting = "YES"
11+ buildForRunning = "YES"
12+ buildForProfiling = "YES"
13+ buildForArchiving = "YES"
14+ buildForAnalyzing = "YES">
15+ <BuildableReference
16+ BuildableIdentifier = "primary"
17+ BlueprintIdentifier = "2EC90F8C21DC4F1B00F295DC"
18+ BuildableName = "JavaLaunch"
19+ BlueprintName = "JavaLaunch"
20+ ReferencedContainer = "container:JavaLaunch.xcodeproj">
21+ </BuildableReference>
22+ </BuildActionEntry>
23+ </BuildActionEntries>
24+ </BuildAction>
25+ <TestAction
26+ buildConfiguration = "Debug"
27+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+ shouldUseLaunchSchemeArgsEnv = "YES">
30+ <Testables>
31+ </Testables>
32+ <MacroExpansion>
33+ <BuildableReference
34+ BuildableIdentifier = "primary"
35+ BlueprintIdentifier = "2EC90F8C21DC4F1B00F295DC"
36+ BuildableName = "JavaLaunch"
37+ BlueprintName = "JavaLaunch"
38+ ReferencedContainer = "container:JavaLaunch.xcodeproj">
39+ </BuildableReference>
40+ </MacroExpansion>
41+ <AdditionalOptions>
42+ </AdditionalOptions>
43+ </TestAction>
44+ <LaunchAction
45+ buildConfiguration = "Release"
46+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
47+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
48+ launchStyle = "0"
49+ useCustomWorkingDirectory = "NO"
50+ ignoresPersistentStateOnLaunch = "NO"
51+ debugDocumentVersioning = "YES"
52+ debugServiceExtension = "internal"
53+ allowLocationSimulation = "YES">
54+ <BuildableProductRunnable
55+ runnableDebuggingMode = "0">
56+ <BuildableReference
57+ BuildableIdentifier = "primary"
58+ BlueprintIdentifier = "2EC90F8C21DC4F1B00F295DC"
59+ BuildableName = "JavaLaunch"
60+ BlueprintName = "JavaLaunch"
61+ ReferencedContainer = "container:JavaLaunch.xcodeproj">
62+ </BuildableReference>
63+ </BuildableProductRunnable>
64+ <AdditionalOptions>
65+ </AdditionalOptions>
66+ </LaunchAction>
67+ <ProfileAction
68+ buildConfiguration = "Release"
69+ shouldUseLaunchSchemeArgsEnv = "YES"
70+ savedToolIdentifier = ""
71+ useCustomWorkingDirectory = "NO"
72+ debugDocumentVersioning = "YES">
73+ <BuildableProductRunnable
74+ runnableDebuggingMode = "0">
75+ <BuildableReference
76+ BuildableIdentifier = "primary"
77+ BlueprintIdentifier = "2EC90F8C21DC4F1B00F295DC"
78+ BuildableName = "JavaLaunch"
79+ BlueprintName = "JavaLaunch"
80+ ReferencedContainer = "container:JavaLaunch.xcodeproj">
81+ </BuildableReference>
82+ </BuildableProductRunnable>
83+ </ProfileAction>
84+ <AnalyzeAction
85+ buildConfiguration = "Debug">
86+ </AnalyzeAction>
87+ <ArchiveAction
88+ buildConfiguration = "Release"
89+ revealArchiveInOrganizer = "YES">
90+ </ArchiveAction>
91+</Scheme>
--- /dev/null
+++ b/src/JavaLaunch/JavaLaunch/main.m
@@ -0,0 +1,162 @@
1+//
2+// main.m
3+// JavaLaunch
4+//
5+// Created by seraphy on 2019/01/02.
6+// Copyright © 2019 seraphy. All rights reserved.
7+//
8+
9+#import <Foundation/Foundation.h>
10+#import <Cocoa/Cocoa.h>
11+
12+#define JAVA_LAUNCH_ERROR "JavaLaunchError"
13+#define UNSPECIFIED_ERROR "An unknown error occurred."
14+
15+NSString *FindJavaHome() {
16+ NSTask *task = [[NSTask alloc] init];
17+ NSPipe *pipe = [NSPipe pipe];
18+
19+ [task setLaunchPath:@"/usr/libexec/java_home"];
20+ [task setArguments: [NSArray arrayWithObjects: @"-v", nil]];
21+ [task setStandardOutput: pipe];
22+ [task launch];
23+
24+ NSFileHandle *handle = [pipe fileHandleForReading];
25+ NSData *data = [handle readDataToEndOfFile];
26+ NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
27+
28+ [task waitUntilExit];
29+ int exitCode = [task terminationStatus];
30+ if (exitCode != 0) {
31+ NSLog(@"not found system java_home");
32+ return nil;
33+ }
34+ NSLog(@"found system java_home=%@", result);
35+ return result;
36+}
37+
38+int main(int argc, const char * argv[]) {
39+ int exitCode = 0;
40+ @autoreleasepool {
41+ @try {
42+ // メインバンドル
43+ NSBundle *mainBundle = [NSBundle mainBundle];
44+
45+ // *.appのディレクトリを取得
46+ NSString *mainBundlePath = [mainBundle bundlePath];
47+ NSLog(@"mainBundlePath=%@", mainBundlePath);
48+
49+ // 実行可能jarの場所
50+ NSString *jarPath = [[mainBundlePath stringByAppendingPathComponent:@"Contents"] stringByAppendingPathComponent: [[mainBundle infoDictionary] objectForKey:@"ExecutableJar"]];
51+ NSLog(@"jarPath=%@", jarPath);
52+
53+ // バンドルJREの場所を探索する
54+ NSString *pluginJreDir = [mainBundlePath stringByAppendingPathComponent:@"Contents/Plugins/JRE"];
55+ NSLog(@"pluginJreDir=%@", pluginJreDir);
56+
57+ NSString *jreDir = pluginJreDir;
58+
59+ NSFileManager *fileManager = [NSFileManager defaultManager];
60+ NSString *path = [pluginJreDir stringByAppendingPathComponent:@"Home/bin/java"];
61+ if ([fileManager fileExistsAtPath: path]) {
62+ // パターン1 Home/bin/java
63+ jreDir = [pluginJreDir stringByAppendingPathComponent:@"Home"];
64+ } else {
65+ // パターン2 bin/java
66+ path = [pluginJreDir stringByAppendingPathComponent:@"bin/java"];
67+ if (![fileManager fileExistsAtPath: path]) {
68+ // バンドルJREがない場合は環境変数JAVA_HOMEがあれば、それを優先する
69+ jreDir = [[[NSProcessInfo processInfo]environment]objectForKey:@"JAVA_HOME"];
70+ if (jreDir == nil) {
71+ // 環境変数JAVA_HOMEがなければ/usr/libexec/java_homeで問い合わせる
72+ jreDir = FindJavaHome();
73+ }
74+ }
75+ }
76+ NSLog(@"JreDir=%@", jreDir);
77+ if (jreDir == nil) {
78+ // JAVA_HOMEを特定できなければエラーダイアログ表示
79+ NSString *title = [mainBundle localizedStringForKey: @"JavaDirectoryNotFound" value:@"JRE Not Found Error" table:@"Localizable"];
80+ [[NSException exceptionWithName:@JAVA_LAUNCH_ERROR reason:title userInfo:nil] raise];
81+ }
82+
83+ // アプリケーション名を取得(ローカライズされたもの)
84+ NSString *displayAppName;
85+ displayAppName = [[mainBundle localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"];
86+ NSLog(@"displayAppName=%@", displayAppName);
87+ printf("%s\n", [displayAppName UTF8String]);
88+
89+ //
90+ NSMutableArray *jvmOptions = [[[mainBundle infoDictionary] objectForKey:@"JVMOptions"] mutableCopy];
91+ if (jvmOptions == nil) {
92+ jvmOptions = [NSMutableArray array];
93+ }
94+
95+ // バンドル名
96+ NSString *bundleName = [[mainBundle infoDictionary] objectForKey:@"CFBundleName"];
97+ NSLog(@"bundleName=%@", bundleName);
98+
99+ // ユーザー定義オプションの読み込み
100+ NSString *userJvmOptionPath = [NSHomeDirectory() stringByAppendingPathComponent: [NSString stringWithFormat:@"/Library/%@/jvm_options", bundleName]];
101+ if ([fileManager fileExistsAtPath: userJvmOptionPath]) {
102+ NSString* fileContents = [NSString stringWithContentsOfFile:userJvmOptionPath
103+ encoding:NSUTF8StringEncoding error:nil];
104+ NSArray* allLinedStrings = [fileContents componentsSeparatedByCharactersInSet:
105+ [NSCharacterSet newlineCharacterSet]];
106+ // 同一のキーが指定されている場合はRightMostとなることを期待している。(厳密には仕様に定義されていない。)
107+ for (id line in allLinedStrings) {
108+ NSString *option = [line stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
109+ if (![option hasPrefix:@"#"] && [option length] > 0) {
110+ NSLog(@"option: %@", line);
111+ [jvmOptions addObject: option];
112+ }
113+ }
114+ }
115+
116+ // Java起動引数の組み立て
117+ NSMutableArray *launchArgs = [NSMutableArray arrayWithObjects:[@"-Xdock:name=" stringByAppendingString:displayAppName], nil];
118+ [launchArgs addObjectsFromArray: jvmOptions];
119+ [launchArgs addObject:@"-jar"];
120+ [launchArgs addObject:jarPath];
121+ // javaを起動する
122+ NSPipe *pipe = [NSPipe pipe];
123+ NSTask *javaTask = [[NSTask alloc] init];
124+ [javaTask setLaunchPath: [jreDir stringByAppendingPathComponent: @"bin/java"]];
125+ [javaTask setArguments: launchArgs];
126+ [javaTask setStandardError: pipe];
127+
128+ NSTimeInterval beginTime = [NSDate timeIntervalSinceReferenceDate];
129+ [javaTask launch];
130+
131+ NSFileHandle *handle = [pipe fileHandleForReading];
132+ NSData *data = [handle readDataToEndOfFile];
133+ NSString *javaError = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
134+ if ([javaError length] > 0) {
135+ NSLog(@"Error Message=%@", javaError);
136+ }
137+
138+ [javaTask waitUntilExit];
139+ NSTimeInterval endTime = [NSDate timeIntervalSinceReferenceDate];
140+
141+ exitCode = [javaTask terminationStatus];
142+ NSLog(@"exitCode=%d", exitCode);
143+
144+ NSTimeInterval span = endTime - beginTime;
145+ if (span < 5 && exitCode != 0) {
146+ // Javaの実行直後にエラーで終了している場合は、クラスロードエラーの可能性が高い。
147+ NSString *title = [mainBundle localizedStringForKey: @"JRELoadError" value:@"JRE Load Error" table:nil];
148+ NSString *reason = [NSString stringWithFormat:@"%@\n%@", title, javaError];
149+ [[NSException exceptionWithName:@JAVA_LAUNCH_ERROR reason: reason userInfo:nil] raise];
150+ }
151+
152+ } @catch(NSException *exception) {
153+ NSLog(@"error=%@", [exception reason]);
154+ NSAlert *alert = [[NSAlert alloc] init];
155+ [alert setAlertStyle:NSCriticalAlertStyle];
156+ [alert setMessageText:[exception reason]];
157+ [alert runModal];
158+ exitCode = 1;
159+ }
160+ }
161+ return exitCode;
162+}
--- a/src/main/attachment/bundle/CharacterManaJ.app/Contents/Info.plist
+++ b/src/main/attachment/bundle/CharacterManaJ.app/Contents/Info.plist
@@ -5,7 +5,7 @@
55 <key>CFBundleDevelopmentRegion</key>
66 <string>English</string>
77 <key>CFBundleExecutable</key>
8- <string>java_launch.sh</string>
8+ <string>JavaLaunch</string>
99 <key>CFBundleIconFile</key>
1010 <string>icon.icns</string>
1111 <key>CFBundleIdentifier</key>
@@ -30,5 +30,7 @@
3030 <true/>
3131 <key>NSSupportsAutomaticGraphicsSwitching</key>
3232 <true/>
33+ <key>ExecutableJar</key>
34+ <string>Resources/CharacterManaJ.jar</string>
3335 </dict>
3436 </plist>
Binary files /dev/null and b/src/main/attachment/bundle/CharacterManaJ.app/Contents/MacOS/JavaLaunch differ
--- a/src/main/attachment/bundle/CharacterManaJ.app/Contents/MacOS/java_launch.sh
+++ /dev/null
@@ -1,98 +0,0 @@
1-#! /bin/bash
2-
3-APPNAME="CharacterManaJ"
4-JARNAME="CharacterManaJ.jar"
5-
6-# JVMオプション
7-declare -a jvm_options=()
8-
9-# 相対パスから絶対パスに変換する
10-function realpath() {
11- [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
12-}
13-
14-# エラーを表示する
15-function ShowMessage() {
16- if [[ -x /usr/bin/osascript ]]; then
17- /usr/bin/osascript -e "display alert \"$APPNAME\" message \"$1\""
18- else
19- echo "$APPNAME -- $1"
20- fi
21-}
22-
23-# JVMに指定するオプションのテキストファイルをjvm_options配列に読み込む
24-function read_jvm_options() {
25- while IFS='' read -r line || [[ -n $line ]]; do
26- line="${line//[$'\r\n']}" # 行端記号の除去(空白は残す)
27- trimline="${line//[$'\t\r\n ']}" # 空行判定のためタブ、行端、空白を除去
28- if [[ -n $trimline ]]; then
29- jvm_options+=("$line")
30- fi
31- done < "$1"
32-}
33-
34-# このスクリプト基準のパスを求める
35-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
36-RESOURCE_DIR="$(realpath "$SCRIPT_DIR/../Resources")"
37-
38-# JVMオプションがあれば読み取る
39-if [[ -f "$RESOURCE_DIR/jvm_options" ]]; then
40- read_jvm_options "$RESOURCE_DIR/jvm_options"
41-fi
42-# JVMオプション(ユーザーディレクトリ上)
43-if [[ -f "${HOME}/Library/${APPNAME}/jvm_options" ]]; then
44- read_jvm_options "${HOME}/Library/${APPNAME}/jvm_options"
45-fi
46-
47-# JREの位置を検索する
48-PLUGINS_JRE_DIR="$(realpath "${SCRIPT_DIR}/../Plugins/JRE")"
49-if [[ -x "${PLUGINS_JRE_DIR}/Home/bin/java" ]]; then
50- # バンドル内にある場合(パターン1)
51- JAVA_HOME="$(realpath "${PLUGINS_JRE_DIR}/Home")"
52-elif [[ -x "${PLUGINS_JRE_DIR}/bin/java" ]]; then
53- # バンドル内にある場合(パターン2)
54- JAVA_HOME="$(realpath "${PLUGINS_JRE_DIR}")"
55-else
56- # バンドル内にない場合で、環境変数JAVA_HOMEがあれば、それを用いる。
57- # 環境変数JAVA_HOMEがなければ、/usr/libexec/java_home があれば、それを使う
58- if [[ -z "$JAVA_HOME" ]]; then
59- if [[ -x "/usr/libexec/java_home" ]]; then
60- JAVA_HOME="$(/usr/libexec/java_home)"
61- if [[ $? -ne 0 ]]; then
62- # java_homeがエラーを返すならばJavaが無いものと見なす
63- JAVA_HOME=""
64- fi
65- fi
66- fi
67-fi
68-
69-if [[ -z "$JAVA_HOME" ]]; then
70- which java 2>/dev/null
71- if [[ $? -ne 0 ]]; then
72- # JAVA_HOMEが設定されておらず、且つ、javaにパスが通ってない場合はエラー
73- ShowMessage "Could not find Java SE Runtime Environment."
74- exit 2
75- fi
76- # JAVA_HOMEは未設定だがパスが通っていれば継続する
77- JAVA_CMD="java"
78-else
79- # JAVA_HOMEが特定されている場合は、それを用いる
80- export JAVA_HOME
81- JAVA_CMD="$JAVA_HOME/bin/java"
82-fi
83-
84-# JAVAをオプションとJARを指定して起動する
85-if [[ -f $RESOURCE_DIR/$JARNAME ]]; then
86- # アプリケーション名とロケールの取得
87- APPTITLE=( $("$JAVA_CMD" -jar "$RESOURCE_DIR/$JARNAME" --show-appinfo) )
88- if [[ $? -ne 0 ]]; then
89- # JAVAの起動に失敗した場合
90- ShowMessage "Could not launch Java SE Runtime Environment. ${APPNAME}"
91- exit 1
92- fi
93-
94- # アプリケーションの起動
95- "$JAVA_CMD" ${jvm_options[@]} "-Xdock:name=${APPTITLE[0]}" -jar "$RESOURCE_DIR/$JARNAME" || ShowMessage "Failed to launch ${APPNAME}"
96-else
97- ShowMessage "$JARNAME is not found."
98-fi
--- /dev/null
+++ b/src/main/attachment/bundle/CharacterManaJ.app/Contents/Resources/en.lproj/Localizable.strings
@@ -0,0 +1,2 @@
1+"JRELoadError" = "Unable to load Java Runtime Environment.";
2+"JavaDirectoryNotFound" = "Unable to enumerate Java directory contents.";
--- /dev/null
+++ b/src/main/attachment/bundle/CharacterManaJ.app/Contents/Resources/ja.lproj/Localizable.strings
@@ -0,0 +1,2 @@
1+"JRELoadError" = "Javaの起動に失敗しました。";
2+"JavaDirectoryNotFound" = "Javaランタイムが見つかりません";
Show on old repository browser