简体   繁体   中英

Maven project structure for Java+JNI project

The default Java Maven project structure is usually

src/
  main/
    java/
      org/example/Main.java
  test/
    java/

If I have a project with C++/JNI code, would it be right to extend on this idea and put the C++ code into the folder src/main/cpp or would it be usually put somewhere else? If so, what is the rationale behind the java folder?

According to the description of the Maven directory structure :

If there are other contributing sources to the artifact build, they would be under other subdirectories. For example src/main/antlr would contain Antlr grammar definition files.

Taking into account that JNI code is also something contributing to the artifact build, that the default Android Studio project structure for Android apps with NDK also includes a folder src/main/cpp , and that JNI code is naturally hardly coupled with the corresponding Java class, I believe it's best to include at least the JNI code into the Java project at src/main/cpp . Usually, the core C/C++ library code is something generalizable, so it would be kept in a separate project and built separately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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