A Java library for breaking a given text into lines within a specified width.
This package can be installed from Maven Central Repository.
The examples of declaring that repository and the dependency on this package in Maven pom.xml
and Gradle build.gradle
are as follows:
<dependencies>
<dependency>
<groupId>io.github.sttk</groupId>
<artifactId>linebreak</artifactId>
<version>0.1.4</version>
</dependency>
</dependencies>
repositories {
mavenCentral()
}
dependencies {
implementation 'io.github.sttk:linebreak:0.1.4'
}
The following code breaks the argument text into lines within the terminal width, and outputs them to stdout.
import com.github.sttk.linebreak.LineIter;
...
var iter = new LineIter(text, Term.getCols());
iter.setIndent(" ".repeat(4));
while (iter.hasNext()) {
System.out.println(iter.next());
}
This library supports native build with GraalVM.
See the following pages to setup native build environment on Linux/macOS or Windows.
And see the following pages to build native image with Maven or Gradle.
This library uses ICU4J and JNA.
Since the ICU4J's jar file includes data files, it is required to write those data files in resource-config.json
which is one of native build configuration files.
And since JNA uses JNI, reflection and so on, it is also required to write configurations into native build configuration files: jni-config.json
, proxy-config.json
, reflect-config.json
and resource-config.json
.
These configuration files are included in the src/main/resources/META-INF/native-image/com.github.sttk.linebreak/
directory.
But only one configuration, JNA dynamic link library, is not included because it is platform-dependent.
Please include the configuration of JNA dynamic link library for your platform into reflect-config.json
.
That configuration's format is as follows:
{
"resources":{
"includes":[ ... , {
"pattern":"\\Qcom/sun/jna/<osname>-<processor>/libjnidispatch.<extension>\\E"
}]},
"bundles":[ ... ]
}
Here, the <osname>
, <processor>
, and <extension>
can be obtained from the attribute
element named "Bundle-NativeCode"
in JNA build file. Or, download this project and run ./build.sh trace-test
to generate reflect-config.json
and other configuration files.
This framework supports JDK 21 or later.
- GraalVM CE 21.0.2+13.1 (openjdk version 21.0.2)
- GraalVM CE 22.0.1+8.1 (openjdk version 22.0.1)
Copyright (C) 2023-2024 Takayuki Sato
This program is free software under MIT License.
See the file LICENSE in this distribution for more details.