A minimal, ready-to-build template for creating a BEAST 3 external package
using the strongly-typed spec class hierarchy.
This skeleton demonstrates:
- A custom scalar distribution (
MyDistribution) extendingScalarDistribution— usable directly as a prior (noPriorwrapper) - A custom MCMC operator (
MyScaleOperator) working withRealScalarParam - JPMS
module-info.javawithprovidesdeclarations version.xmlfor package service discovery- JUnit 5 testing with the new strongly-typed API
- A BEAST XML file using both custom classes with
RealScalarParamand domain constraints
- Java 25+
- Maven 3.9+
- GitHub Packages authentication for BEAST 3 artifacts (not needed if BEAST 3 is available on Maven Central) — add this to your
~/.m2/settings.xml:
<settings>
<servers>
<server>
<id>github</id>
<username>YOUR_GITHUB_USERNAME</username>
<password>YOUR_GITHUB_PAT</password>
</server>
</servers>
</settings>Replace YOUR_GITHUB_USERNAME with your GitHub username and YOUR_GITHUB_PAT with a personal access token that has the read:packages scope. BEAST 3 dependencies are resolved automatically from GitHub Packages.
Alternatively, you can install BEAST 3 to your local Maven repository from source:
cd /path/to/beast3
mvn install:install-file -Dfile=lib/beagle.jar -DgroupId=io.github.compevol -DartifactId=beagle -Dversion=1.0 -Dpackaging=jar
mvn install:install-file -Dfile=lib/colt.jar -DgroupId=io.github.compevol -DartifactId=colt -Dversion=1.0 -Dpackaging=jar
mvn install -DskipTestsmvn compile # compile against beast-base
mvn test # run MyDistributionTest-
Rename the Maven coordinates in
pom.xml:- Change
groupId(should be a verified Maven Central namespace, e.g.io.github.yourname),artifactId, andversion - Update
<url>,<developers>, and<scm>to point to your repository
- Change
-
Rename the Java module in
src/main/java/module-info.java:- Change
module my.beast.pkgto your module name - Update
exportsandprovidesdeclarations
- Change
-
Rename the Java package under
src/main/java/:- Move source files to your package directory
- Update
packagestatements in all.javafiles
-
Update
version.xml:- Change the package
nameandversion - List your
BEASTInterfaceproviders
- Change the package
-
Replace the example classes with your own:
- See
MyDistribution.javafor theScalarDistributionpattern - See
MyScaleOperator.javafor theOperator+RealScalarParampattern
- See
| Old (deprecated) | New (spec) |
|---|---|
RealParameter |
RealScalarParam<D> / RealVectorParam<D> |
ParametricDistribution |
ScalarDistribution<S, T> |
Prior wrapper + ParametricDistribution |
Distribution with param input (acts as its own prior) |
lower/upper bounds |
Domain types: Real, PositiveReal, NonNegativeReal, UnitInterval |
If your package includes BEAUti input editors or other GUI components,
add this dependency to pom.xml:
<dependency>
<groupId>io.github.compevol</groupId>
<artifactId>beast-fx</artifactId>
<version>${beast.version}</version>
</dependency>And add requires beast.fx; to your module-info.java.
The included release.sh script automates the full release process: build, package, and
optionally create a GitHub release.
./release.shThis will:
- Read the package name and version from
version.xml - Run
mvn clean package -DskipTests - Assemble a BEAST package ZIP with the correct flat structure
- Output a file like
MyPackage.v1.0.0.zip
./release.sh --releaseThis additionally creates a GitHub release (e.g. v1.0.0) with the ZIP attached,
and prints the CBAN XML entry you'll need for the next step.
The CBAN repository is where BEAST's Package Manager discovers available packages. To make your package installable:
- Fork CompEvol/CBAN
- Add your package entry to
packages2.8.xml(the--releaseflag prints this for you):
<package name="MyPackage" version="1.0.0"
url="https://github.com/YOU/YOUR-REPO/releases/download/v1.0.0/MyPackage.v1.0.0.zip"
projectURL="https://github.com/YOU/YOUR-REPO"
description="One-line description of your package">
<depends on="BEAST.base" atleast="2.8.0"/>
</package>- Open a pull request against CompEvol/CBAN
Once merged, your package will appear in the BEAST Package Manager.
BEAST 3 can also install packages directly from Maven Central. This is an alternative (or complement) to the ZIP/CBAN distribution above.
- Sonatype account — register at central.sonatype.com
- Verified namespace — verify your
groupIdnamespace (e.g.io.github.yourname) - GPG key — generate a signing key and publish it to a key server
- Maven settings — add credentials to
~/.m2/settings.xml:
<settings>
<servers>
<server>
<id>central</id>
<username>YOUR_SONATYPE_TOKEN_USER</username>
<password>YOUR_SONATYPE_TOKEN_PASS</password>
</server>
</servers>
</settings>- Set your
groupIdto your verified namespace (e.g.io.github.yourname) - Fill in the
<url>,<licenses>,<developers>, and<scm>sections inpom.xml - Remove the
-SNAPSHOTsuffix from<version>for release builds
mvn clean deploy -PreleaseThis builds the JAR (with version.xml embedded), generates sources and javadoc
JARs, signs everything with GPG, and uploads to Maven Central.
Once published, BEAST 3 users can install your package with:
Package Manager > Install from Maven > groupId:artifactId:version
Or from the command line:
packagemanager -maven groupId:artifactId:versionThe BEAST Package Manager expects a flat ZIP (no wrapper directory) containing:
version.xml # required — package name, version, service providers
lib/ # required — your JARs (and any third-party runtime deps)
fxtemplates/ # optional — BEAUti templates
examples/ # optional — example BEAST XML files and data
Important: the ZIP must NOT contain a top-level directory named after your package. The Package Manager extracts the ZIP into its own directory, so a wrapper would cause double-nesting and break service discovery.
- BEAST 3 source
- BEAST 2 → 3 migration guide
- morph-models — worked example of a migrated multi-module BEAST 3 package