Improve code for populating openrs2.jawtDirectory

The previous profile-based logic didn't work on Java 8 due to the
architecture-specific lib directories. It was also complicated by the
fact that nar.javaHome isn't set at profile activation time unless the
user manually specifies it with -D on the Maven command line.

This commit replaces it with an Ant task that runs during the
initialization phase. It finds the first (and probably only) jawt
library with glob matching, allowing us to search architecture-specific
lib directories.

If found, it strips the file name to get just the directory name and
sets openrs2.jawtProperty. If not found, it makes the build fail.
master
Graham 5 years ago
parent 7a7c3bd502
commit c77bc62557
  1. 50
      gl-natives/pom.xml

@ -19,12 +19,43 @@
as it may be backed by a CALayer or an NSView. as it may be backed by a CALayer or an NSView.
</description> </description>
<properties>
<openrs2.jawtDirectory>${nar.javaHome}/lib</openrs2.jawtDirectory>
</properties>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
<pathconvert property="openrs2.jawtDirectory">
<first>
<fileset dir="${nar.javaHome}">
<include name="lib/**/jawt.lib" />
<include name="lib/**/libjawt.dylib" />
<include name="lib/**/libjawt.so" />
<!-- legacy Java on macOS -->
<include name="../Libraries/libjawt.dylib" />
</fileset>
</first>
<regexpmapper from="(.*)/" to="\1" handledirsep="true" />
</pathconvert>
<fail message="Failed to find jawt directory">
<condition>
<equals arg1="${openrs2.jawtDirectory}" arg2="" />
</condition>
</fail>
<echo>Found jawt directory: ${openrs2.jawtDirectory}</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>com.github.maven-nar</groupId> <groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId> <artifactId>nar-maven-plugin</artifactId>
@ -78,17 +109,6 @@
</plugins> </plugins>
</build> </build>
</profile> </profile>
<profile>
<id>mac-legacy</id>
<activation>
<file>
<exists>${nar.javaHome}/../Libraries</exists>
</file>
</activation>
<properties>
<openrs2.jawtDirectory>${nar.javaHome}/../Libraries</openrs2.jawtDirectory>
</properties>
</profile>
<profile> <profile>
<id>unix</id> <id>unix</id>
<activation> <activation>

Loading…
Cancel
Save