Using maven2 to build autotools-based C/C++ package

本秂侑毒 提交于 2020-01-13 05:14:05

问题


I am working on a collection MATLAB, Java, and C/C++ components that all inter-operate, but have distinctly different compilation/installation steps. We currently don't compile anything for MATLAB, use maven2 for our Java build and unit tests, and use autotools for our C/C++ build and unit tests.

I would like to move everything to a single build and unit test system, using maven2, but have not been able to find a plugin that will allow the C/C++ codestream to remain autotools-based and simply wrap it in a maven build. Having to rip out autotools support and recreate all the dependencies in maven is most likely a deal-breaker, so I'm looking for a way for maven and autotools to play nicely together, rather than having to choose between the two.

Is this possible or even desirable? Are there resources out there that I have overlooked?


回答1:


I don't really know autotools, but can't you use the maven exec plugin, that lets you execute system commands (or Java programs)? For example:

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <executions>
        <execution>
          <id>exec-one</id>
          <phase>compile</phase>
          <configuration>
            <executable>autogen</executable>
            <arguments>
              <argument>-v</argument>
            </arguments>
          </configuration>
          <goals>
            <goal>exec</goal>
          </goals>
        </execution>

        <execution>
          <id>exec-two</id>
          <phase>compile</phase>
          <configuration>
            <executable>automake</executable>
            <arguments>
              <argument>-v</argument>
              <argument>[other arguments]</argument>
            </arguments>
          </configuration>
          <goals>
            <goal>exec</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

I didn't test the pom fragment above, but it gives you some hints about how to proceed.




回答2:


You did overlook the maven cbuild parent suite. take a look at the "make-maven-plugin" section for more details.



来源:https://stackoverflow.com/questions/190996/using-maven2-to-build-autotools-based-c-c-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!