Using Maven for C/C++ projects

后端 未结 1 1464
失恋的感觉
失恋的感觉 2020-11-30 17:55

I\'m putting Maven build around cluster of amateur, poorly written and frankly - primitive C/C++ code (meaning some C, some C++). Problem is - there\'s lots of it in circula

相关标签:
1条回答
  • 2020-11-30 18:27

    I highly recommend the maven-nar-plugin. I find it superior in many ways to the alternatives. It doesn't require listing out source files, handles multiple OSes and architectures, handles unit and integration tests, and generally follows "the maven way". It introduces a new kind of packaging - the NAR, or "native archive", that contains the artifact you care about (.dll, .so, .a, .exe, etc.) but also metadata, headers, etc. in a way that makes sense.

    It does require a bit of up front work to package third-party software up into NARs, but its pretty straightforward. Once they are NARs, you simply use the normal Maven dependency mechanism to link with them, for example:

    <dependency>
      <groupId>cppunit</groupId>
      <artifactId>cppunit</artifactId>
      <scope>test</scope>
    </dependency>
    

    One drawback is that it does not appear to be actively maintained, but it is full-featured and is a rather impressive example of Maven plugin authoring.

    0 讨论(0)
提交回复
热议问题