Class WorkspaceBootstrap
java.lang.Object
network.ike.plugin.ws.bootstrap.WorkspaceBootstrap
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 emptysubprojects: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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordParameters captured from the user-facing mojo. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSentinel marking the start of the managed extension block in.mvn/extensions.xml.static final StringSentinel marking the end of the managed extension block.static final StringSentinel marking the start of the managed comment header inworkspace.yaml.static final StringSentinel marking the end of the managed comment header. -
Constructor Summary
ConstructorsConstructorDescriptionWorkspaceBootstrap(WorkspaceBootstrap.Params params, org.apache.maven.api.plugin.Log log) Create a workspace bootstrapper bound to a parameter bag and a logger. -
Method Summary
Modifier and TypeMethodDescriptionvoidWrite the full workspace scaffold intowsDirand optionally initialize git.static StringmanagedHeader(String name, String description, String org) Build the managed comment header that leadsworkspace.yaml.static booleanrefreshExtensionsManagedBlock(Path extensionsXmlPath, String extensionVersion) Refresh the managed ike-workspace-extension block in an existing.mvn/extensions.xml.static booleanrefreshManagedHeader(Path yamlPath, String name, String description, String org) Refresh the managed comment header in an existingworkspace.yaml.
-
Field Details
-
EXTENSIONS_MANAGED_BEGIN
Sentinel marking the start of the managed extension block in.mvn/extensions.xml. The block between this marker andEXTENSIONS_MANAGED_ENDis regenerated byws:scaffold-initandws:scaffold-publish(IKE-Network/ike-issues#460) so the ike-workspace-extension version stays in lockstep with theike-parentproperty.- See Also:
-
EXTENSIONS_MANAGED_END
Sentinel marking the end of the managed extension block.- See Also:
-
MANAGED_BEGIN
Sentinel marking the start of the managed comment header inworkspace.yaml. The block between this marker andMANAGED_ENDis regenerated byws:scaffold-initon every run (IKE-Network/ike-issues#458) so the bootstrap instructions stay in lockstep with current goal names.- See Also:
-
MANAGED_END
Sentinel marking the end of the managed comment header.- See Also:
-
-
Constructor Details
-
WorkspaceBootstrap
Create a workspace bootstrapper bound to a parameter bag and a logger. Construction is cheap; the actual filesystem writes happen increateAt(Path).- Parameters:
params- the resolved create-time parameterslog- the mojo logger
-
-
Method Details
-
createAt
Write the full workspace scaffold intowsDirand optionally initialize git. The directory must not already containpom.xmlorworkspace.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 currentextensionVersion. 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.xmlto refreshextensionVersion- the literal version to write- Returns:
trueif the file was rewritten,falsewhen the existing content already matches- Throws:
IOException- on read/write failure
-
managedHeader
Build the managed comment header that leadsworkspace.yaml. Wrapped inMANAGED_BEGIN/MANAGED_ENDsentinels sorefreshManagedHeader(Path, String, String, String)can replace it in place on everyws:scaffold-initrun (ike-issues#458). Hardcoded goal-name strings are forbidden — they are pulled fromWsGoalso a goal rename propagates.- Parameters:
name- the workspace namedescription- the workspace description; falls back tonamewhen blankorg- the GitHub org for the clone URL; rendered as<org>whennullor 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 existingworkspace.yaml. Replaces the block betweenMANAGED_BEGINandMANAGED_ENDwith 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 theworkspace.yamlto refreshname- the workspace name (typically the workspace directory name)description- the workspace description; falls back tonamewhen blankorg- the GitHub org;nullrenders as<org>placeholder- Returns:
trueif the file was rewritten,falsewhen the existing header already matches- Throws:
IOException- on read/write failure
-