0

My users have been calling out for easily distributed native binaries with my library. I've got this working by distributing the natives in jars, which are extracted at runtime into a temporary directory.

However, the maven-native-plugin requires that the native is packaged as a jnilib (OS X), so (Linux) or dll (Windows). I have my own deploy target that packages a jar file and distributes that under the classifier natives. It's a bit annoying that this needs a special classifier.

  1. How can I disable the deploy of the jnilib/so/dll?
  2. How can I distribute my jar without any special classifier?
fommil
  • 5,757
  • 8
  • 41
  • 81

1 Answers1

1

I do a similar thing, but I pack the native libraries inside zip files. After that, in the artifact that needs them, I pull and unpack the zip file with the maven dependency plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>    
    <executions>
        <execution>
            <id>unzip</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>foo</groupId>
                        <artifactId>bar</artifactId>
                        <version>1.0.0</version>
                        <type>zip</type>
                        <overWrite>true</overWrite>
                        <includes>**/*.dll</includes>
                        <outputDirectory>${project.build.directory}/natives</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>    
</plugin>

As you can see I don't use any classifiers.

Kornel
  • 97,764
  • 37
  • 219
  • 309
amaurs
  • 1,622
  • 1
  • 13
  • 18
  • so downstream would then depend on the `zip`. Interesting. However, how do you disable the deploy of the maven native `jnilib`? – fommil Aug 08 '13 at 22:19
  • I do not use the maven native plugin at all, I create my own build process as I explain [here](http://stackoverflow.com/questions/17652649/native-maven-plugin-error-with-msvc-compiler-the-command-line-is-too-long/17686109#17686109), on the other side, I only create a dll for windows, and I haven't faced yet the problem of creating a multi-platform native library. – amaurs Aug 08 '13 at 22:31
  • Yeah, you'd have problems as its effectively reinventing the wheel. Zip wouldn't work for me as my users want a dynamic file system independent load, which requires the natives to be on the class path (I.e. in a jar). – fommil Aug 09 '13 at 07:34