Class WorkspaceBootstrap

java.lang.Object
network.ike.plugin.ws.bootstrap.WorkspaceBootstrap

public final class WorkspaceBootstrap extends Object
Generates the on-disk scaffold for a brand-new IKE workspace.

Subsumes the file-generation half of the retired WsCreateMojo (folded into ws:scaffold-init per IKE-Network/ike-issues#393): given a target directory and a small parameter bag, writes the standard workspace files (pom.xml, workspace.yaml, .gitignore, .mvn/maven.config, .mvn/jvm.config, README.adoc) and installs the Maven wrapper via MavenWrapper.writeMissingFiles(Path, String).

The generated files follow current IKE conventions:

  • POM uses Maven 4.1.0 model with root="true"
  • .gitignore uses whitelist strategy (ignore everything, whitelist workspace-owned files)
  • workspace.yaml has schema-version 1.1 with a typed workspace-root: block holding the workspace's GAV (ike-issues#183) and an empty subprojects: list
  • .mvn/maven.config sets -T 1C

This class is a pure scaffold writer — it does not consult workspace.yaml (none exists yet), does not iterate subprojects, and never extends AbstractWorkspaceMojo.

See Also:
  • Field Details

    • EXTENSIONS_MANAGED_BEGIN

      public static final String EXTENSIONS_MANAGED_BEGIN
      Sentinel marking the start of the managed extension block in .mvn/extensions.xml. The block between this marker and EXTENSIONS_MANAGED_END is regenerated by ws:scaffold-init and ws:scaffold-publish (IKE-Network/ike-issues#460) so the ike-workspace-extension version stays in lockstep with the ike-parent property.
      See Also:
    • EXTENSIONS_MANAGED_END

      public static final String EXTENSIONS_MANAGED_END
      Sentinel marking the end of the managed extension block.
      See Also:
    • MANAGED_BEGIN

      public static final String MANAGED_BEGIN
      Sentinel marking the start of the managed comment header in workspace.yaml. The block between this marker and MANAGED_END is regenerated by ws:scaffold-init on every run (IKE-Network/ike-issues#458) so the bootstrap instructions stay in lockstep with current goal names.
      See Also:
    • MANAGED_END

      public static final String MANAGED_END
      Sentinel marking the end of the managed comment header.
      See Also:
  • Constructor Details

    • WorkspaceBootstrap

      public WorkspaceBootstrap(WorkspaceBootstrap.Params params, org.apache.maven.api.plugin.Log log)
      Create a workspace bootstrapper bound to a parameter bag and a logger. Construction is cheap; the actual filesystem writes happen in createAt(Path).
      Parameters:
      params - the resolved create-time parameters
      log - the mojo logger
  • Method Details

    • createAt

      public void createAt(Path wsDir) throws org.apache.maven.api.plugin.MojoException
      Write the full workspace scaffold into wsDir and optionally initialize git. The directory must not already contain pom.xml or workspace.yaml; the caller is responsible for that pre-check.
      Parameters:
      wsDir - the workspace directory to populate
      Throws:
      org.apache.maven.api.plugin.MojoException - on file or git failures
    • refreshExtensionsManagedBlock

      public static boolean refreshExtensionsManagedBlock(Path extensionsXmlPath, String extensionVersion) throws IOException
      Refresh the managed ike-workspace-extension block in an existing .mvn/extensions.xml. Replaces the sentinel-bounded block with a freshly-generated one carrying the current extensionVersion. When the file predates the sentinel convention (or lacks an extension entry entirely), one-time migrates by appending the managed block before the closing </extensions> tag.

      Idempotent. A no-op write is suppressed.

      Parameters:
      extensionsXmlPath - path to the .mvn/extensions.xml to refresh
      extensionVersion - the literal version to write
      Returns:
      true if the file was rewritten, false when the existing content already matches
      Throws:
      IOException - on read/write failure
    • managedHeader

      public static String managedHeader(String name, String description, String org)
      Build the managed comment header that leads workspace.yaml. Wrapped in MANAGED_BEGIN / MANAGED_END sentinels so refreshManagedHeader(Path, String, String, String) can replace it in place on every ws:scaffold-init run (ike-issues#458). Hardcoded goal-name strings are forbidden — they are pulled from WsGoal so a goal rename propagates.
      Parameters:
      name - the workspace name
      description - the workspace description; falls back to name when blank
      org - the GitHub org for the clone URL; rendered as <org> when null or blank
      Returns:
      the sentinel-bounded header, ending in a blank line
    • refreshManagedHeader

      public static boolean refreshManagedHeader(Path yamlPath, String name, String description, String org) throws IOException
      Refresh the managed comment header in an existing workspace.yaml. Replaces the block between MANAGED_BEGIN and MANAGED_END with freshly- generated text. When the file predates the sentinel convention, one-time migrates by stripping the legacy leading #-prefix comment block (consecutive comment-or-blank lines from the start of file, terminated by the first non-comment non-blank line) and prepending the new sentinel-bounded block.

      Idempotent. A no-op write is suppressed.

      Parameters:
      yamlPath - path to the workspace.yaml to refresh
      name - the workspace name (typically the workspace directory name)
      description - the workspace description; falls back to name when blank
      org - the GitHub org; null renders as <org> placeholder
      Returns:
      true if the file was rewritten, false when the existing header already matches
      Throws:
      IOException - on read/write failure