Class ProjectModel

java.lang.Object
org.praxislive.project.ProjectModel

public final class ProjectModel extends Object
Model for project scripts. Project scripts are a series of commands or file includes, split into three sections - setup, build and run.

The setup section normally consists of commands to configure the hub, libraries, compiler, etc.

The build section normally consists of includes for the various root graph files.

The run section normally includes lines to start the various roots. Unlike the other two sections, elements in the run section should usually support repeated execution.

  • Method Details

    • setupElements

      public List<ProjectElement> setupElements()
      Immutable list of the elements in the setup section.
      Returns:
      setup elements
    • buildElements

      public List<ProjectElement> buildElements()
      Immutable list of the elements in the build section.
      Returns:
      build elements
    • runElements

      public List<ProjectElement> runElements()
      Immutable list of the elements in the run section.
      Returns:
      run elements
    • context

      public Optional<URI> context()
      Access the optional context (eg. working dir) for resolving relative file values.
      Returns:
      optional context
    • withContext

      public ProjectModel withContext(URI context)
      Create a new project model with a different context. The context is used to relativize resources when writing. Use null to create a model without context.
      Parameters:
      context - new resource context
      Returns:
      new graph model
    • write

      public void write(Appendable target) throws IOException
      Write the model as a script to the given target.
      Parameters:
      target - write destination
      Throws:
      IOException
    • writeToString

      public String writeToString()
      Write the project model to a String. This is shorthand for passing in a StringBuilder to write(java.lang.Appendable).

      The output of this method is suitable for parsing back into a model, as distinct from the output of toString().

      Returns:
      model as script
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static ProjectModel.Builder builder()
      Create a project model builder.
      Returns:
      builder
    • parse

      public static ProjectModel parse(String script) throws ParseException
      Parse the given project script into a project model.
      Parameters:
      script - project script
      Returns:
      model
      Throws:
      ParseException - if script is not a valid project
    • parse

      public static ProjectModel parse(URI context, String script) throws ParseException
      Parse the given project script and context into a project model. Relative includes will be parsed against the provided context.
      Parameters:
      context - project context
      script - project script
      Returns:
      model
      Throws:
      ParseException - if script is not a valid project