@@ -292,9 +292,6 @@ private File getJar() {
292
292
293
293
@ Override
294
294
public void execute () throws MojoExecutionException {
295
- if (getLog ().isDebugEnabled ()) {
296
- printState ();
297
- }
298
295
299
296
final File workDir = setupBuildEnvironment ();
300
297
if (infile != null ) {
@@ -303,7 +300,50 @@ public void execute() throws MojoExecutionException {
303
300
if (getLog ().isDebugEnabled ()) {
304
301
getLog ().debug ("Trying to load Launch4j native configuration using file=" + infile .getAbsolutePath ());
305
302
}
303
+ // load launch4j configfile from <infile>
306
304
ConfigPersister .getInstance ().load (infile );
305
+
306
+ // overwrite several properties analogous to the ANT task
307
+ // https://sourceforge.net/p/launch4j/git/ci/master/tree/src/net/sf/launch4j/ant/Launch4jTask.java#l84
308
+
309
+ // retreive the loaded configuration for manipulation
310
+ Config c = ConfigPersister .getInstance ().getConfig ();
311
+
312
+ String jarDefaultValue = project .getBuild ().getDirectory () + "/" + project .getBuild ().getFinalName () + ".jar" ;
313
+ if (jar != null && !jar .equals (jarDefaultValue )) {
314
+ getLog ().debug ("Overwriting config file property 'jar' (='" +c .getJar ().getAbsolutePath ()+"') with local value '" +getJar ().getAbsolutePath ()+"'" );
315
+ // only overwrite when != defaultValue (should be != null anytime because of the default value)
316
+ c .setJar (getJar ());
317
+ }
318
+
319
+ File outFileDefaultValue = new File (project .getBuild ().getDirectory () + "/" + project .getArtifactId () + ".exe" );
320
+ if (outfile != null && !outfile .getAbsolutePath ().equals (outFileDefaultValue .getAbsolutePath ())) {
321
+ // only overwrite when != defaultValue (should be != null anytime because of the default value)
322
+ getLog ().debug ("Overwriting config file property 'outfile' (='" +c .getOutfile ().getAbsolutePath ()+"') with local value '" +outfile .getAbsolutePath ()+"'" );
323
+ c .setOutfile (outfile );
324
+ }
325
+
326
+ if (versionInfo != null ) {
327
+ if (versionInfo .fileVersion != null ) {
328
+ getLog ().debug ("Overwriting config file property 'versionInfo.fileVersion' (='" +c .getVersionInfo ().getFileVersion ()+"') with local value '" +versionInfo .fileVersion +"'" );
329
+ c .getVersionInfo ().setFileVersion (versionInfo .fileVersion );
330
+ }
331
+ if (versionInfo .txtFileVersion != null ) {
332
+ getLog ().debug ("Overwriting config file property 'versionInfo.txtFileVersion' (='" +c .getVersionInfo ().getTxtFileVersion ()+"') with local value '" +versionInfo .txtFileVersion +"'" );
333
+ c .getVersionInfo ().setTxtFileVersion (versionInfo .txtFileVersion );
334
+ }
335
+ if (versionInfo .productVersion != null ) {
336
+ getLog ().debug ("Overwriting config file property 'versionInfo.productVersion' (='" +c .getVersionInfo ().getProductVersion ()+"') with local value '" +versionInfo .productVersion +"'" );
337
+ c .getVersionInfo ().setProductVersion (versionInfo .productVersion );
338
+ }
339
+ if (versionInfo .txtProductVersion != null ) {
340
+ getLog ().debug ("Overwriting config file property 'versionInfo.txtProductVersion' (='" +c .getVersionInfo ().getTxtProductVersion ()+"') with local value '" +versionInfo .txtProductVersion +"'" );
341
+ c .getVersionInfo ().setTxtProductVersion (versionInfo .txtProductVersion );
342
+ }
343
+ }
344
+
345
+ ConfigPersister .getInstance ().setAntConfig (c , infile .getParentFile ());
346
+
307
347
} catch (ConfigPersisterException e ) {
308
348
getLog ().error (e );
309
349
throw new MojoExecutionException ("Could not load Launch4j native configuration file" , e );
@@ -353,6 +393,10 @@ public void execute() throws MojoExecutionException {
353
393
ConfigPersister .getInstance ().setAntConfig (c , getBaseDir ());
354
394
}
355
395
396
+ if (getLog ().isDebugEnabled ()) {
397
+ printState ();
398
+ }
399
+
356
400
final Builder builder = new Builder (new MavenLog (getLog ()), workDir );
357
401
try {
358
402
builder .build ();
@@ -563,82 +607,85 @@ private File getBaseDir() {
563
607
*/
564
608
private void printState () {
565
609
Log log = getLog ();
566
-
567
- log .debug ("headerType = " + headerType );
568
- log .debug ("outfile = " + outfile );
569
- log .debug ("jar = " + jar );
570
- log .debug ("dontWrapJar = " + dontWrapJar );
571
- log .debug ("errTitle = " + errTitle );
572
- log .debug ("downloadUrl = " + downloadUrl );
573
- log .debug ("supportUrl = " + supportUrl );
574
- log .debug ("cmdLine = " + cmdLine );
575
- log .debug ("chdir = " + chdir );
576
- log .debug ("priority = " + priority );
577
- log .debug ("stayAlive = " + stayAlive );
578
- log .debug ("restartOnCrash = " + restartOnCrash );
579
- log .debug ("icon = " + icon );
580
- log .debug ("objs = " + objs );
581
- log .debug ("libs = " + libs );
582
- log .debug ("vars = " + vars );
583
- if (singleInstance != null ) {
584
- log .debug ("singleInstance.mutexName = " + singleInstance .mutexName );
585
- log .debug ("singleInstance.windowTitle = " + singleInstance .windowTitle );
610
+ Config c = ConfigPersister .getInstance ().getConfig ();
611
+
612
+ log .debug ("headerType = " + c .getHeaderType ());
613
+ log .debug ("outfile = " + c .getOutfile ());
614
+ log .debug ("jar = " + c .getJar ());
615
+ log .debug ("dontWrapJar = " + c .isDontWrapJar ());
616
+ log .debug ("errTitle = " + c .getErrTitle ());
617
+ log .debug ("downloadUrl = " + c .getDownloadUrl ());
618
+ log .debug ("supportUrl = " + c .getSupportUrl ());
619
+ log .debug ("cmdLine = " + c .getCmdLine ());
620
+ log .debug ("chdir = " + c .getChdir ());
621
+ log .debug ("priority = " + c .getPriority ());
622
+ log .debug ("stayAlive = " + c .isStayAlive ());
623
+ log .debug ("restartOnCrash = " + c .isRestartOnCrash ());
624
+ log .debug ("icon = " + c .getIcon ());
625
+ log .debug ("objs = " + c .getHeaderObjects ());
626
+ log .debug ("libs = " + c .getLibs ());
627
+ log .debug ("vars = " + c .getVariables ());
628
+ if (c .getSingleInstance () != null ) {
629
+ log .debug ("singleInstance.mutexName = " + c .getSingleInstance ().getMutexName ());
630
+ log .debug ("singleInstance.windowTitle = " + c .getSingleInstance ().getWindowTitle ());
586
631
} else {
587
632
log .debug ("singleInstance = null" );
588
633
}
589
- if (jre != null ) {
590
- log .debug ("jre.path = " + jre . path );
591
- log .debug ("jre.minVersion = " + jre . minVersion );
592
- log .debug ("jre.maxVersion = " + jre . maxVersion );
593
- log .debug ("jre.jdkPreference = " + jre . jdkPreference );
594
- log .debug ("jre.initialHeapSize = " + jre . initialHeapSize );
595
- log .debug ("jre.initialHeapPercent = " + jre . initialHeapPercent );
596
- log .debug ("jre.maxHeapSize = " + jre . maxHeapSize );
597
- log .debug ("jre.maxHeapPercent = " + jre . maxHeapPercent );
598
- log .debug ("jre.opts = " + jre . opts );
634
+ if (c . getJre () != null ) {
635
+ log .debug ("jre.path = " + c . getJre (). getPath () );
636
+ log .debug ("jre.minVersion = " + c . getJre (). getMinVersion () );
637
+ log .debug ("jre.maxVersion = " + c . getJre (). getMaxVersion () );
638
+ log .debug ("jre.jdkPreference = " + c . getJre (). getJdkPreference () );
639
+ log .debug ("jre.initialHeapSize = " + c . getJre (). getInitialHeapSize () );
640
+ log .debug ("jre.initialHeapPercent = " + c . getJre (). getInitialHeapPercent () );
641
+ log .debug ("jre.maxHeapSize = " + c . getJre (). getMaxHeapSize () );
642
+ log .debug ("jre.maxHeapPercent = " + c . getJre (). getMaxHeapPercent () );
643
+ log .debug ("jre.opts = " + c . getJre (). getOptions () );
599
644
} else {
600
645
log .debug ("jre = null" );
601
646
}
647
+ if (c .getClassPath () != null ) {
648
+ log .debug ("classPath.mainClass = " + c .getClassPath ().getMainClass ());
649
+ }
602
650
if (classPath != null ) {
603
- log .debug ("classPath.mainClass = " + classPath .mainClass );
604
651
log .debug ("classPath.addDependencies = " + classPath .addDependencies );
605
652
log .debug ("classPath.jarLocation = " + classPath .jarLocation );
606
653
log .debug ("classPath.preCp = " + classPath .preCp );
607
654
log .debug ("classPath.postCp = " + classPath .postCp );
608
655
} else {
609
656
log .info ("classpath = null" );
610
657
}
611
- if (splash != null ) {
612
- log .debug ("splash.file = " + splash . file );
613
- log .debug ("splash.waitForWindow = " + splash . waitForWindow );
614
- log .debug ("splash.timeout = " + splash . timeout );
615
- log .debug ("splash.timoutErr = " + splash . timeoutErr );
658
+ if (c . getSplash () != null ) {
659
+ log .debug ("splash.file = " + c . getSplash (). getFile () );
660
+ log .debug ("splash.waitForWindow = " + c . getSplash (). getWaitForWindow () );
661
+ log .debug ("splash.timeout = " + c . getSplash (). getTimeout () );
662
+ log .debug ("splash.timoutErr = " + c . getSplash (). isTimeoutErr () );
616
663
} else {
617
664
log .debug ("splash = null" );
618
665
}
619
- if (versionInfo != null ) {
620
- log .debug ("versionInfo.fileVersion = " + versionInfo . fileVersion );
621
- log .debug ("versionInfo.txtFileVersion = " + versionInfo . txtFileVersion );
622
- log .debug ("versionInfo.fileDescription = " + versionInfo . fileDescription );
623
- log .debug ("versionInfo.copyright = " + versionInfo . copyright );
624
- log .debug ("versionInfo.productVersion = " + versionInfo . productVersion );
625
- log .debug ("versionInfo.txtProductVersion = " + versionInfo . txtProductVersion );
626
- log .debug ("versionInfo.productName = " + versionInfo . productName );
627
- log .debug ("versionInfo.companyName = " + versionInfo . companyName );
628
- log .debug ("versionInfo.internalName = " + versionInfo . internalName );
629
- log .debug ("versionInfo.originalFilename = " + versionInfo . originalFilename );
630
- log .debug ("versionInfo.language = " + versionInfo . language );
631
- log .debug ("versionInfo.languageIndex = " + versionInfo . languageIndex );
632
- log .debug ("versionInfo.trademarks = " + versionInfo . trademarks );
666
+ if (c . getVersionInfo () != null ) {
667
+ log .debug ("versionInfo.fileVersion = " + c . getVersionInfo (). getFileVersion () );
668
+ log .debug ("versionInfo.txtFileVersion = " + c . getVersionInfo (). getTxtFileVersion () );
669
+ log .debug ("versionInfo.fileDescription = " + c . getVersionInfo (). getFileDescription () );
670
+ log .debug ("versionInfo.copyright = " + c . getVersionInfo (). getCopyright () );
671
+ log .debug ("versionInfo.productVersion = " + c . getVersionInfo (). getProductVersion () );
672
+ log .debug ("versionInfo.txtProductVersion = " + c . getVersionInfo (). getTxtProductVersion () );
673
+ log .debug ("versionInfo.productName = " + c . getVersionInfo (). getProductName () );
674
+ log .debug ("versionInfo.companyName = " + c . getVersionInfo (). getCompanyName () );
675
+ log .debug ("versionInfo.internalName = " + c . getVersionInfo (). getInternalName () );
676
+ log .debug ("versionInfo.originalFilename = " + c . getVersionInfo (). getOriginalFilename () );
677
+ log .debug ("versionInfo.language = " + c . getVersionInfo (). getLanguage () );
678
+ log .debug ("versionInfo.languageIndex = " + c . getVersionInfo (). getLanguageIndex () );
679
+ log .debug ("versionInfo.trademarks = " + c . getVersionInfo (). getTrademarks () );
633
680
} else {
634
681
log .debug ("versionInfo = null" );
635
682
}
636
- if (messages != null ) {
637
- log .debug ("messages.startupErr = " + messages . startupErr );
638
- log .debug ("messages.bundledJreErr = " + messages . bundledJreErr );
639
- log .debug ("messages.jreVersionErr = " + messages . jreVersionErr );
640
- log .debug ("messages.launcherErr = " + messages . launcherErr );
641
- log .debug ("messages.instanceAlreadyExistsMsg = " + messages . instanceAlreadyExistsMsg );
683
+ if (c . getMessages () != null ) {
684
+ log .debug ("messages.startupErr = " + c . getMessages (). getStartupErr () );
685
+ log .debug ("messages.bundledJreErr = " + c . getMessages (). getBundledJreErr () );
686
+ log .debug ("messages.jreVersionErr = " + c . getMessages (). getJreVersionErr () );
687
+ log .debug ("messages.launcherErr = " + c . getMessages (). getLauncherErr () );
688
+ log .debug ("messages.instanceAlreadyExistsMsg = " + c . getMessages (). getInstanceAlreadyExistsMsg () );
642
689
} else {
643
690
log .debug ("messages = null" );
644
691
}
0 commit comments