ALFA Maven Plugin CLI (OSS)

The ALFA Maven plugin can be run as a single shell command, without the need for a pom.xml file.

This is useful for cases such as a one-off run of an ALFA importer or exporter, such as Markdown/HTML export.

The minimum command (without parameters) is shown below.

mvn com.schemarise.alfa.utils:alfa-maven-plugin:3.4.6:cli

Note The specific version (3.4.6) of the plugin is executed.

When run for the 1st time, dependencies are downloaded. Without parameters as shown above, an error like that shown below is reported.

Alfa compiler error.: -Dalfa.sourcepath=<path to source files> missing

Creating a shell script to run ALFA Maven CLI

It maybe convenient to create a shell script as shown below, allowing the Plugin CLI to be simply run as a command - alfa.

Windows:

Create a file alfa.cmd with contents -

mvn com.schemarise.alfa.utils:alfa-maven-plugin:3.4.6:cli %*

Linux/MacOS:

Create a file alfa.sh with execute permission, with contents -

mvn com.schemarise.alfa.utils:alfa-maven-plugin:3.4.6:cli $@

Supported Parameters

Name Description
-Dalfa.compile Compile the contents of sourcepath
-Dalfa.importers= One or many comma seperated importer names to run
-Dalfa.exporters= One or many comma seperated exporter names to run
-Dalfa.output= Directory where contents are written
-Dalfa.sourcepath= Input file or directory

Example usages:

Note there are no spaces on either side of the = symbol.

  1. Import a JSON Schema file into ALFA on Windows.

    alfa.cmd -Dalfa.importers=jsonschema -Dalfa.output=generated/alfa -Dalfa.sourcepath=demo-schema.json
    
  2. Export set of ALFA files into Markdown documentation.

    alfa.cmd -Dalfa.exporters=markdown -Dalfa.output=generated/md -Dalfa.sourcepath=src/alfa/
    
  3. Compile ALFA files in a directory

    alfa.cmd -Dalfa.compile -Dalfa.sourcepath=src/alfa/