[Updated] (MNG-6921) Maven compile with properties ${artifactId} and ${project.build.finalName} occurs java.lang.NullPointerException

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Updated] (MNG-6921) Maven compile with properties ${artifactId} and ${project.build.finalName} occurs java.lang.NullPointerException

Sylwester Lachiewicz (Jira)

     [ https://issues.apache.org/jira/browse/MNG-6921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Osipov updated MNG-6921:
--------------------------------
    Fix Version/s: waiting-for-feedback

> Maven compile with properties ${artifactId} and ${project.build.finalName} occurs java.lang.NullPointerException
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: MNG-6921
>                 URL: https://issues.apache.org/jira/browse/MNG-6921
>             Project: Maven
>          Issue Type: Bug
>          Components: Command Line
>    Affects Versions: 3.6.2, 3.6.3
>         Environment: MacOS 10.15.2
>            Reporter: anruence
>            Priority: Major
>              Labels: NPE
>             Fix For: waiting-for-feedback, 3.7.0
>
>         Attachments: maven-demo.zip
>
>
> with maven 3.3.9,this project with command "mvn compile" can process normally,but NPE when change to 3.6.3
> after debug :
> ${artifactId} and ${project.build.finalName} define at same time will cause InterpolationCycleException
> PS: ${project.build.finalName} will be parse to ${project.artifactId}-${project.version} with default config.
> this problem can replay with attach project
> {code:java}
> Caused by: java.lang.NullPointerException
>     at java.util.concurrent.ConcurrentHashMap$MapEntry.setValue (ConcurrentHashMap.java:3539)
>     at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit (StringVisitorModelInterpolator.java:1429)
>     at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit (StringVisitorModelInterpolator.java:1027)
>     at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit (StringVisitorModelInterpolator.java:170)
>     at org.apache.maven.model.interpolation.StringVisitorModelInterpolator.interpolateModel (StringVisitorModelInterpolator.java:107)
>     at org.apache.maven.model.building.DefaultModelBuilder.interpolateModel (DefaultModelBuilder.java:789)
>     at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:393)
>     at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:448)
>     at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:414)
>     at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:558)
>     at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:414)
>     at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:377)
>     at org.apache.maven.graph.DefaultGraphBuilder.collectProjects (DefaultGraphBuilder.java:414)
>     at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor (DefaultGraphBuilder.java:405)
>     at org.apache.maven.graph.DefaultGraphBuilder.build (DefaultGraphBuilder.java:82)
>     at org.apache.maven.DefaultMaven.buildGraph (DefaultMaven.java:507)
>     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:219)
>     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:957)
>     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
>     at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
>     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke (Method.java:567)
>     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){code}
>  
> pom.xml
> {code:java}
> <?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>
>     <parent>
>         <groupId>com.example</groupId>
>         <artifactId>maven-demo</artifactId>
>         <version>0.0.1-SNAPSHOT</version>
>     </parent>
>     <version>0.0.1-SNAPSHOT</version>
>     <name>maven-demo-api</name>
>     <description>Demo project for Maven</description>
>     <packaging>jar</packaging>
>     <properties>
>         <groupId>com.example</groupId>
>         <artifactId>maven-demo-api</artifactId>
>         <project.build.finalName>maven-demo-api</project.build.finalName>
>         <finalName>${project.build.finalName}</finalName>
>     </properties>
>     <artifactId>${artifactId}</artifactId>
>     <build>
>         <plugins>
>             <plugin>
>                 <groupId>org.springframework.boot</groupId>
>                 <artifactId>spring-boot-maven-plugin</artifactId>
>             </plugin>
>             <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-jar-plugin</artifactId>
>                 <version>2.3.2</version>
>                 <configuration>
>                     <finalName>${finalName}</finalName>
>                 </configuration>
>             </plugin>
>         </plugins>
>     </build>
> </project>
> {code}
> org.apache.maven.model.interpolation.StringVisitorModelInterpolator#visit
> {code:java}
> private void visit( Properties properties )
> {
>     if ( properties != null )
>     {
>         for ( Map.Entry<Object, Object> entry : properties.entrySet() )
>         {
>             Object v = entry.getValue();
>             if ( v instanceof String )
>             {
>                 String value = (String) v;
>                 String inter = interpolate( value ); // inter can be return null
>                 if ( value != inter )
>                 {
>                     entry.setValue( inter );
>                 }
>             }
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)