Skip to content

Commit 86587ea

Browse files
committed
Removed forced VS version 16.0 setting. Reset compare checks back to 15.0
1 parent 457fed1 commit 86587ea

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/main/java/com/github/maven_nar/Msvc.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public void configureLinker(final LinkerDef linker) throws MojoExecutionExceptio
286286
}
287287

288288
// Visual Studio
289-
if (compareVersion(version, "16.0") < 0) {
289+
if (compareVersion(version, "15.0") < 0) {
290290
if ("x86".equals(arch)) {
291291
linker.addLibraryDirectory(msvctoolhome, "lib");
292292
linker.addLibraryDirectory(msvctoolhome, "atlmfc/lib");
@@ -367,7 +367,7 @@ private String getTempPath() {
367367
private void initPath(CrossCompilers compiler) throws MojoExecutionException {
368368

369369
Boolean found = true;
370-
if (compareVersion(version, "16.0") < 0) {
370+
if (compareVersion(version, "15.0") < 0) {
371371
switch (compiler) {
372372
case x86:
373373
// compile using x86 tools.
@@ -446,7 +446,7 @@ private void initPath(CrossCompilers compiler) throws MojoExecutionException {
446446
}
447447

448448
// tools that are more generic
449-
if (compareVersion(version, "16.0") < 0) {
449+
if (compareVersion(version, "15.0") < 0) {
450450
addPath(msvctoolhome, "VCPackages");
451451
addPath(home, "Common7/Tools");
452452
addPath(home, "Common7/IDE");
@@ -559,11 +559,15 @@ private void initVisualStudio() throws MojoFailureException, MojoExecutionExcept
559559
WindowsSdkVerBinPath=C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\
560560
WindowsSDKVersion=10.0.18362.0\
561561
*/
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+
}
565570
mojo.getLog().debug("Requested Linker version is \"" + version + "\"");
566-
567571
if (version != null && version.trim().length() > 1) {
568572
String internalVersion;
569573
Pattern r = Pattern.compile("(\\d+)\\.*(\\d)");
@@ -596,7 +600,7 @@ private void initVisualStudio() throws MojoFailureException, MojoExecutionExcept
596600
mojo.getLog().debug(String.format(" VisualStudio %1s (%2s) found %3s ", version, internalVersion, home));
597601
} else {
598602
// reset
599-
this.version = ""; //
603+
this.version = "";
600604
// First search registry for installed items, more reliable than environment.
601605
for (final Entry<String, Object> entry : visualStudioVS7SxS(com.sun.jna.platform.win32.WinReg.HKEY_LOCAL_MACHINE,
602606
"SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7").entrySet()) {
@@ -850,7 +854,7 @@ private void addSDKLibs(File includeDir, File libdir) {
850854
}
851855

852856
private File VCToolHome() {
853-
if (compareVersion(version, "16.0") < 0) {
857+
if (compareVersion(version, "15.0") < 0) {
854858
return new File(home, "VC/");
855859
} else {
856860
final File msvcversionFile = new File(home, "VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt");

0 commit comments

Comments
 (0)