88 } |
88 } |
89 |
89 |
90 return result; |
90 return result; |
91 } |
91 } |
92 |
92 |
93 static String getMainClass(Map<String, ? super Object> params) { |
93 static String getMainClassFromModule(Map<String, ? super Object> params) { |
94 String result = ""; |
|
95 String mainModule = StandardBundlerParam.MODULE.fetchFrom(params); |
94 String mainModule = StandardBundlerParam.MODULE.fetchFrom(params); |
96 if (mainModule != null) { |
95 if (mainModule != null) { |
|
96 |
97 int index = mainModule.indexOf("/"); |
97 int index = mainModule.indexOf("/"); |
98 if (index > 0) { |
98 if (index > 0) { |
99 result = mainModule.substring(index + 1); |
99 return mainModule.substring(index + 1); |
100 } else { |
100 } else { |
101 ModuleDescriptor descriptor = |
101 ModuleDescriptor descriptor = |
102 JLinkBundlerHelper.getMainModuleDescription(params); |
102 JLinkBundlerHelper.getMainModuleDescription(params); |
103 if (descriptor != null) { |
103 if (descriptor != null) { |
104 Optional<String> mainClass = descriptor.mainClass(); |
104 Optional<String> mainClass = descriptor.mainClass(); |
105 if (mainClass.isPresent()) { |
105 if (mainClass.isPresent()) { |
106 Log.verbose(MessageFormat.format(I18N.getString( |
106 Log.verbose(MessageFormat.format(I18N.getString( |
107 "message.module-class"), |
107 "message.module-class"), |
108 mainClass.get(), |
108 mainClass.get(), |
109 JLinkBundlerHelper.getMainModule(params))); |
109 JLinkBundlerHelper.getMainModule(params))); |
110 result = mainClass.get(); |
110 return mainClass.get(); |
111 } |
111 } |
112 } |
112 } |
113 } |
113 } |
114 } else { |
114 } |
115 RelativeFileSet fileset = |
115 return null; |
116 StandardBundlerParam.MAIN_JAR.fetchFrom(params); |
|
117 if (fileset != null) { |
|
118 result = StandardBundlerParam.MAIN_CLASS.fetchFrom(params); |
|
119 } else { |
|
120 // possibly app-image |
|
121 } |
|
122 } |
|
123 |
|
124 return result; |
|
125 } |
116 } |
126 |
117 |
127 static String getMainModule(Map<String, ? super Object> params) { |
118 static String getMainModule(Map<String, ? super Object> params) { |
128 String result = null; |
119 String result = null; |
129 String mainModule = StandardBundlerParam.MODULE.fetchFrom(params); |
120 String mainModule = StandardBundlerParam.MODULE.fetchFrom(params); |
149 } |
140 } |
150 |
141 |
151 static void execute(Map<String, ? super Object> params, |
142 static void execute(Map<String, ? super Object> params, |
152 AbstractAppImageBuilder imageBuilder) |
143 AbstractAppImageBuilder imageBuilder) |
153 throws IOException, Exception { |
144 throws IOException, Exception { |
154 |
|
155 // we might be able to build it (with no main class) but it won't run |
|
156 if (StandardBundlerParam.MAIN_CLASS.fetchFrom(params) == null) { |
|
157 throw new PackagerException("ERR_NoMainClass"); |
|
158 } |
|
159 |
145 |
160 List<Path> modulePath = |
146 List<Path> modulePath = |
161 StandardBundlerParam.MODULE_PATH.fetchFrom(params); |
147 StandardBundlerParam.MODULE_PATH.fetchFrom(params); |
162 Set<String> addModules = |
148 Set<String> addModules = |
163 StandardBundlerParam.ADD_MODULES.fetchFrom(params); |
149 StandardBundlerParam.ADD_MODULES.fetchFrom(params); |