如何使用 maven-nar 插件生成 cpp 二进制文件
how to generate cpp binaries using maven-nar plugin
我需要有关使用 maven-nar 编译 C++ 代码的帮助 plugin.I 尝试通读文档但无法使代码正常工作。非常感谢任何帮助
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.github.maven-nar</groupId>
<artifactId>maven-nar-poc</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>nar</packaging>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<libraries>
<library>
<type>jni</type>
<narSystemPackage>com.github.maven-nar</narSystemPackage>
</library>
</libraries>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/nar/nar-generated/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>mac</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<skip>false</skip>
<cpp>
<debug>true</debug>
<includePaths>
<includePath>${project.basedir}/src/main/cpp</includePath>
</includePaths>
<options>
<option>-DMAC -DMAC_OSX -DMAC_CARBON -D__CF_USE_FRAMEWORK_INCLUDES__ -DLARGE64_FILES
</option>
</options>
</cpp>
<libraries>
<library>
<type>executable</type>
<!-- <run>true</run> -->
<subSystem>gui</subSystem>
</library>
</libraries>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<skip>false</skip>
<cpp>
<debug>true</debug>
<includePaths>
<includePath>${project.basedir}/src/main/cpp</includePath>
</includePaths>
<options>
<option>-DWINDOWS -D__CF_USE_FRAMEWORK_INCLUDES__ -DLARGE64_FILES
</option>
</options>
</cpp>
<libraries>
<library>
<type>executable</type>
<!-- <run>true</run> -->
<subSystem>gui</subSystem>
</library>
</libraries>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
上面的 pom.xml 不会引发任何问题,但它不会为 windows 创建任何二进制文件,而且我无法理解我可以为 WINDOWS 使用哪些选项。
不熟悉 mac 可执行文件的问题
这两个配置将结合在一起,如果您的目标是可执行文件,您可能不需要 jni 库部分。
<libraries>
<library>
<type>jni</type>
<narSystemPackage>com.github.maven-nar</narSystemPackage>
</library>
</libraries>
<libraries>
<library>
<type>executable</type>
<!-- <run>true</run> -->
<subSystem>gui</subSystem>
</library>
</libraries>
这个部分可能有用
- 在 1 中有多个选项可能是个问题 - 引用空格使这个 arg 而不是 3...
选项中的换行符可能是个问题...
<options>
<option>-DWINDOWS -D__CF_USE_FRAMEWORK_INCLUDES__ -DLARGE64_FILES
</option>
</options>
<options>
<option>-DWINDOWS</option>
<option>-D__CF_USE_FRAMEWORK_INCLUDES__</option>
<option>-DLARGE64_FILES</option>
</options>
但通常会像
<defines>
<define>WINDOWS</define>
<define>__CF_USE_FRAMEWORK_INCLUDES__</define>
<define>LARGE64_FILES</define>
</defines>
我需要有关使用 maven-nar 编译 C++ 代码的帮助 plugin.I 尝试通读文档但无法使代码正常工作。非常感谢任何帮助
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<groupId>com.github.maven-nar</groupId>
<artifactId>maven-nar-poc</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>nar</packaging>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<libraries>
<library>
<type>jni</type>
<narSystemPackage>com.github.maven-nar</narSystemPackage>
</library>
</libraries>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/nar/nar-generated/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>mac</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<skip>false</skip>
<cpp>
<debug>true</debug>
<includePaths>
<includePath>${project.basedir}/src/main/cpp</includePath>
</includePaths>
<options>
<option>-DMAC -DMAC_OSX -DMAC_CARBON -D__CF_USE_FRAMEWORK_INCLUDES__ -DLARGE64_FILES
</option>
</options>
</cpp>
<libraries>
<library>
<type>executable</type>
<!-- <run>true</run> -->
<subSystem>gui</subSystem>
</library>
</libraries>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<skip>false</skip>
<cpp>
<debug>true</debug>
<includePaths>
<includePath>${project.basedir}/src/main/cpp</includePath>
</includePaths>
<options>
<option>-DWINDOWS -D__CF_USE_FRAMEWORK_INCLUDES__ -DLARGE64_FILES
</option>
</options>
</cpp>
<libraries>
<library>
<type>executable</type>
<!-- <run>true</run> -->
<subSystem>gui</subSystem>
</library>
</libraries>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
上面的 pom.xml 不会引发任何问题,但它不会为 windows 创建任何二进制文件,而且我无法理解我可以为 WINDOWS 使用哪些选项。
不熟悉 mac 可执行文件的问题
这两个配置将结合在一起,如果您的目标是可执行文件,您可能不需要 jni 库部分。
<libraries>
<library>
<type>jni</type>
<narSystemPackage>com.github.maven-nar</narSystemPackage>
</library>
</libraries>
<libraries>
<library>
<type>executable</type>
<!-- <run>true</run> -->
<subSystem>gui</subSystem>
</library>
</libraries>
这个部分可能有用
- 在 1 中有多个选项可能是个问题 - 引用空格使这个 arg 而不是 3...
选项中的换行符可能是个问题...
<options> <option>-DWINDOWS -D__CF_USE_FRAMEWORK_INCLUDES__ -DLARGE64_FILES </option> </options> <options> <option>-DWINDOWS</option> <option>-D__CF_USE_FRAMEWORK_INCLUDES__</option> <option>-DLARGE64_FILES</option> </options>
但通常会像
<defines>
<define>WINDOWS</define>
<define>__CF_USE_FRAMEWORK_INCLUDES__</define>
<define>LARGE64_FILES</define>
</defines>