Skip to content

toolchains:3.2.0:select-jdk-toolchain fails with Maven 4.0.0-rc4 due to Guice/NullInjectedIntoNonNullable #128

@nxglhez

Description

@nxglhez

Affected version

3.2.0

Bug description

Hello,

I am trying to check how Maven 4 will eat my time, and I tried updating my project using mvnup.

While migration worked, it gave me this error when running mvn validate:

com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/NullInjectedIntoNonNullable]: null returned by binding at LocatorWiring
 but SelectJdkToolchainMojo.factory(SelectJdkToolchainMojo.java:57) is not @Nullable
  at LocatorWiring
  at SelectJdkToolchainMojo.factory(SelectJdkToolchainMojo.java:57)
      \_ for field factory
  while locating SelectJdkToolchainMojo

Learn more:
  https://github.com/google/guice/wiki/NULL_INJECTED_INTO_NON_NULLABLE

1 error

======================
Full classname legend:
======================
LocatorWiring:          "org.eclipse.sisu.wire.LocatorWiring"
SelectJdkToolchainMojo: "org.apache.maven.plugins.toolchain.jdk.SelectJdkToolchainMojo"
========================
End of classname legend:
========================

The pom I used is very simple (it is more complex in my use case, but this failed as well): the pom below is the Maven 3 compatible POM (modelVersion 4.0.0) and it fails the same with Maven 4 (it works with Maven 3).

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.acme.example</groupId>
  <artifactId>sample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
    <resources.propertiesEncoding>${project.build.sourceEncoding}</resources.propertiesEncoding>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <toolchain.jdk.version>[8,)</toolchain.jdk.version>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-toolchains-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-toolchains-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>select-jdk-toolchain</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

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