【问题标题】:Using maven2 to build autotools-based C/C++ package使用maven2构建基于autotools的C/C++包
【发布时间】:2023-03-20 01:49:01
【问题描述】:

我正在开发一个集合 MATLAB、Java 和 C/C++ 组件,它们都可以互操作,但编译/安装步骤截然不同。我们目前不为 MATLAB 编译任何东西,使用 maven2 进行 Java 构建和单元测试,并使用 autotools 进行 C/C++ 构建和单元测试。

我想使用 maven2 将所有内容移到单个构建和单元测试系统中,但我找不到一个插件可以让 C/C++ 代码流保持基于 autotools 并简单地将其包装在 maven 中建造。不得不取消 autotools 支持并在 maven 中重新创建所有依赖项很可能会破坏交易,所以我正在寻找一种让 maven 和 autotools 很好地协同工作的方法,而不是必须在两者之间进行选择。

这是可能的,甚至是可取的吗?有没有我忽略的资源?

【问题讨论】:

    标签: c++ maven-2 build-automation autotools


    【解决方案1】:

    我不太了解自动工具,但你不能使用maven exec plugin,它可以让你执行系统命令(或Java 程序)吗?例如:

    <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>
    

    我没有测试上面的 pom 片段,但它给了你一些关于如何继续的提示。

    【讨论】:

    • 我一直在寻找一种不必将每个 maven 命令都转换为系统命令的方法。它使维护复杂化,而且不像 Java 构建那样干净。如果我最终不得不编写所有脚本,我可能最终会在 maven 之外为 C/C++ 工具工作。
    【解决方案2】:

    您确实忽略了 maven cbuild parent 套件。查看“make-maven-plugin”部分了解更多详情。

    【讨论】:

    • 这看起来很有希望,但他们仍然只是声称处于 alpha 状态。绝对是要跟踪的东西,并且符合我正在寻找的东西。我会在测试可用功能后更新更多内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-30
    • 2015-06-30
    • 1970-01-01
    • 1970-01-01
    • 2014-02-24
    • 2011-07-16
    • 1970-01-01
    相关资源
    最近更新 更多