私の目標は、jlink を使用して、カスタム JRE にバンドルされたモジュラー ランタイム イメージにアプリケーションをパッケージ化することです。私のアプリは単純な「hello world」Java Standard Edition アプリで、Guava に依存しています。JDK11を使用しています。
基本的にはこのチュートリアルを Baeldungで再現しようとしていますが、依存関係を管理する NetBeans と Maven を使用し、モジュール システムでビルドするにはMaven Compiler Pluginバージョン 3.8.1 を使用します。
ディレクトリ構造:
module-info.java ファイル:
module TestwithJLink {
requires guava;
exports net.clementlevallois.testwithjlink;
}
コントローラー.java:
package net.clementlevallois.testwithjlink;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;
public class Controller {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Multiset<String> test = HashMultiset.create();
test.add("hello");
test.add("world");
System.out.println("test: "+ test.toString());
}
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>net.clementlevallois</groupId>
<artifactId>TestwithJLink</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<id>compile</id>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project>
ただし、コンパイルされたクラスが作成され、jar やモジュールは作成されません。したがって、これ以上先に進むことはできません (jar のモジュールを jdeps で分析し、次に jlink を使用します)。明らかな何かが欠けているに違いありませんが、何ですか?