2

I have a project with multiple sub-modules and sub-sub-modules which has both java and native language code (Mostly native language). To process this native code, I use the maven-nar-plugin. Now, I don't have all the includes needed to compile the native code in my local repository. Is there anyway to give a directory to the maven-nar-plugin and include everything within it?

I've used <systemIncludePaths> and <includePaths> in the module's pom, but it still couldn't compile.

If there is an easier way to do this, than the direction I'm going, please do explain.

Rob Avery IV
  • 3,562
  • 10
  • 48
  • 72

1 Answers1

2

The following is still work in progress, but I think I am on the right track. I started with the following (standard) directory structure, in which I want to include a git c++ project:

+---src
    +---main
        +---c++
        +---java

Because I do not want to change the directory structure of the original make project, I needed to define the custom source directory and a custom include directory. This is the resulting directory structure after a pull (I left out irrelevant file structures):

+---src
    +---main
        +---c++
            +---data
                +--- ...
            +---examples
                +--- ...
            +---scripts
                +--- ...
            +---src
                +---hunalign
                    +--- ... (source files)
                +---include
                    +--- ... (header files)
                +---utils
                    +--- ... (helper classes)
            +---tools
                +--- ...

With the following configuration I got the project compiled.

    <build>
    <plugins>
        <plugin>
            <artifactId>maven-nar-plugin</artifactId>
            <version>2.1-SNAPSHOT</version>
            <extensions>true</extensions>
            <configuration>
                <libraries>
                    <library>
                        <type>executable</type>
                        <run>true</run>
                    </library>
                </libraries>
                <!-- Here is the config for the custom source dir and includes -->
                <cpp>
                    <sourceDirectory>
                        ${basedir}/src/main/c++/src/hunalign
                    </sourceDirectory>
                    <includes>
                        <include>${basedir}/src/main/c++/src/include/*.h</include>
                    </includes>
                </cpp>
                <libraries>
                    <library>
                        <type>executable</type>
                        <run>true</run>
                    </library>
                </libraries>
            </configuration>
        </plugin>
    </plugins>
</build>

EDIT: to make javah run properly, I had to symlink it, as maven kept looking in the wrong place for it:

sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home/bin/javah /Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home/jre/bin/javah
jvdbogae
  • 1,241
  • 9
  • 15
  • FWIW, we fixed the [javah problems with Java 7 on OS X](https://github.com/maven-nar/nar-maven-plugin/issues/41). And we released nar-maven-plugin 3.0.0, [available now from Maven Central](http://search.maven.org/#artifactdetails%7Ccom.github.maven-nar%7Cnar-maven-plugin%7C3.0.0%7Cmaven-plugin). ;-) – ctrueden Dec 16 '13 at 18:04
  • Yeah, I saw that. Thanks. But I only found the version after I stumbled upon the name change FAQ topic. I think, a lot of people are still googling for maven-nar-plugin instead of nar-maven-plugin. Should the tags in stackoverflow be changed/added accordingly, you think? – jvdbogae Dec 17 '13 at 09:46
  • I did edit the maven-nar-plugin tag yesterday to reflect the new name and location. Can SO tags be renamed? If not, it seems like creating a nar-maven-plugin tag too might dilute the question pool. I guess we could ask on Meta about it. – ctrueden Dec 17 '13 at 19:49