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

NullPointerExeception when running quarkus:dev when trying to write dynamic property from git-commit-id-maven-plugin to manifest #32816

Closed
wtell400 opened this issue Apr 21, 2023 · 3 comments · Fixed by #33617
Labels
area/maven env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@wtell400
Copy link

Describe the bug

Hello,

I am trying to add the current git commit id to the MANIFEST.MF of the quarkus build artifact.

In the past I have used git-commit-id-maven-plugin to extract this value into a maven property:

<configuration>
	...
	<injectAllReactorProjects>true</injectAllReactorProjects>
	...
	<includeOnlyProperties>
		<includeOnlyProperty>git.commit.id.describe</includeOnlyProperty>
	</includeOnlyProperties>
</configuration>

and add the property git.commit.id.describe to the jar file using the maven-jar-plugin with:

<archive>
	<manifestEntries>
		<Implementation-Build>${git.commit.id.describe}</Implementation-Build>
	</manifestEntries>
</archive>

Now from what I understand, with Quarkus I can no longer use the maven-jar-plugin but have to use the quarkus-maven-plugin to set manifest values:

<configuration>
	<manifestEntries>
		<Implementation-Build>${git.commit.id.describe}</Implementation-Build>
	</manifestEntries>
</configuration>

When running the project with mvn quarkus-dev (or in my case form intellij with the quarkus plugin), I get a NullPointerException on parsing properties and the application does not start.

Expected behavior

When building the project with mvn clean package -DskipTests=true, I expect to find in the quarkus-run.jar MANIFEST.MF file

Implementation-Build: [my.git.commit.id]

When running the project with mvn quarkus-dev (or in my case form intellij with the quarkus plugin), I expect the application to start

Actual behavior

When building the project with mvn clean package -DskipTests=true, I find in the quarkus-run.jar MANIFEST.MF file

Implementation-Build: [my.git.commit.id]

When running the project with mvn quarkus-dev (or in my case form intellij with the quarkus plugin), I get:

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< org.acme:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- quarkus-maven-plugin:2.16.6.Final:dev (default-cli) @ code-with-quarkus ---
[INFO] Invoking org.apache.maven.plugins:maven-resources-plugin:2.6:resources @ code-with-quarkus
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Invoking io.quarkus.platform:quarkus-maven-plugin:2.16.6.Final:generate-code @ code-with-quarkus
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.904 s
[INFO] Finished at: 2023-04-21T12:04:38+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.16.6.Final:dev (default-cli) on project code-with-quarkus: Quarkus code generation phase has failed: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.16.6.Final:dev (default-cli) on project code-with-quarkus: Quarkus code generation phase has failed
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Quarkus code generation phase has failed
    at io.quarkus.maven.GenerateCodeMojo.generateCode (GenerateCodeMojo.java:85)
    at io.quarkus.maven.GenerateCodeMojo.doExecute (GenerateCodeMojo.java:53)
    at io.quarkus.maven.QuarkusBootstrapMojo.execute (QuarkusBootstrapMojo.java:154)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:120)
    at io.quarkus.maven.DevMojo.executeIfConfigured (DevMojo.java:655)
    at io.quarkus.maven.DevMojo.triggerPrepare (DevMojo.java:602)
    at io.quarkus.maven.DevMojo.triggerCompile (DevMojo.java:623)
    at io.quarkus.maven.DevMojo.handleAutoCompile (DevMojo.java:582)
    at io.quarkus.maven.DevMojo.execute (DevMojo.java:412)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.putVal (ConcurrentHashMap.java:1011)
    at java.util.concurrent.ConcurrentHashMap.put (ConcurrentHashMap.java:1006)
    at java.util.Properties.put (Properties.java:1301)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.doBootstrap (QuarkusBootstrapProvider.java:193)
    at io.quarkus.maven.QuarkusBootstrapProvider$QuarkusMavenAppBootstrap.bootstrapApplication (QuarkusBootstrapProvider.java:292)
    at io.quarkus.maven.QuarkusBootstrapProvider.bootstrapApplication (QuarkusBootstrapProvider.java:103)
    at io.quarkus.maven.QuarkusBootstrapMojo.bootstrapApplication (QuarkusBootstrapMojo.java:272)
    at io.quarkus.maven.GenerateCodeMojo.generateCode (GenerateCodeMojo.java:70)
    at io.quarkus.maven.GenerateCodeMojo.doExecute (GenerateCodeMojo.java:53)
    at io.quarkus.maven.QuarkusBootstrapMojo.execute (QuarkusBootstrapMojo.java:154)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo (MojoExecutor.java:120)
    at io.quarkus.maven.DevMojo.executeIfConfigured (DevMojo.java:655)
    at io.quarkus.maven.DevMojo.triggerPrepare (DevMojo.java:602)
    at io.quarkus.maven.DevMojo.triggerCompile (DevMojo.java:623)
    at io.quarkus.maven.DevMojo.handleAutoCompile (DevMojo.java:582)
    at io.quarkus.maven.DevMojo.execute (DevMojo.java:412)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

How to Reproduce?

Steps to reproduce the behavior:

  1. Create a project on code.quarkus.io, maven, Java 17, with resteasy reactive (although that might not be necessary.
  2. Add the git-commit-id-maven-plugin to the pom
<!-- Start: Added git-commit-id-plugin -->
<plugin>
	<groupId>io.github.git-commit-id</groupId>
	<artifactId>git-commit-id-maven-plugin</artifactId>
	<version>5.0.0</version>
	<executions>
		<execution>
			<id>get-git-info</id>
			<goals>
				<goal>revision</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
		<verbose>false</verbose>
		<generateGitPropertiesFile>true</generateGitPropertiesFile>
		<injectAllReactorProjects>true</injectAllReactorProjects>

		<includeOnlyProperties>
			<includeOnlyProperty>git.commit.id.describe</includeOnlyProperty>
		</includeOnlyProperties>
	</configuration>
</plugin>
<!-- End: Added git-commit-id-plugin -->
  1. Add this to the quarkus-maven-plugin
<!-- Start: Adding 'git.commit.id.describe' property from 'git-commit-id-plugin' -->
<configuration>
	<manifestEntries>
		<Implementation-Build>${git.commit.id.describe}</Implementation-Build>
	</manifestEntries>
</configuration>
<!-- End: Adding 'git.commit.id.describe' property from 'git-commit-id-plugin' -->		
  1. Run project with mvn quarkus:dev

Output of uname -a or ver

Microsoft Windows [Version 10.0.22621.1555]

Output of java -version

openjdk version "17.0.5" 2022-10-18 OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8) OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.6

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: C:\dev\tools\maven\apache-maven-3.8.6 Java version: 17.0.5, vendor: Eclipse Adoptium, runtime: C:\dev\tools\jdk\adoptium\jdk-17.0.5+8 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

Additional information

  • When removing the ${git.commit.id.describe} from the manifestEntries the application works with quarkus:dev, but I do not get the Implementation-Build entry in the manifest.
  • When adding ${git.commit.id.describe} to the maven <properties>, the application works with quarkus:dev, but then the value is static and it is not overwritten by the git-commit-id-maven-plugin during build.
  • When running mvn compile quarkus:dev, the application works, but the intellij plugin does not use this. It likely works as the compile phase triggers the git-commit-id-maven-plugin to set its properties in the reactor.
  • The ${git.commit.id.describe} is set dynamically by the git-commit-id-maven-plugin.

It seems as if the git-commit-id-maven-plugin is not run when running quarkus:dev, or the properties are not copied the reactor. It is as if the quarkus:dev goal does not use the rest of maven at all (seeing how the maven-jar-plugin also is not used).

I am stuck on how to make both these scenarios work at the same time. I am happy to solve this problem in another way, with a different plugin or setting in maven.

@wtell400 wtell400 added the kind/bug Something isn't working label Apr 21, 2023
@quarkus-bot quarkus-bot bot added area/maven env/windows Impacts Windows machines labels Apr 21, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 21, 2023

/cc @quarkusio/devtools (maven)

@gastaldi
Copy link
Contributor

Does it change if you add a <phase>process-resources</phase> to the git-commit-id's execution?

@wtell400
Copy link
Author

wtell400 commented May 2, 2023

It depends where the git-commit-id plugin is defined in de pom.

  • If git-commit-id-maven-plugin is before quarkus-maven-plugin, then mvn compile works.
  • If git-commit-id-maven-plugin is after quarkus-maven-plugin, then mvn compile fails with the same error.

This is because quarkus-maven-plugin is also using the process-resources phase, and goals of the same phase are executed in the order they are defined in the pom.

mvn help:describe -DartifactId=quarkus-maven-plugin -DgroupId=io.quarkus.platform -Dgoal=generate-code -Ddetail

[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.acme:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.4.0:describe (default-cli) @ code-with-quarkus ---
[INFO] Mojo: 'quarkus:generate-code'
quarkus:generate-code
  Description: (no description available)
  Implementation: io.quarkus.maven.GenerateCodeMojo
  Language: java
  Bound to phase: process-resources
...

Using generate-resources phase removes the order requirements of the plugins, as the generate-resources phase runs before the process-resources phase.


My initial issue still stands though.

Running mvn quarkus:dev still causes the same error. Likely because it does not call any of the maven lifecycle phases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/maven env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants