Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency as a source code - is it possible? #329

Closed
wmarkow opened this issue Oct 7, 2018 · 4 comments
Closed

Dependency as a source code - is it possible? #329

wmarkow opened this issue Oct 7, 2018 · 4 comments

Comments

@wmarkow
Copy link

wmarkow commented Oct 7, 2018

I have a generic question about using nar-maven-plugin. I do not know how to configure the plugin to do what I want to do. Here is the case:
in my main C++ project (let's call it MAIN) I want to use two dependencies: let's call it A and B. I can provide those dependencies as a NAR packages and they will be available in my local Maven repository. One remark is, that those dependecies are provided as a source code. It would be nice if I could do the following with nar-maven-plugin when I execute mvn clean package on MAIN project:

  • NAR notices that my MAIN project uses two dependencies A and B which are a source code, so they need to be compiled as well. So it copies them (and unzipps as well from NAR package) to - for example - target/nar/libraries
  • NAR automatically adds target/nar/libraries to the source folder list, so it will be compiled together with MAIN sources
  • NAR automatically passes those A and B "libraries" to the execution of gcc's search path, so it will be possible to find include files, something like:
    gcc -IpathToIncludesOfA -IpathToIncludesOfB ...

I thought that nar plugin will unpack the dependencies in the NarUnpackMojo but it doesn't work; the dependencies A and B are not copied. I took a quick look at the source code of NarUnpackMojo and it looks like it will copy only the dependencies that are defined by A and B, but not the A and B itself. Is it a desired behavior? Maybe I do not understand how it suppose to work or I'm not using nar-maven-plugin correctly?

@wmarkow
Copy link
Author

wmarkow commented Oct 7, 2018

Are there any chances thy this issue is related to #326?

@wmarkow
Copy link
Author

wmarkow commented Oct 7, 2018

The com.github.maven_nar.NarUnpackMojo.narExecute() method uses com.github.maven_nar.AbstractDependencyMojo.getAttachedNarArtifacts(List<? extends Executable>) to get the list of dependencies to unpack. In my case this list is empty and dependencies A and B are not there. It is obvious as getAttachedNarArtifacts lists the dependenices of A and B but do not include A and B itself.

I have modified a bit com.github.maven_nar.NarUnpackMojo.narExecute() so it adds to the list of dependency also A and B (to do that I have used com.github.maven_nar.AbstractDependencyMojo.getNarArtifacts() and then convert its result to AttachedNarArtifact objects).

With this modification nar-maven-plugin copies the A and B dependencies to target/nar/libraries folder and also tries to compile them (I'm using build-helper-maven-plugin to add this path to the sources). I see also that the gcc's search path is updated automatically with includes path, like gcc -I${project.build.directory}/nar/libraries/A/include -I${project.build.directory}/nar/libraries/B/include

Is this a bug or I have configured the plugin incorrectly? Am I on the good way?

@wmarkow
Copy link
Author

wmarkow commented Nov 21, 2018

I have just one more thing to say in this topic. The search path from my last comment is like:
-I${project.build.directory}/nar/libraries/A/include -I${project.build.directory}/nar/libraries/B/include

It is not so good, because the A and B libraries that I have doesn't contain any *include folder. What I want to say that those libraries doesn't follow the NarFileLayout10.java

I wanted to compile Arduino project with nar-maven-plugin but the Arduino library's layout is different; there is no such a folders like include, bin or lib.

@bchiodo
Copy link
Contributor

bchiodo commented Dec 21, 2020

If the dependency is not a nar file (doesn't conform to a NarLayout) then this plugin will not help you. If you want to do something like this, it has to be configured manually using the maven-dependency-plugin unpack or similar. That way, you can unpack the source code to a directory under target and add that as a source directory to your project. Since this isn't a bug in NAR itself, I am closing.

@bchiodo bchiodo closed this as completed Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants