Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when used in IDE as first phase of maven #488

Open
freedom1b2830 opened this issue Oct 3, 2023 · 2 comments
Open

NPE when used in IDE as first phase of maven #488

freedom1b2830 opened this issue Oct 3, 2023 · 2 comments
Labels
bug Something isn't working. good first issue Good for newcomers. to grab Ready to do and to grab by those willing.

Comments

@freedom1b2830
Copy link

Describe the bug
My idea was to run signature verification immediately after downloading the dependencies, so I set the validate phase.
when running mvn clean install it works fine.
When opening a project in eclipse it shows NPE

To Reproduce

  1. create 2 projects(see pom.xml files below)
  2. open projects in eclipse

Expected behavior
running the verification plugin after downloading dependencies

Additional context
There is no such behavior when used in maven.

error in:

<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>
	<artifactId>proj</artifactId>
	<parent>
		<groupId>proj</groupId>
		<artifactId>header</artifactId>
		<version>1.0</version>
	</parent>
</project>

parent:

<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>proj</groupId>
	<artifactId>header</artifactId>
	<version>1.0</version>
	<packaging>pom</packaging>

	
	</build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.simplify4u.plugins</groupId>
					<artifactId>pgpverify-maven-plugin</artifactId>
					<version>1.17.0</version>
				</plugin>
			</plugins>
		</pluginManagement>

			<plugin>
				<groupId>org.simplify4u.plugins</groupId>
				<artifactId>pgpverify-maven-plugin</artifactId>
				<configuration>
					<keysMapLocation>${PGP_MAP}</keysMapLocation>
					<verifyPlugins>true</verifyPlugins>
					<verifyAtypical>true</verifyAtypical>
					<suppressSignatureOkLogging>true</suppressSignatureOkLogging>
					<verifySnapshots>true</verifySnapshots>
					<verifyPluginDependencies>true</verifyPluginDependencies>
				</configuration>
				<executions>
					<execution>
						<id>download</id>
						<phase>validate</phase>
						<goals>
							<goal>go-offline</goal>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
Failed to execute mojo org.simplify4u.plugins:pgpverify-maven-plugin:1.17.0:check {execution: download} (org.simplify4u.plugins:pgpverify-maven-plugin:1.17.0:check:download:validate)

org.eclipse.core.runtime.CoreException: Failed to execute mojo org.simplify4u.plugins:pgpverify-maven-plugin:1.17.0:check {execution: download}
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:340)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.lambda$0(MavenExecutionContext.java:291)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:290)
	at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:57)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.lambda$2(MavenBuilderImpl.java:153)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:986)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:133)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:164)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$1(MavenBuilder.java:109)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:228)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$0(MavenBuilder.java:100)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:83)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:192)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:1079)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:296)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:352)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:441)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:444)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:555)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:503)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:585)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:207)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:300)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution download of goal org.simplify4u.plugins:pgpverify-maven-plugin:1.17.0:check failed: Cannot invoke "org.apache.maven.execution.ProjectDependencyGraph.getUpstreamProjects(org.apache.maven.project.MavenProject, boolean)" because the return value of "org.apache.maven.execution.MavenSession.getProjectDependencyGraph()" is null
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:338)
	... 32 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.maven.execution.ProjectDependencyGraph.getUpstreamProjects(org.apache.maven.project.MavenProject, boolean)" because the return value of "org.apache.maven.execution.MavenSession.getProjectDependencyGraph()" is null
	at org.simplify4u.plugins.skipfilters.ReactorDependencySkipper.<init>(ReactorDependencySkipper.java:39)
	at org.simplify4u.plugins.AbstractVerifyMojo.prepareDependencyFilters(AbstractVerifyMojo.java:229)
	at org.simplify4u.plugins.AbstractVerifyMojo.executeConfiguredMojo(AbstractVerifyMojo.java:150)
	at org.simplify4u.plugins.AbstractPGPMojo.execute(AbstractPGPMojo.java:177)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
	... 33 more

@slawekjaranowski
Copy link
Member

Issue can be caused by wrong eclipse implementation.

Despite, we can protect it in ReactorDependencySkipper - simply we can set an empty list for upstreamProjects.

@slawekjaranowski slawekjaranowski added bug Something isn't working. good first issue Good for newcomers. to grab Ready to do and to grab by those willing. labels Apr 12, 2024
@slawekjaranowski
Copy link
Member

PR are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. good first issue Good for newcomers. to grab Ready to do and to grab by those willing.
Development

No branches or pull requests

2 participants