@@ -286,7 +286,7 @@ public void configureLinker(final LinkerDef linker) throws MojoExecutionExceptio
286
286
}
287
287
288
288
// Visual Studio
289
- if (compareVersion (version , "16 .0" ) < 0 ) {
289
+ if (compareVersion (version , "15 .0" ) < 0 ) {
290
290
if ("x86" .equals (arch )) {
291
291
linker .addLibraryDirectory (msvctoolhome , "lib" );
292
292
linker .addLibraryDirectory (msvctoolhome , "atlmfc/lib" );
@@ -367,7 +367,7 @@ private String getTempPath() {
367
367
private void initPath (CrossCompilers compiler ) throws MojoExecutionException {
368
368
369
369
Boolean found = true ;
370
- if (compareVersion (version , "16 .0" ) < 0 ) {
370
+ if (compareVersion (version , "15 .0" ) < 0 ) {
371
371
switch (compiler ) {
372
372
case x86 :
373
373
// compile using x86 tools.
@@ -446,7 +446,7 @@ private void initPath(CrossCompilers compiler) throws MojoExecutionException {
446
446
}
447
447
448
448
// tools that are more generic
449
- if (compareVersion (version , "16 .0" ) < 0 ) {
449
+ if (compareVersion (version , "15 .0" ) < 0 ) {
450
450
addPath (msvctoolhome , "VCPackages" );
451
451
addPath (home , "Common7/Tools" );
452
452
addPath (home , "Common7/IDE" );
@@ -559,11 +559,15 @@ private void initVisualStudio() throws MojoFailureException, MojoExecutionExcept
559
559
WindowsSdkVerBinPath=C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\
560
560
WindowsSDKVersion=10.0.18362.0\
561
561
*/
562
- // examine the VS version variable first before attempting to read older registry entries which are not supported in later VS versions
563
- this .version = System .getenv ("VisualStudioVersion" );
564
-
562
+ // don't attempt to subvert the version setting from the pom
563
+ if (version == null || version .trim ().length () < 1 ) {
564
+ // examine the VS version variable before attempting to read older registry entries which are not supported in later VS versions
565
+ String envVisualStudioVersion = System .getenv ("VisualStudioVersion" );
566
+ if (envVisualStudioVersion != null && envVisualStudioVersion .length () > 3 ) {
567
+ this .version = envVisualStudioVersion ;
568
+ }
569
+ }
565
570
mojo .getLog ().debug ("Requested Linker version is \" " + version + "\" " );
566
-
567
571
if (version != null && version .trim ().length () > 1 ) {
568
572
String internalVersion ;
569
573
Pattern r = Pattern .compile ("(\\ d+)\\ .*(\\ d)" );
@@ -596,7 +600,7 @@ private void initVisualStudio() throws MojoFailureException, MojoExecutionExcept
596
600
mojo .getLog ().debug (String .format (" VisualStudio %1s (%2s) found %3s " , version , internalVersion , home ));
597
601
} else {
598
602
// reset
599
- this .version = "" ; //
603
+ this .version = "" ;
600
604
// First search registry for installed items, more reliable than environment.
601
605
for (final Entry <String , Object > entry : visualStudioVS7SxS (com .sun .jna .platform .win32 .WinReg .HKEY_LOCAL_MACHINE ,
602
606
"SOFTWARE\\ Microsoft\\ VisualStudio\\ SxS\\ VS7" ).entrySet ()) {
@@ -850,7 +854,7 @@ private void addSDKLibs(File includeDir, File libdir) {
850
854
}
851
855
852
856
private File VCToolHome () {
853
- if (compareVersion (version , "16 .0" ) < 0 ) {
857
+ if (compareVersion (version , "15 .0" ) < 0 ) {
854
858
return new File (home , "VC/" );
855
859
} else {
856
860
final File msvcversionFile = new File (home , "VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" );
0 commit comments