Skip to content

Commit

Permalink
FFM support
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 9, 2023
1 parent 3a51fd9 commit d0e1ce1
Show file tree
Hide file tree
Showing 25 changed files with 3,249 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
java: [ '11', '21' ]
java: [ '21' ]
steps:
- uses: actions/checkout@v2

Expand Down
22 changes: 0 additions & 22 deletions builtins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,12 @@
<execution>
<id>default-compile</id>
<configuration>
<includes>
<include>**/ConsoleEngineImpl.java</include>
<include>**/TTop.java</include>
</includes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>compact</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<excludes>
<exclude>**/ConsoleEngineImpl.java</exclude>
<exclude>**/TTop.java</exclude>
</excludes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
<arg>-profile</arg>
<arg>compact1</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
22 changes: 0 additions & 22 deletions console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,12 @@
<execution>
<id>default-compile</id>
<configuration>
<includes>
<include>**/ConsoleEngineImpl.java</include>
<include>**/TTop.java</include>
</includes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>compact</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<excludes>
<exclude>**/ConsoleEngineImpl.java</exclude>
<exclude>**/TTop.java</exclude>
</excludes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
<arg>-profile</arg>
<arg>compact1</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
6 changes: 6 additions & 0 deletions demo/jline-gogo.bat
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set "logconf=%DIRNAME%etc\logging.properties"
if "%1" == "debug" goto :EXECUTE_DEBUG
if "%1" == "debugs" goto :EXECUTE_DEBUGS
if "%1" == "verbose" goto :EXECUTE_VERBOSE
if "%1" == "ffm" goto :EXECUTE_FFM
if "%1" == "" goto :EXECUTE_MAIN
set "opts=%opts% %~1"
shift
Expand Down Expand Up @@ -76,6 +77,11 @@ set "logconf=%DIRNAME%etc\logging.properties"
shift
goto :RUN_LOOP

:EXECUTE_FFM
set "opts=%opts% --enable-preview --enable-native-access=ALL-UNNAMED"
shift
goto :RUN_LOOP

:EXECUTE_MAIN
popd

Expand Down
5 changes: 5 additions & 0 deletions demo/jline-gogo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ while [ "${1}" != "" ]; do
logconf="${DIRNAME}/etc/logging-verbose.properties"
shift
;;
'ffm')
opts="${opts} --enable-preview --enable-native-access=ALL-UNNAMED"
shift
;;
*)
opts="${opts} ${1}"
shift
Expand Down Expand Up @@ -98,6 +102,7 @@ echo "Launching Gogo JLine..."
echo "Classpath: $cp"
set mouse=a
java -cp $cp \
--enable-preview \
$opts \
-Dgosh.home="${DIRNAME}" \
-Djava.util.logging.config.file="${logconf}" \
Expand Down
4 changes: 4 additions & 0 deletions demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
</properties>

<dependencies>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-ffm</artifactId>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jansi</artifactId>
Expand Down
21 changes: 10 additions & 11 deletions jline/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<properties>
<automatic.module.name>org.jline</automatic.module.name>
<javadocOptions>--enable-preview --release 21</javadocOptions>
</properties>

<dependencies>
Expand Down Expand Up @@ -316,31 +317,29 @@
<execution>
<id>default-compile</id>
<configuration>
<includes>
<include>**/TTop.java</include>
<include>**/ConsoleEngineImpl.java</include>
</includes>
<excludes>
<exclude>**/ffm/*.java</exclude>
</excludes>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>compact</id>
<id>jdk21</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<excludes>
<exclude>**/TTop.java</exclude>
<exclude>**/ConsoleEngineImpl.java</exclude>
</excludes>
<includes>
<include>**/ffm/*.java</include>
</includes>
<release>21</release>
<compilerArgs>
<arg>-Xlint:all,-options</arg>
<arg>-Werror</arg>
<arg>-profile</arg>
<arg>compact1</arg>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</execution>
Expand Down
3 changes: 2 additions & 1 deletion native/src/main/java/org/jline/nativ/OSInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class OSInfo {
public static final String PPC64 = "ppc64";
public static final String ARM64 = "arm64";

private static final HashMap<String, String> archMapping = new HashMap<String, String>();
private static final HashMap<String, String> archMapping = new HashMap<>();

static {
// x86 mappings
Expand Down Expand Up @@ -116,6 +116,7 @@ public static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").toLowerCase().contains("android");
}

@SuppressWarnings("unused")
public static boolean isAlpine() {
try {
Process p = Runtime.getRuntime().exec(new String[] {"cat", "/etc/os-release", "|", "grep", "^ID"});
Expand Down
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<modules>
<module>native</module>
<module>terminal</module>
<module>terminal-ffm</module>
<module>terminal-jna</module>
<module>terminal-jansi</module>
<module>reader</module>
Expand Down Expand Up @@ -92,7 +93,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputTimestamp>2023-03-08T19:46:51Z</project.build.outputTimestamp>

<java.build.version>11</java.build.version>
<java.build.version>21</java.build.version>
<java.target.version>1.8</java.target.version>
<maven.version>3.5.0</maven.version>

Expand Down Expand Up @@ -131,6 +132,12 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-ffm</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jansi</artifactId>
Expand Down Expand Up @@ -407,8 +414,6 @@
<compilerArgs>
<arg>-Xlint:all,-options,-processing</arg>
<arg>-Werror</arg>
<arg>-profile</arg>
<arg>compact1</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
Expand Down
1 change: 1 addition & 0 deletions reader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<properties>
<automatic.module.name>org.jline.reader</automatic.module.name>
<surefire.argLine>--add-opens java.base/java.io=ALL-UNNAMED --enable-preview</surefire.argLine>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -181,7 +183,9 @@ public void testPreferAppNameFromConstructor() throws IOException {

@Test
public void terminalLineInfiniteLoop() throws IOException {
ByteArrayInputStream in = new ByteArrayInputStream("hello\nworld\n".getBytes(StandardCharsets.UTF_8));
PipedInputStream in = new PipedInputStream();
PipedOutputStream outIn = new PipedOutputStream(in);
outIn.write("hello\nworld\n".getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);

Terminal terminal = TerminalBuilder.builder().streams(in, out).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.jline.terminal.Cursor;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

Expand All @@ -39,6 +41,16 @@

public class ExternalTerminalTest {

@BeforeEach
public void setup() {
System.setProperty(TerminalBuilder.PROP_PROVIDERS, "exec");
}

@AfterEach
public void tearDown() {
System.clearProperty(TerminalBuilder.PROP_PROVIDERS);
}

@Test
public void testInput() throws IOException, InterruptedException {
PipedInputStream in = new PipedInputStream();
Expand Down
75 changes: 75 additions & 0 deletions terminal-ffm/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2002-2020, the original author or authors.
This software is distributable under the BSD license. See the terms of the
BSD license in the documentation provided with this software.
https://opensource.org/licenses/BSD-3-Clause
-->
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jline</groupId>
<artifactId>jline-parent</artifactId>
<version>3.23.1-SNAPSHOT</version>
</parent>

<artifactId>jline-terminal-ffm</artifactId>
<name>JLine FFM Terminal</name>

<properties>
<java.target.version>21</java.target.version>
<automatic.module.name>org.jline.terminal.ffm</automatic.module.name>
</properties>

<dependencies>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>*;-noimport:=true</Export-Package>
<Fragment-Host>org.jline.terminal</Fragment-Host>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>21</release>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--enable-preview --enable-native-access=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit d0e1ce1

Please sign in to comment.