NAR plugin can't locate header files

405 views
Skip to first unread message

KAnand

unread,
Feb 5, 2014, 7:17:56 PM2/5/14
to mave...@googlegroups.com
Hi,

I am trying to build a NAR, in the directory foo, say) that depends on another NAR (built in another directory, say bar) and hence the source code for the one in foo, depends on the header files in bar.

In the absence of the <includes> <include></include>  </includes> block of my cpp execution block, the compilation fails because it can't find certain header files (as expected).

<cpp>
   <!-- Suppress all warnings -->
   <options>
       <option>-w</option>
   </options>
   <sourceDirectory>../../../sources/cpp-sources/foo/src/main</sourceDirectory>

</cpp> 


Next, I add teh <includes> block as shown below:

<cpp>
   <!-- Suppress all warnings -->
   <options>
       <option>-w</option>
   </options>
   <sourceDirectory>../../../sources/cpp-sources/foo/src/main</sourceDirectory>
   <includes>
        <include>../../../sources/cpp-sources/bar/src/main/include/blah.h</include>
   </includes>

</cpp>


This time, it finds no sources to compile.  Build succeeds, with no NAR generated.  NOTE: It does find the dependency NAR that was packaged in bar and unpacked during goal executions.  This is bizzare!  Why would including headers, eliminate sources?  And why are headers not being found once the includes are specified?


Does NAR plugin have any restrictions on location of header files?

Any help is greatly appreciated.


Thanks


KAnand

Henrik Horneber

unread,
Feb 6, 2014, 3:20:08 AM2/6/14
to mave...@googlegroups.com
... I accidentally did not reply-to-list, so here's a copy of my answer. FWIW.

---------- Forwarded message ----------
From: Henrik Horneber <horn...@gmail.com>
Date: Thu, Feb 6, 2014 at 9:18 AM
Subject: Re: [maven-nar] NAR plugin can't locate header files
To: KAnand <keerti...@gmail.com>


Hi,

<includes> is for source files, not headers. From http://duns.github.io/maven-nar-plugin/configuration.html:
"cpp includes

Include patterns for sources, relative to sourceDirectory in "ant" style."

For header files, use

<includePaths> and <systemIncludePaths>, depending on whether you want to include (i.e. package) the header files in your nar artefact.

For headers of nar libraries you depend on, i.e. you have in your <dependencies> section, it should just work (TM).
It does for me, at least.
From your mail it sounds as if you already depend on 'bar' -- does the bar nar file contain headers?

Hope that helps.

Henrik







--
You received this message because you are subscribed to the Google Groups "NAR Maven plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-nar+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
"I find many of the machines of violence very attractive. Tanks, airplanes, warships, especially aircraft carriers."
- 14th Dalai Lama



--
"I find many of the machines of violence very attractive. Tanks, airplanes, warships, especially aircraft carriers."
- 14th Dalai Lama

Greg Domjan

unread,
Feb 6, 2014, 1:20:03 PM2/6/14
to mave...@googlegroups.com
Hi KAnand

Following from Henriks advice that the <include> section your using relates to the source files to compile, not the sdk includes folder.

Assuming a directory structure something like

    build/maven/
      bar
      foo
    sources/cpp-sources/
      bar
      foo

in bar
    <sourceDirectory>../../../sources/cpp-sources/bar/src/main</sourceDirectory>
    <resourceDirectory>../../../sources/cpp-sources/bar/src/main/include</resourceDirectory>
also consider...
    <testSourceDirectory>  <testResourceDirectory>
    <gnuSourceDirectory>

in foo
    <sourceDirectory>../../../sources/cpp-sources/foo/src/main</sourceDirectory>
    <resourceDirectory>../../../sources/cpp-sources/foo/src/main/include</resourceDirectory>
   
By specifying the resourceDirectory in a different location NAR should
 * make that folder available in the build of the artifact using -I
 * have the contents copied to the noarch jar and when used as a dependency it will be unpacked and referred to using -I

Also files in  ${project.build.directory}/nar/resources/include  will be copied to noarch jar


So if bar project has in the ${resourceDirectory} folder a file  blah.h 
Then foo  can use it by   #include <blah.h>

Suggestion but includes into a folder named after the sdk/module - many OS SDK  put their includes in a subfolder with their name, this will help avoid filename clashes.


If there where some other additions or reason to,  could also use the resources
        <resources>
            <resource>
                <targetPath>target/nar/${project.artifactid}-${project.version}-noarch</targetPath>
                <filtering>false</filtering>
                <directory>../../../sources/cpp-sources/foo/src/main/include</directory>
                <includes>
                    <include>*.h</include>
                </includes>
            </resource>
        </resources>

KAnand

unread,
Feb 6, 2014, 2:34:06 PM2/6/14
to mave...@googlegroups.com
That makes sense.  Thanks so much.  
Reply all
Reply to author
Forward
0 new messages