Building C++ and Java code using CMake and Maven and bundle in a jar

后端 未结 1 409
走了就别回头了
走了就别回头了 2021-02-05 21:08

I have legacy C++ code that is built using CMake. It generates a .so file. I need to wrap this code in Java and build a jar that includes Java code as

1条回答
  •  感情败类
    2021-02-05 21:12

    In Apache Hadoop, the build does something similar to what you described. We use the Apache Maven AntRun Plugin during the compile phase to make an external call to cmake and then call make on the build output generated by CMake to compile and link the C portion of our codebase. This output then feeds into our final build artifacts. In our case, those build artifacts are tarballs rather than bundled straight into a jar file, but you could accomplish it by controlling configuration of the Apache Maven JAR Plugin. Specifically, you may need to override content include/exclude settings.

    If you'd like to use it as a starting point, the relevant part of the Hadoop build is visible here:

    https://github.com/apache/hadoop/blob/release-2.7.3-RC2/hadoop-common-project/hadoop-common/pom.xml#L598-L615

    
      make
      compile
      run
      
        
          
            
          
          
            
          
          
          
        
      
    
    

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