-
Notifications
You must be signed in to change notification settings - Fork 1
Publishing Modules
Compile the module and package its binary, sources, and Javadoc as flat, module-named resources:
module=com.example.app
version=1.2.3
output=/path/to/output
artifacts="$output/artifacts"
mkdir -p "$output/args" "$output/modules" "$artifacts"
jig --module-source-path src \
-m "$module" \
--module-version "$version" \
-r module-path,module-source-path,module=list,module-version,release \
-w "$output/args/compile.args"
javac -d "$output/modules" @"$output/args/compile.args"
jig --module-source-path src \
-m "$module" \
-r module-path,module-source-path,module=list,release \
-w "$output/args/javadoc.args"
javadoc @"$output/args/javadoc.args" \
-tag 'mainClass:a:Main class:' \
-d "$output/javadoc"
jig --module-source-path src \
-m "$module" \
-r main-class \
-w "$output/args/jar.args"
jar --create --file "$artifacts/$module.jar" \
@"$output/args/jar.args" \
-C "$output/modules/$module" .
jar --create --file "$artifacts/$module-sources.jar" \
-C "src/$module" .
jar --create --file "$artifacts/$module-javadoc.jar" \
-C "$output/javadoc" .The artifact directory is deliberately not a Maven repository layout:
<output>/artifacts/
|-- com.example.app.jar
|-- com.example.app-sources.jar
|-- com.example.app-javadoc.jar
`-- com.example.app.pom
The version in module-info.class is authoritative. Module descriptors provide the names, versions, and dependencies used to generate consumer POMs and create the Maven repository layout:
jig maven install "$artifacts"
jig maven deploy --repository /path/to/repository "$artifacts"
jig maven deploy --repository releases=https://repository.example/releases "$artifacts"
jig maven deploy-central "$artifacts"A matching <module-name>.pom can supply the project name, description, URL, licenses, developers, and SCM metadata required when publishing that module to Maven Central.
jig maven install and jig maven deploy consume a directory of flat, module-named artifacts. The main JAR must contain module-info.class with a module version. Optional resources use -sources.jar, -javadoc.jar, and .jmod suffixes. Publication metadata uses a .pom file with the same basename as the main JAR.
A consumer POM is generated from each module descriptor. Non-system requires directives become Maven dependencies. A plain requires static becomes an optional compile dependency. Because Maven cannot express a dependency that is transitive at compile time but optional at runtime, requires static transitive remains non-optional so downstream compilation continues to work. jig still uses the module descriptor to omit either static form from runtime resolution. Dependencies outside the artifact directory are mapped back to their original Maven coordinates through the same module-location contract used for resolution.
For each module, <artifact-directory>/<module-name>.pom contributes additional metadata. It supports these top-level elements:
-
modelVersion, which must be4.0.0 namedescriptionurllicensesdevelopersscm
Coordinates, versions, packaging, and dependencies come from the module descriptor and artifact assembly. Deploy requires --repository <id=uri|path>; a repository path is published through its normalized file: URI.
Add --sign to deploy detached OpenPGP signatures with every artifact. Signing reads MAVEN_GPG_KEY, with optional MAVEN_GPG_KEY_FINGERPRINT and MAVEN_GPG_PASSPHRASE, from the environment.
jig maven deploy-central requires binary, sources, and Javadoc JARs. Snapshots are rejected. Component and POM coordinates, project name, description and URL, licenses, developers, and SCM metadata are validated before upload.
Signing is mandatory and reads MAVEN_GPG_KEY, with optional MAVEN_GPG_KEY_FINGERPRINT and MAVEN_GPG_PASSPHRASE, from the environment. Callers do not provide .asc files. Every artifact is signed before the signature set is verified, checksums are generated, and the Maven repository bundle is created.
Generate a user token in the Central Portal and add its username and password to the central server in ~/.m2/settings.xml. These are not account login credentials.
<settings>
<servers>
<server>
<id>central</id>
<username>token username</username>
<password>token password</password>
</server>
</servers>
</settings>In CI, set both MAVEN_CENTRAL_USERNAME and MAVEN_CENTRAL_PASSWORD instead. The bundle is submitted for automatic publication and the command waits for completion. Add --manual to stop after validation and leave publication for approval in the Central Portal. Portal validation remains authoritative for namespace ownership, established signing keys, and duplicate releases. Validation failures are reported with the deployment details returned by Central. The deployment UUID is written to standard output after publication or validation. --name supplies an optional deployment name.
Maven Resolver owns local-repository locking and metadata for install, repository authentication and mirrors from Maven settings, and the repository layout for deploy.
The module proxy also generates consumer POMs without modifying backing JARs. Each POM records the backing Maven package URL in an origin property.