Skip to content

DefaultBuildContext cannot be provisioned outside a Maven session in 1.3.0 #125

Description

@slachiewicz

DefaultBuildContext gained two constructor dependencies in 1.3.0:

1.2.0  DefaultBuildContext(org.sonatype.plexus.build.incremental.BuildContext)
1.3.0  DefaultBuildContext(org.sonatype.plexus.build.incremental.BuildContext,
                           org.codehaus.plexus.build.connect.BuildConnection,
                           org.apache.maven.plugin.LegacySupport)

org.apache.maven.plugin.LegacySupport is a Maven session component. In a plain sisu container — a unit
test, or any consumer that is not running inside a Maven build — it cannot be provisioned, so sisu injects
null where a BuildContext is expected.

Reproducer

Raising the pin from 1.2.0 to 1.3.0 in modello is enough. Modello Java Plugin then fails 13 of 17 tests,
each with:

com.google.inject.ProvisionException:
1) [Guice/NullInjectedIntoNonNullable]: null returned by binding at LocatorWiring
 but AbstractModelloGenerator.buildContext(AbstractModelloGenerator.java:59) is not @Nullable
  while locating JavaModelloGenerator

The same module is green on 1.2.0 with no other change, so the version bump is the whole difference.

Also changed

1.3.0 ships META-INF/maven/extension.xml, which 1.2.0 did not. Together with the LegacySupport
dependency that moves the artifact from a library any sisu consumer can use towards something that expects
a Maven runtime around it. If that is the intended direction it is worth saying so in the README, since
BuildContext injection outside Maven is what the earlier versions supported.

Possible resolutions

  • Make BuildConnection and LegacySupport optional, or the field @Nullable, so DefaultBuildContext
    still provisions without a Maven session — a 1.3.1.
  • Keep the behaviour and document it; consumers outside a Maven runtime then stay on 1.2.0 and the change
    is a major rather than a minor.

Raised while bumping the pin across the codehaus-plexus components after the 1.3.0 release. modello stays
on 1.2.0 for now.

This issue was created with AI assistance.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions