Class LionWebPluginExtension
Configure this extension in your build script using the lionweb block after applying
the io.lionweb plugin. The plugin wires these settings into the
generateLWLanguages and generateLWNodeClasses tasks.
Default conventions provided by the plugin:
getLanguagesDirectory()defaults tosrc/main/lionwebgetGenerationDirectory()defaults tobuild/generated-lionweb
Example (Kotlin DSL):
lionweb {
// Where to look for language definitions, defaults to src/main/lionweb
languagesDirectory = layout.projectDirectory.dir("my-dir-full-of-languages")
// Set the package names with a global default and specific settings
defaultPackageName = "com.example.languages"
languagesSpecificPackages = mapOf("com_example_mylanguage_id" to "com.example.mylanguage")
// Defaults to build/generated-lionweb
generationDirectory.set(layout.buildDirectory.dir("my-generation-dir"))
// If we want to force the Language Class to have a specific name, we can
languagesClassNames = mapOf("com.example.mylanguage" to "MyLanguage")
// If we want to generate code only for some of the languages (as the others are just dependencies,
// for example), we can use this setting
languagesToGenerate = setOf("MyLanguage")
// Classes for primitive types must be written manually and specified here
primitiveTypes = mapOf("com.example.types.Instant" to "java.time.Instant")
// Our language may refer to concepts for which a class has been already written. If so,
// this setting let the generator know about it.
mappings = mapOf("com.example.other.MyConcept" to "com.example.other.MyConceptImpl")
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.provider.Property<Boolean>Configures whether the compilation tasks should be enabled for the generated Java sources.abstract org.gradle.api.provider.Property<String>Base package for generated Java sources.abstract org.gradle.api.file.DirectoryPropertyDestination directory for generated Java sources.Maps LionWeb language IDs to the class name of the generatedLanguageJava class.abstract org.gradle.api.file.DirectoryPropertyDirectory containing LionWeb language definitions to load from the project.Maps LionWeb language IDs to the Java package in which code for that language should be generated.abstract org.gradle.api.provider.SetProperty<String>Restricts generation to a subset of languages.Maps LionWeb classifier qualified names to Java fully qualified class names.Maps LionWeb primitive type IDs to Java fully qualified class names.
-
Constructor Details
-
LionWebPluginExtension
public LionWebPluginExtension()
-
-
Method Details
-
getDefaultPackageName
Base package for generated Java sources.This is used when a language does not have a specific package configured in
getLanguagesSpecificPackages(). If you do not provide a default package, then every language that is generated must have an entry ingetLanguagesSpecificPackages(). -
getLanguagesDirectory
public abstract org.gradle.api.file.DirectoryProperty getLanguagesDirectory()Directory containing LionWeb language definitions to load from the project.Files under this directory are scanned recursively. The plugin currently supports JSON serialization files (extension
.json). Protobuf files (.pb) are discovered but not yet supported by the generator.When creating the project's JAR, the plugin also packages these language files under
META-INF/lionweb. -
getGenerationDirectory
public abstract org.gradle.api.file.DirectoryProperty getGenerationDirectory()Destination directory for generated Java sources.Both
generateLWLanguagesandgenerateLWNodeClasseswrite output to this directory. -
getPrimitiveTypes
Maps LionWeb primitive type IDs to Java fully qualified class names.Keys are LionWeb primitive type identifiers as found in the serialized language definitions (for example,
com.example.types.Instant). Values are Java type names such asjava.time.Instant. This mapping is used bygenerateLWNodeClasseswhen generating fields for primitive-typed properties. -
getLanguagesSpecificPackages
Maps LionWeb language IDs to the Java package in which code for that language should be generated.When a language ID is not present in this map,
getDefaultPackageName()is used instead. -
getLanguagesClassNames
Maps LionWeb language IDs to the class name of the generatedLanguageJava class.If a language ID is not present, the default naming strategy is used.
-
getLanguagesToGenerate
Restricts generation to a subset of languages.Entries can be language names, IDs, or keys. If unset, the generators produce code for all languages loaded from the project language files.
-
getMappings
Maps LionWeb classifier qualified names to Java fully qualified class names.This is used when generated code references classifiers that are not generated by this plugin (for example, concepts or interfaces from external languages). The key must match
classifier.qualifiedName()from the LionWeb language model. -
getConfigureCompilation
Configures whether the compilation tasks should be enabled for the generated Java sources.- Returns:
- a
Property<Boolean>indicating if compilation tasks are configured and enabled.
-