Class LionWebPluginExtension

java.lang.Object
io.lionweb.gradleplugin.LionWebPluginExtension

public abstract class LionWebPluginExtension extends Object
Gradle extension for configuring the LionWeb Gradle plugin.

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:

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 Details

    • LionWebPluginExtension

      public LionWebPluginExtension()
  • Method Details

    • getDefaultPackageName

      @NotNull public abstract @NotNull org.gradle.api.provider.Property<String> 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 in getLanguagesSpecificPackages().

    • getLanguagesDirectory

      @NotNull public abstract @NotNull 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

      @NotNull public abstract @NotNull org.gradle.api.file.DirectoryProperty getGenerationDirectory()
      Destination directory for generated Java sources.

      Both generateLWLanguages and generateLWNodeClasses write output to this directory.

    • getPrimitiveTypes

      @NotNull public abstract @NotNull org.gradle.api.provider.MapProperty<String,String> 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 as java.time.Instant. This mapping is used by generateLWNodeClasses when generating fields for primitive-typed properties.

    • getLanguagesSpecificPackages

      @NotNull public abstract @NotNull org.gradle.api.provider.MapProperty<String,String> 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

      @NotNull public abstract @NotNull org.gradle.api.provider.MapProperty<String,String> getLanguagesClassNames()
      Maps LionWeb language IDs to the class name of the generated Language Java class.

      If a language ID is not present, the default naming strategy is used.

    • getLanguagesToGenerate

      @NotNull public abstract @NotNull org.gradle.api.provider.SetProperty<String> 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

      @NotNull public abstract @NotNull org.gradle.api.provider.MapProperty<String,String> 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

      @NotNull public abstract @NotNull org.gradle.api.provider.Property<Boolean> 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.