238 return isSupported(); |
238 return isSupported(); |
239 } |
239 } |
240 |
240 |
241 public static boolean isSupported() { |
241 public static boolean isSupported() { |
242 try { |
242 try { |
243 return validateWixTools(); |
243 validateWixTools(); |
|
244 return true; |
|
245 } catch (ConfigException ce) { |
|
246 Log.error(ce.getMessage()); |
|
247 if (ce.getAdvice() != null) { |
|
248 Log.error(ce.getAdvice()); |
|
249 } |
244 } catch (Exception e) { |
250 } catch (Exception e) { |
245 return false; |
251 Log.error(e.getMessage()); |
246 } |
252 } |
|
253 return false; |
247 } |
254 } |
248 |
255 |
249 private static String findToolVersion(String toolName) { |
256 private static String findToolVersion(String toolName) { |
250 try { |
257 try { |
251 if (toolName == null || "".equals(toolName)) return null; |
258 if (toolName == null || "".equals(toolName)) return null; |
265 Log.verbose(e); |
272 Log.verbose(e); |
266 return null; |
273 return null; |
267 } |
274 } |
268 } |
275 } |
269 |
276 |
270 public static boolean validateWixTools() { |
277 public static void validateWixTools() throws ConfigException{ |
271 String candleVersion = findToolVersion(getCandlePath()); |
278 String candleVersion = findToolVersion(getCandlePath()); |
272 String lightVersion = findToolVersion(getLightPath()); |
279 String lightVersion = findToolVersion(getLightPath()); |
273 |
280 |
274 // WiX 3.0+ is required |
281 // WiX 3.0+ is required |
275 String minVersion = "3.0"; |
282 String minVersion = "3.0"; |
|
283 if (candleVersion == null || lightVersion == null) { |
|
284 throw new ConfigException( |
|
285 I18N.getString("error.no-wix-tools"), |
|
286 I18N.getString("error.no-wix-tools.advice")); |
|
287 } |
276 |
288 |
277 if (VersionExtractor.isLessThan(candleVersion, minVersion)) { |
289 if (VersionExtractor.isLessThan(candleVersion, minVersion)) { |
278 Log.verbose(MessageFormat.format( |
290 throw new ConfigException( |
|
291 MessageFormat.format( |
279 I18N.getString("message.wrong-tool-version"), |
292 I18N.getString("message.wrong-tool-version"), |
280 TOOL_CANDLE, candleVersion, minVersion)); |
293 TOOL_CANDLE, candleVersion, minVersion), |
281 return false; |
294 I18N.getString("error.no-wix-tools.advice")); |
282 } |
295 } |
283 if (VersionExtractor.isLessThan(lightVersion, minVersion)) { |
296 if (VersionExtractor.isLessThan(lightVersion, minVersion)) { |
284 Log.verbose(MessageFormat.format( |
297 throw new ConfigException( |
|
298 MessageFormat.format( |
285 I18N.getString("message.wrong-tool-version"), |
299 I18N.getString("message.wrong-tool-version"), |
286 TOOL_LIGHT, lightVersion, minVersion)); |
300 TOOL_LIGHT, lightVersion, minVersion), |
287 return false; |
301 I18N.getString("error.no-wix-tools.advice")); |
288 } |
302 } |
289 return true; |
|
290 } |
303 } |
291 |
304 |
292 @Override |
305 @Override |
293 public boolean validate(Map<String, ? super Object> params) |
306 public boolean validate(Map<String, ? super Object> params) |
294 throws ConfigException { |
307 throws ConfigException { |
297 I18N.getString("error.parameters-null"), |
310 I18N.getString("error.parameters-null"), |
298 I18N.getString("error.parameters-null.advice")); |
311 I18N.getString("error.parameters-null.advice")); |
299 |
312 |
300 // run basic validation to ensure requirements are met |
313 // run basic validation to ensure requirements are met |
301 // we are not interested in return code, only possible exception |
314 // we are not interested in return code, only possible exception |
302 if (!validateWixTools()){ |
315 validateWixTools(); |
303 throw new ConfigException( |
|
304 I18N.getString("error.no-wix-tools"), |
|
305 I18N.getString("error.no-wix-tools.advice")); |
|
306 } |
|
307 |
316 |
308 String lightVersion = findToolVersion(getLightPath()); |
317 String lightVersion = findToolVersion(getLightPath()); |
309 if (!VersionExtractor.isLessThan(lightVersion, "3.6")) { |
318 if (!VersionExtractor.isLessThan(lightVersion, "3.6")) { |
310 Log.verbose(I18N.getString("message.use-wix36-features")); |
319 Log.verbose(I18N.getString("message.use-wix36-features")); |
311 params.put(CAN_USE_WIX36.getID(), Boolean.TRUE); |
320 params.put(CAN_USE_WIX36.getID(), Boolean.TRUE); |