apache/maven · warning

Ignored invalid goal specification '{}' from lifecycle mappi

Error message

Ignored invalid goal specification '{}' from lifecycle mapping for phase {}

What it means

DefaultPackagingRegistry parses a packaging's lifecycle mapping, where every bound goal must be groupId:artifactId:goal (3 parts) or groupId:artifactId:version:goal (4 parts). A goal string with any other number of colon-separated segments is rejected with this warning and skipped, so that phase in the custom packaging silently runs one fewer goal.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultPackagingRegistry.java:131

                // Compute goal coordinates
                String groupId, artifactId, version, goal;
                String[] p = mojo.getGoal().trim().split(":");
                if (p.length == 3) {
                    // <groupId>:<artifactId>:<goal>
                    groupId = p[0];
                    artifactId = p[1];
                    version = null;
                    goal = p[2];
                } else if (p.length == 4) {
                    // <groupId>:<artifactId>:<version>:<goal>
                    groupId = p[0];
                    artifactId = p[1];
                    version = p[2];
                    goal = p[3];
                } else {
                    // invalid
                    LOGGER.warn(
                            "Ignored invalid goal specification '{}' from lifecycle mapping for phase {}",
                            mojo.getGoal(),
                            phase);
                    continue;
                }

                String key = groupId + ":" + artifactId;

                // Build plugin
                List<PluginExecution> execs = new ArrayList<>();
                List<Dependency> deps = new ArrayList<>();

                Plugin existing = plugins.get(key);
                if (existing != null) {
                    if (version == null) {
                        version = existing.getVersion();
                    }
                    execs.addAll(existing.getExecutions());

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Open the packaging plugin's lifecycle mapping metadata and rewrite the offending goal as groupId:artifactId:goal or groupId:artifactId:version:goal
  2. Rebuild and reinstall the packaging plugin, then re-run the consuming project so the corrected mapping is picked up
  3. Verify with mvn -X (or help:describe on the phase) that the phase now binds the expected goals

Example fix

<!-- before (custom packaging lifecycle mapping) -->
<lifecycle>
  <phases>
    <phase>my-package</phase>
  </phases>
  <mojos>
    <mojo>my-plugin:do-package</mojo> <!-- 2 parts: ignored -->
  </mojos>
</lifecycle>
<!-- after -->
<mojo>com.acme:my-plugin:do-package</mojo>
<!-- or with version pinned: com.acme:my-plugin:1.0:do-package -->
Defensive patterns

Strategy: validation

Validate before calling

// unit-test your packaging plugin's lifecycle mapping format
for (String goal : mappingGoals) {
    String[] p = goal.split(":");
    if (p.length != 3 && p.length != 4) {
        throw new IllegalArgumentException("Invalid goal spec (must be g:a[:v]:goal): " + goal);
    }
}

Prevention

When it happens

Trigger: A hand-authored lifecycle mapping for a custom packaging declares goal='prefix:goal' (2 parts), omits a segment, or adds extra segments; the split on ':' does not yield length 3 or 4 and the entry is dropped.

Common situations: Custom packaging plugins (own jar/war-like packagings) with typos in lifecycle.xml; mappings migrated from another format where 'groupId:artifactId:version:goal' ordering got mangled.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/c73fcf0c8eb474d2. Report an issue: GitHub.