简体   繁体   English

使用Maven进行C / C ++项目

[英]Using Maven for C/C++ projects

I'm putting Maven build around cluster of amateur, poorly written and frankly - primitive C/C++ code (meaning some C, some C++). 我将Maven构建在业余,写得不好和坦率的群集之上 - 原始的C / C ++代码(意思是一些C,一些C ++)。 Problem is - there's lots of it in circulation currently and cannot be easily replaced. 问题是 - 目前流通很多,不容易更换。 Building it requires a lot of tribal knowledge (you have to go from cube to cube just to find out how to compile/build various parts) and releasing is total nightmare. 构建它需要大量的部落知识(你必须从立方体到立方体才能找到如何编译/构建各种部分)并且释放是完全的噩梦。 (No - I'm not going to rewrite it, plz don't ask) My question is - should I use maven-native-plugin to replace multitude of short makefiles or use exec-maven-plugin to simply execute these? (不 - 我不打算重写它,请不要问)我的问题是 - 我应该使用maven-native-plugin来替换大量的短makefile还是使用exec-maven-plugin来执行这些? I had pretty good experience so far with the latter doing .NET and don't know if I should invest into native plugin or stay with exec ? 到目前为止,我有很好的经验 ,后者做.NET,不知道我是否应该投资native插件或留在exec If you had experience with "Mavenizing" C/C++ I would love to get some advice. 如果你有“Mavenizing”C / C ++的经验,我很乐意得到一些建议。

I highly recommend the maven-nar-plugin . 我强烈推荐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". 它不需要列出源文件,处理多个操作系统和体系结构,处理单元和集成测试,并且通常遵循“maven方式”。 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. 它引入了一种新的包装--NAR或“本机存档”,它包含您关注的工件(.dll,.so,.a,.exe等),还包含元数据,标题等。有道理的方式。

It does require a bit of up front work to package third-party software up into NARs, but its pretty straightforward. 它需要一些前期工作才能将第三方软件打包到NAR中,但它非常简单。 Once they are NARs, you simply use the normal Maven dependency mechanism to link with them, for example: 一旦它们是NAR,您只需使用普通的Maven依赖机制与它们链接,例如:

<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. 一个缺点是它似乎没有得到积极维护,但它功能齐全,是Maven插件创作的一个相当令人印象深刻的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM