Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC resource files cause the build to fail with a NullPointer exception #370

Open
vindiagram opened this issue Jan 20, 2021 · 0 comments
Open

Comments

@vindiagram
Copy link

vindiagram commented Jan 20, 2021

When using the undocumented <versionInfo> field to generate details for an executable the build fails because the .res file compilation throws a null pointer execption. Thus at the end of the build during linking the build fails because this .res file does not exist.
This same issue occurs if a .rc file is created and included in the src/main directory.

The NullPointer exception occurs from the com.github.maven_nar.cpptasks.compiler.CommandLineCompiler function runCommand. The commands variable is null when the cmdLine arguments are added to it.

I tracked the issue to the com.github.maven_nar.NarCompileMojo in the createLibrary function when the resource compiler is added to the execution, the compilerDef commands must be set to compileCommands or an empty initialized list.

The following code block:
if (getResource() != null) { final CompilerDef res = getResource().getCompiler(Compiler.MAIN, null); if (res != null) { task.addConfiguredCompiler(res); } }

Should be

if (getResource() != null) { final CompilerDef res = getResource().getCompiler(Compiler.MAIN, null); if (res != null) { **res.setCommands(compileCommands);** task.addConfiguredCompiler(res); } }

Doing so resolves the error and allows the build to compile.

Note: I susspect this issue also exists when adding the IDL and Message compiler definitions before the resource compiler definition and thus the same line should be added to each of them as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant