AUTOSAR / ARXML I/O
The kuml-io-arxml module reads and writes AUTOSAR Classic ARXML (R19-11 through
R23-11). It bridges the gap between the kUML component and class diagram DSL and the
AUTOSAR toolchain used in automotive embedded-software projects.
|
ARXML I/O is a JVM-only module loaded via reflection. It is included in the Fat-JAR
( |
CLI export
kuml export brake-assist.kuml.kts --format arxml
# writes brake-assist.arxml
kuml export brake-assist.kuml.kts --format arxml -o out/brake-assist.arxml
The script must either:
-
define a
componentDiagram { … }— elements are wrapped in a syntheticAR-PACKAGE. -
evaluate to a
UmlPackageroot — the package tree is preserved as aAR-PACKAGEShierarchy.
Unsupported diagram types (C4, SysML 2, BPMN, Blueprint) are rejected with a clear
SCRIPT_ERROR message.
CLI import (reverse)
kuml reverse --format arxml ./arxml-dir/ -o model.kuml.kts
Reads every *.arxml file in arxml-dir/ (sorted alphabetically), imports each via
ArxmlClassicImporter, and merges them into a single KumlModel — packages with the
same AR-PACKAGE name across files are merged recursively to avoid duplicate
declarations.
Exit codes:
-
0— success, output script written. -
REVERSE_NO_SOURCES— the directory contains no.arxmlfiles.
Supported ARXML elements
| ARXML element | kUML mapping |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AUTOSAR Adaptive Platform elements (SERVICE-MANIFEST, MACHINE-MANIFEST) are parsed
and round-tripped, but map to UmlPackage/UmlClass with «BehaviorSpec» stereotypes
rather than distinct metamodel classes.
Roundtrip guarantee
The exporter writes R22-11 schema-labelled ARXML. A full roundtrip (import → export → import) preserves:
-
All SWC types, port names and directions.
-
Interface names, service flags, and admin-data version strings.
-
Runnable entity names, trigger types, and period values.
-
Assembly connector mappings (provider/requirer port TREFs).
What is NOT preserved:
-
Calibration parameters (
PARAMETER-DATA-PROTOTYPE) — omitted as out of scope. -
BSW-MODULE-DESCRIPTION— not supported. -
Schema declarations other than R22-11 are parsed but always exported as R22-11.
Library API
import dev.kuml.io.arxml.ArxmlClassicImporter
import dev.kuml.io.arxml.ArxmlClassicExporter
// Import
val importer = ArxmlClassicImporter()
val model: KumlModel = importer.import(File("composition.arxml"))
// Export
val exporter = ArxmlClassicExporter()
exporter.export(model, File("out/composition.arxml"))
For multi-file import, use ArxmlModelMerge:
import dev.kuml.cli.reverse.ArxmlModelMerge
val models: List<KumlModel> = arxmlFiles.map { ArxmlClassicImporter().import(it) }
val merged: KumlModel = ArxmlModelMerge.merge(models)
AUTOSAR profile
kUML ships a built-in AUTOSAR profile in kuml-profile-autosar. Apply it in any
component diagram to use AUTOSAR stereotypes:
componentDiagram(name = "Brake Assist SWC") {
applyProfile("AUTOSAR")
component("BrakeAssist") {
stereotype("SoftwareComponent", "kind" to "Application",
"packageName" to "powertrain")
port("wheelSpeedIn") { stereotype("AutosarPort", "direction" to "Required") }
port("brakeCmdOut") { stereotype("AutosarPort", "direction" to "Provided") }
operation("evaluate") { stereotype("Runnable", "kind" to "Periodic", "periodMs" to 10L) }
}
interface("WheelSpeed") {
stereotype("ComInterface", "version" to "1.0", "isService" to false)
}
}
See Profiles for the full AUTOSAR stereotype reference.
See also
-
Profiles — AUTOSAR, JavaEE, Spring, OpenAPI, SoaML
-
EMF / XMI I/O — Eclipse UML2 XMI import and export