mavensigar

how to configur sigar with libsigar-x86-linux.so automatically in maven project


I'm using sigar API in maven project, I have add the sigar maven dependencies and log4j dependencies into the pom file, but when I build the project it gives the following error

DEBUG Sigar  - no libsigar-x86-linux.so in java.library.path
org.hyperic.sigar.SigarException: no libsigar-x86-linux.so in java.library.path

Error was fixed when I manually added the libsigar-x86-linux.so file into the maven local repo, How can it be automatically configured using pom file?


Solution

  • there is a problem with maven dependency plugin. You've to add .so type as included type like here:

     <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>         
            <execution>
                <id>native-dep</id>
                <phase>compile</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <stripVersion>true</stripVersion>
                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                    <includeGroupIds>org.hyperic</includeGroupIds>
    HERE ->         <includeTypes>dll,so</includeTypes>
                </configuration>
             </execution>
             ...
         </executions>
     </plugin>