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

Add a configuration property to include/exclude files from nativeSourceDirectory #12

Open
trustin opened this issue May 22, 2014 · 2 comments

Comments

@trustin
Copy link

trustin commented May 22, 2014

I'm using the 'generate' goal of the maven-hawtjni-plugin with the nativeSourceDirectory option. It works really well when the same set of native source files are used to produce the native library for different platforms. However, sometimes, some projects use different set of native source files for different OSes. (e.g. unix.c on Linux and Solaris and win32.c on Windows)

Maven profile might help specify different nativeSourceDirectory for different platforms, but it's not a good idea when only small number of .c files are platform dependent and all other .c files are universal.

Therefore, it would be great if there's a way to include/exclude a set of files from nativeSourceDirectory, so that a user can use Maven profile to include the files that are relevant to the current platform only (or to exclude the files that are irrelevant to the current platform.) For example:

<plugin>
  <artifactId>maven-hawtjni-plugin</artifactId>
  ...
  <configuration>
    <nativeSourceDirectory>...</nativeSourceDirectory>
    <nativeSourceDirectoryIncludes>${nativeIncludes}</nativeSourceDirectoryIncludes>
    <nativeSourceDirectoryExcludes>${nativeExcludes}</nativeSourcedirectoryExcludes>
    ...
  </configuration>
</plugin>
...
<profile>
  <id>win32</id>
  <activation>...</activation>
  <properties>
    <nativeSourceDirectoryIncludes>**</nativeSourceDirectoryIncludes>
    <nativeSourceDirectoryExcludes>unix/**</nativesourceDirectoryExcludes>
  </properties>
</profile>
@trustin
Copy link
Author

trustin commented May 22, 2014

A workaround would be to use a plugin like maven-antrun-plugin or copy-maven-plugin to selectively copy the native source files to another directory and specify that directory to nativeSourceDirectory, but it will be much cleaner and more efficient to have this feature in maven-hawtjni-plugin.

@chirino
Copy link
Member

chirino commented May 22, 2014

Another way you could do this is by having one of the native source files do a conditional include of the platform specific sources. Kinda like:

#ifdef WIN32
#include ../win32/some.c
#endif

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