pi4j-native
Used in:
components
- OverviewOverview
- VersionsVersions
- DependentsDependents
- DependenciesDependencies
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-native</artifactId>
<version>1.4</version>
</dependency><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- MAVEN ARTIFACT INFORMATION -->
<artifactId>pi4j-native</artifactId>
<name>Pi4J :: JNI Native Library</name>
<description>Pi4J JNI Native Library</description>
<packaging>pom</packaging>
<parent>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-parent</artifactId>
<version>1.4</version>
</parent>
<!-- BUILD PROFILES -->
<profiles>
<!-- This profile is used to dynamically rebuild the native library .H
header files from the defined JNI jar classes. This profile should only be
used when changes have been made to the JNI Java wrapper classes and new
native method signatures are required. To use this profile, simply include
the "-generate-jni-headers" command argument with the maven build command. -->
<profile>
<id>generate-jni-headers</id>
<!-- SPECIAL PROFILE DEPENDENCIES -->
<dependencies>
<!-- we define the pi4j Java project as a dependency so that the .H header
files can be generated based on the Java native wrapper classes -->
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<!-- SPECIAL PROFILE BUILD INSTRUCTIONS -->
<build>
<plugins>
<!-- Generate .h header files for JNI wrapper -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<id>javah-generate</id>
<phase>generate-sources</phase>
<goals>
<goal>javah</goal>
</goals>
<configuration>
<!-- trigger javah execution -->
<javahClassNames>
<javahClassName>com.pi4j.jni.AnalogInputMonitor</javahClassName>
<javahClassName>com.pi4j.jni.WDT</javahClassName>
<javahClassName>com.pi4j.jni.I2C</javahClassName>
<javahClassName>com.pi4j.jni.Serial</javahClassName>
<javahClassName>com.pi4j.jni.SerialInterrupt</javahClassName>
<javahClassName>com.pi4j.wiringpi.Gpio</javahClassName>
<javahClassName>com.pi4j.wiringpi.GpioInterrupt</javahClassName>
<javahClassName>com.pi4j.wiringpi.GpioUtil</javahClassName>
<javahClassName>com.pi4j.wiringpi.Serial</javahClassName>
<javahClassName>com.pi4j.wiringpi.Lcd</javahClassName>
<javahClassName>com.pi4j.wiringpi.Shift</javahClassName>
<javahClassName>com.pi4j.wiringpi.SoftPwm</javahClassName>
<javahClassName>com.pi4j.wiringpi.Spi</javahClassName>
<javahClassName>com.pi4j.wiringpi.Gertboard</javahClassName>
<javahClassName>com.pi4j.wiringpi.Nes</javahClassName>
</javahClassNames>
<!-- enable additional javah interface in dependencies list -->
<javahSearchJNIFromDependencies>true</javahSearchJNIFromDependencies>
<!-- specify the output directory for generated header files -->
<javahOutputDirectory>src/main/native</javahOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<!-- BUILD INSTRUCTIONS -->
<build>
<finalName>libpi4j</finalName>
<plugins>
<!-- GENERATE LICENSE HEADERS IN SOURCE FILES -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
<!-- EXTRACT/PARSE MAJOR & MINOR (semver) VERSION ELEMENTS FROM PROJECT VERSION -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>initialize</phase>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- PERFORM ADDITIONAL BUILD TASKS USING ANT -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<!-- ensure that a target directory has been created platform -->
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<target>
<mkdir dir="target" />
<mkdir dir="target/classes" />
<mkdir dir="target/native" />
<mkdir dir="target/native/lib" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<!-- copy the native source files and compile them on each of the targeted platforms -->
<execution>
<id>pi4j-build-native-libraries</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="pi4j-build-platform-libraries" >
<property name="pi4j.builder.version" value="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<if>
<!-- check for DOCKER-COMPILER setting in the 'pi4j.native.compiler' property -->
<equals arg1="${pi4j.native.compiler.effective}" arg2="DOCKER-COMPILER" />
<then>
<!-- perform native build using Pi4J Docker Builder Image for native cross-compiling -->
<ant target="build-with-docker" inheritRefs="true"/>
</then>
<else>
<if>
<!-- check for CROSS-COMPILER setting in the 'pi4j.native.compiler' property -->
<equals arg1="${pi4j.native.compiler.effective}" arg2="CROSS-COMPILER" />
<then>
<!-- perform native build using cross-compiler toolchains directly on host -->
<ant target="build-with-cross-compile" inheritRefs="true"/>
</then>
<else>
<fail message="NATIVE BUILD FAILED/ABORTED; Missing or invalid 'pi4j.native.compiler' property. [${pi4j.native.compiler}]; Expected 'CROSS-COMPILER|DOCKER-COMPILER'"/>
</else>
</if>
</else>
</if>
</target>
</configuration>
</execution>
<!-- attach the compiled native libraries for each of the targeted platforms as artifacts -->
<execution>
<id>pi4j-attach-native-library-artifacts</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="pi4j-attach-platform-libraries" >
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath"/>
<!-- Attach 'libpi4j.so' for RasbperryPi -->
<!-- NOTE: As of 2018-04-23 Pi4J no longer includes
a statically linked wiringPi lib for the Raspberry Pi platform. -->
<attachartifact file="${project.build.directory}/native/lib/raspberrypi/dynamic/libpi4j-armhf.so" classifier="raspberrypi-dynamic-armhf" type="so"/>
<attachartifact file="${project.build.directory}/native/lib/raspberrypi/dynamic/libpi4j-aarch64.so" classifier="raspberrypi-dynamic-aarch64" type="so"/>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>${ant-jsch.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>${jsch.version}</version>
</dependency>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>${ant-contrib.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>