Class ScaffoldMojoSupport
ike:scaffold-draft,
ike:scaffold-publish, and ike:scaffold-revert.
Resolves the scaffold tree (manifest + templates), loads per-scope lockfiles from disk, and offers pure-function helpers the three mojos use. Written as a final class with static methods so the mojos can share wiring without inheritance.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAggregate counts of each action kind in a plan. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic ScaffoldMojoSupport.CountscountActions(ScaffoldPlan plan) One-line summary of what the plan would change, for post-publish telemetry and draft headers.static ScaffoldLockfileloadLockfileOrEmpty(Path lockfilePath) Load a lockfile from disk, returningScaffoldLockfile.empty()when the file is absent.static ScaffoldManifestloadManifest(Path scaffoldDir) Resolve the manifest file at the root of a scaffold tree.static voidWrite a batch of plan-report lines through the supplied log.static PathprojectLockfilePath(Path projectRoot) Resolve the project lockfile path, creating nothing.static StringrenderOrphanReport(List<OrphanEntry> orphans, ScaffoldScope scope) Render an orphan listing suitable for log output.static StringrenderPlanReport(ScaffoldPlan plan, ScaffoldScope scope) Render a draft-style listing of a plan suitable for log output.static StringrenderRevertReport(ScaffoldReverter.RevertResult result, ScaffoldScope scope) Render a revert-outcome listing suitable for log output.static PathresolveProjectRoot(String projectRootOverride, org.apache.maven.api.Session session) Resolve the effective project root for a scaffold goal.static List<ScaffoldScope> scopesToProcess(boolean inProject) Scopes the mojos should run for given a project-required context: in a project, both scopes apply; standalone, only user.static PathuserLockfilePath(Path userHome) Resolve the user lockfile path, creating nothing.
-
Field Details
-
MANIFEST_FILE
File name of the manifest inside a scaffold tree.- See Also:
-
PROJECT_LOCKFILE_REL
Relative path of the per-project lockfile.- See Also:
-
USER_LOCKFILE_REL
-
-
Method Details
-
resolveProjectRoot
public static Path resolveProjectRoot(String projectRootOverride, org.apache.maven.api.Session session) Resolve the effective project root for a scaffold goal.Goals annotated
projectRequired = falsecannot rely on Maven's parameter-default expansion of${project.basedir}— Maven 4 leaves the placeholder uninterpolated when no project is required, even when one is in scope. Callers therefore pass an explicitprojectRootparameter when supplied by the user; when blank, this helper derives the directory fromProtoSession.getTopDirectory()(the directory Maven was launched from).The result is null when no
pom.xmlsits at the resolved location, which the calling mojo treats as fresh-machine bootstrap (user scope only, no project scope).- Parameters:
projectRootOverride- raw value of theprojectRootparameter; null/blank means "auto-detect"session- Maven 4 session; required for auto-detection. May benullin tests that supply an explicit override.- Returns:
- absolute project root, or
nullwhen no project is in scope at the resolved location
-
loadManifest
Resolve the manifest file at the root of a scaffold tree.- Parameters:
scaffoldDir- the directory containing "scaffold-manifest.yaml" and templates- Returns:
- parsed manifest
- Throws:
ScaffoldException- if the directory or manifest is missing
-
projectLockfilePath
-
userLockfilePath
-
loadLockfileOrEmpty
Load a lockfile from disk, returningScaffoldLockfile.empty()when the file is absent.- Parameters:
lockfilePath- path to the lockfile; may benull(returns empty)- Returns:
- the loaded lockfile, or an empty lockfile
-
renderPlanReport
Render a draft-style listing of a plan suitable for log output.Lines look like:
[INSTALL] mvnw -> /path/to/mvnw [UPDATE] .mvn/maven.config -> refresh [SKIP] .gitignore user-edited; +3/-1 [OK] ~/.m2/settings.xml up-to-date [USER] ~/.gitconfig deferred to user value for [core].hooksPath
- Parameters:
plan- the plan to renderscope- the scope the plan was built for (used as a header)- Returns:
- multi-line human-readable report (no trailing newline)
-
renderOrphanReport
Render an orphan listing suitable for log output. Orphans are lockfile entries the current manifest no longer ships.- Parameters:
orphans- the orphans found byOrphanScannerscope- the scope the scan targeted (used as a header)- Returns:
- multi-line human-readable report (no trailing newline)
-
countActions
One-line summary of what the plan would change, for post-publish telemetry and draft headers.- Parameters:
plan- the plan to summarise- Returns:
- counts of each action type
-
renderRevertReport
Render a revert-outcome listing suitable for log output.- Parameters:
result- the revert resultscope- the scope the revert targeted- Returns:
- multi-line human-readable report (no trailing newline)
-
logLines
Write a batch of plan-report lines through the supplied log. Each\n-separated segment becomes a separatelog.infocall so Maven's level/colour formatting works on each line.- Parameters:
log- the mojo logmultiLine- multi-line text
-
scopesToProcess
Scopes the mojos should run for given a project-required context: in a project, both scopes apply; standalone, only user.- Parameters:
inProject- whether the mojo invocation has a project- Returns:
- scopes to process, in order
-