You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Michael Osipov (Jira)" <ji...@apache.org> on 2020/08/02 11:17:00 UTC
[jira] [Closed] (MNG-6921) Maven compile with properties
${artifactId} and ${project.build.finalName} occurs
java.lang.NullPointerException
[ https://issues.apache.org/jira/browse/MNG-6921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Osipov closed MNG-6921.
-------------------------------
Fix Version/s: (was: waiting-for-feedback)
Assignee: Sylwester Lachiewicz
Resolution: Fixed
I consider this implicitly being fixed by [~slachiewicz]'s work. Changed {{${artifactId\}}} to {{${project.artifactId\}}} gives me:
{noformat}
PS D:\Entwicklung\Projekte\maven-demo> D:\Entwicklung\Programme\apache-maven-3.7.0-SNAPSHOT\bin\mvn.cmd compile
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'artifactId' contains an expression but should be a constant. @ com.example:${project.artifactId}:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml, line 22, column 17
[ERROR] Resolving expression: '${project.artifactId}': Detected the following recursive expression cycle in 'project.artifactId': [artifactId] @ com.example:${project.artifactId}:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml
[ERROR] Resolving expression: '${project.artifactId}': Detected the following recursive expression cycle in 'project.artifactId': [artifactId] @ com.example:${project.artifactId}:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml
[ERROR] For artifact {com.example:null:0.0.1-SNAPSHOT:jar}: The artifactId cannot be empty. @ com.example:[unknown-artifact-id]:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml
[ERROR] 'artifactId' is missing. @ com.example:${project.artifactId}:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml, line 22, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.example:null:0.0.1-SNAPSHOT (D:\Entwicklung\Projekte\maven-demo\api\pom.xml) has 4 errors
[ERROR] Resolving expression: '${project.artifactId}': Detected the following recursive expression cycle in 'project.artifactId': [artifactId] @ com.example:${project.artifactId}:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml -> [Help 2]
[ERROR] Resolving expression: '${project.artifactId}': Detected the following recursive expression cycle in 'project.artifactId': [artifactId] @ com.example:${project.artifactId}:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml -> [Help 2]
[ERROR] For artifact {com.example:null:0.0.1-SNAPSHOT:jar}: The artifactId cannot be empty. @ com.example:[unknown-artifact-id]:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml
[ERROR] 'artifactId' is missing. @ com.example:${project.artifactId}:0.0.1-SNAPSHOT, D:\Entwicklung\Projekte\maven-demo\api\pom.xml, line 22, column 17
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/InterpolationCycleException
PS D:\Entwicklung\Projekte\maven-demo>
{noformat}
> 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
> Assignee: Sylwester Lachiewicz
> Priority: Major
> Labels: NPE
> Fix For: 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)