archive.jpms

Archive extension for JPMS modules

Programmatically, read and write, the source or binary of JPMS modules.

Auto-require functionality will attempt to write all the necessary requires clauses in module-info, this includes the standard JDK modules but also those available on the classpath (including automatic modules).

For more elaborate examples see archive.glue.


Dependency Graph

Module Dependency

Examples

The following creates an in-memory JPMS module with export predicate:

	Predicate<String> predicate = e -> !e.contains("internal");

	Archive archive = archive()
			.configured(asJpmsModule()
					.named("foo")
					.exporting(predicate))
			.with(DummyIntComparator.class)
			.with(DummyInternal.class)
			.toObjectModel();

(source).

The following finds the JAR for a given class and “wraps it”, (scans classes to determine requires) producing a JPMS compliant module:

	Path jar = Paths.get(Resources.sourceOfResource(Exceptional.class));

	// removes any existing module-info.class
	Predicate<String> filter = n -> !"module-info.class".equals(n);

	Archive jpmsed = archive()
			.configured(
					asJpmsModule()
							.autoRequiring()
							.exporting(p -> true)
							.named(Exceptional.class.getPackage().getName()))
			.sourcing(contentFrom(jar, filter))
			.toObjectModel();

	ArchiveResource moduleInfoBinary = jpmsed.content("module-info.class").orElseThrow(NullPointerException::new);

	ModuleInfo moduleInfoSource = ModuleInfo.read(moduleInfoBinary.bytes());

(source)

Back to top

Version: 0.1.0. Last Published: 2018-10-08.

Earcam Maven Skin.