Search code examples
c++cmavenpluginspackaging

unknown packaging nar - nar-maven-plugin


I use Maven to manage my Java projects build but sometimes I have projects written in C or C++ langage and I would like to use Maven too so it will be easier to manage those projects.

It seems the nar-maven-plugin should do the job. I tried to create an HelloWorld project just to test it. I thought it will be really simple as it is generally with Maven.

My pom.xml

<project
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.sample</groupId>
  <artifactId>helloworld-cplusplus-sample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>nar</packaging>
  <name>Helloworld</name>
  <build>
    <plugins>
      <plugin>
        <groupId>com.github.maven-nar</groupId>
        <artifactId>nar-maven-plugin</artifactId>
        <version>3.2.3</version>
        <configuration>
            <libraries>
                <library>
                    <type>executable</type>
                </library>
            </libraries>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

And i have the following error

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unknown packaging: nar @ line 7, column 14
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.sample:helloworld-cplusplus-sample:0.0.1-SNAPSHOT (D:\local\workspaces\TEST\HelloWorl
dMaven\pom.xml) has 1 error
[ERROR]     Unknown packaging: nar @ line 7, column 14
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

I'm using Maven 3.3.1.

I forced the download of nar-maven-plugin in my local repository using "mvn dependency:get ..." but it doesn't change anything.


Solution

  • As already answered, ;)

    link.exe is part of Microsoft Visual Studio, which is what NAR typically uses under the hood to compile C++ code on Windows.

    Try with

    <linker> 
    <name>g++</name>
    </linker>
    

    in your nar plugin configuration if you have MinGW or something other than MSVS.