[
https://issues.apache.org/jira/browse/MNG-8133?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Guillaume Nodet updated MNG-8133:
---------------------------------
Fix Version/s: 4.0.0-beta-5
> Project build breaks when META-POM uses {project.rootDirectory} (but root is
> definied)
> --------------------------------------------------------------------------------------
>
> Key: MNG-8133
> URL: https://issues.apache.org/jira/browse/MNG-8133
> Project: Maven
> Issue Type: Bug
> Affects Versions: 4.0.0-beta-3
> Environment: Windows, JDK 17
> Reporter: Matthias Bünger
> Priority: Major
> Fix For: 4.0.0-beta-5
>
>
> With the introduction of the {project.rootDirectory} variable in MNG-7038 I
> wanted to check if this variable may be a workaround for my PMD-plugin issue
> described in [MPMD-386|https://issues.apache.org/jira/browse/MPMD-386].
> During my tests (Maven-4.0.0-beta-3 on JDK 17) I found some strange behavior,
> for me a bug, when using the variable in a META-POM and a project using the
> META-POM. But step by step
> META-POM:
> * No usage of "{project.rootDirectory}" in META-POM and no definition of root
> directory (I'll use {root="true"} in my examples) brings up the new warning
> that no such folder is defined, but should be defined. - That's okay.
> * Using"{project.rootDirectory}" in the file path of plugin configuration,
> but no definition of root folder brings up the warning and then breaks the
> build with the {IllegalStateException} as describe in the PR of MNG-7038. -
> That's okay as it's uses of the projects variable which is calculated at the
> start, so definition is needed (documented in PR).
> * Using "{project.rootDirectory}" in the file path of plugin configuration
> with root definition let me install the META-POM in my local repository.
> So we have this META-POM (shortend, full example see
> https://github.com/Bukama/mpmd386 maven 4 folder)
> {code:xml}
> <project xmlns="http://maven.apache.org/POM/4.1.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.1.0
> http://maven.apache.org/xsd/maven-4.1.0.xsd" root="true">
> <modelVersion>4.1.0</modelVersion>
> <groupId>my.test.mpmd386</groupId>
> <artifactId>META-POMM4</artifactId>
> <version>1.0.0</version>
> <packaging>pom</packaging>
> <!-- ... -->
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-pmd-plugin</artifactId>
> <configuration>
>
> <!-- Maven 4.0.0-beta-3 with Model 4.1.0 -->
>
> <excludeFromFailureFile>${project.rootDirectory}/exclude-pmd.properties</excludeFromFailureFile>
> </configuration>
> </plugin>
> <!-- ... -->
> </project>
> {code}
> Now the actual multi-module project which uses the META-POM looks like this.
> {code:xml}
> <project xmlns="http://maven.apache.org/POM/4.1.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.1.0
> http://maven.apache.org/xsd/maven-4.1.0.xsd" root="true">
> <modelVersion>4.1.0</modelVersion>
> <groupId>my.test.mpmd386</groupId>
> <artifactId>MultiModuleRoot</artifactId>
> <version>0.0.1-SNAPSHOT</version>
> <packaging>pom</packaging>
> <name>Multi Module Root</name>
> <parent>
> <groupId>my.test.mpmd386</groupId>
> <artifactId>META-POMM4</artifactId>
> <version>1.0.0</version>
> </parent>
> <modules>
> <module>moduleA</module>
> </modules>
> </project>
> {code}
> What we see
> * Usage of the meta-POM
> * Also definies the root directory via {root="true"}, because this is where
> the project specific {exclude-pmd.properties} file is located.
> My expectation now was that the multi module will build and use the
> exclude-file from its root directory. However the build breaks cause Maven
> thinks there is no root directory set.
> {quote}
> [ERROR] Internal error: java.lang.IllegalStateException: Unable to find the
> root directory. Create a .mvn directory in the root directory or add the
> root="true" attribute on the root project's model to identify it. -> [Help 1]
> org.apache.maven.InternalErrorException: Internal error:
> java.lang.IllegalStateException: Unable to find the root directory. Create a
> .mvn directory in the root directory or add the root="true" attribute on the
> root project's model to identify it.
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:157)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:958)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:205)
> 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:255)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:201)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:361)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:314)
> Caused by: java.lang.IllegalStateException: Unable to find the root
> directory. Create a .mvn directory in the root directory or add the
> root="true" attribute on the root project's model to identify it.
> at
> org.apache.maven.api.services.model.RootLocator.findMandatoryRoot(RootLocator.java:47)
> at
> org.apache.maven.internal.impl.model.DefaultModelInterpolator$3.getValue(DefaultModelInterpolator.java:223)
> at
> org.codehaus.plexus.interpolation.PrefixedValueSourceWrapper.getValue(PrefixedValueSourceWrapper.java:120)
> at
> org.codehaus.plexus.interpolation.StringSearchInterpolator.interpolate(StringSearchInterpolator.java:166)
> at
> org.codehaus.plexus.interpolation.StringSearchInterpolator.interpolate(StringSearchInterpolator.java:105)
> at
> org.apache.maven.internal.impl.model.DefaultModelInterpolator.lambda$createInterpolator$0(DefaultModelInterpolator.java:135)
> at
> org.apache.maven.model.v4.MavenTransformer.transform(MavenTransformer.java:93)
> at
> org.apache.maven.model.v4.MavenTransformer.transform(MavenTransformer.java:2020)
> at
> org.apache.maven.model.v4.MavenTransformer.transform(MavenTransformer.java:1991)
> at
> org.apache.maven.model.v4.MavenTransformer.transform(MavenTransformer.java:2024)
> at
> org.apache.maven.model.v4.MavenTransformer.transformConfigurationContainer_Configuration(MavenTransformer.java:1445)
> at
> org.apache.maven.model.v4.MavenTransformer.transformReportPlugin(MavenTransformer.java:1834)
> at
> org.apache.maven.model.v4.MavenTransformer.transform(MavenTransformer.java:1991)
> at
> org.apache.maven.model.v4.MavenTransformer.transformReporting_Plugins(MavenTransformer.java:1608)
> at
> org.apache.maven.model.v4.MavenTransformer.transformReporting(MavenTransformer.java:1592)
> at
> org.apache.maven.model.v4.MavenTransformer.transformModelBase_Reporting(MavenTransformer.java:374)
> at
> org.apache.maven.model.v4.MavenTransformer.transformModel(MavenTransformer.java:132)
> at
> org.apache.maven.model.v4.MavenTransformer.visit(MavenTransformer.java:86)
> at
> org.apache.maven.internal.impl.model.DefaultModelInterpolator.interpolateModel(DefaultModelInterpolator.java:112)
> at
> org.apache.maven.internal.impl.model.DefaultModelBuilder.interpolateModel(DefaultModelBuilder.java:869)
> at
> org.apache.maven.internal.impl.model.DefaultModelBuilder.readEffectiveModel(DefaultModelBuilder.java:402)
> at
> org.apache.maven.internal.impl.model.DefaultModelBuilder.build(DefaultModelBuilder.java:536)
> at
> org.apache.maven.internal.impl.model.DefaultModelBuilder.build(DefaultModelBuilder.java:215)
> at
> org.apache.maven.internal.impl.model.DefaultModelBuilder.build(DefaultModelBuilder.java:179)
> at
> org.apache.maven.project.DefaultProjectBuilder$BuildSession.build(DefaultProjectBuilder.java:404)
> at
> org.apache.maven.project.DefaultProjectBuilder$BuildSession.initParent(DefaultProjectBuilder.java:987)
> at
> org.apache.maven.project.DefaultProjectBuilder$BuildSession.initProject(DefaultProjectBuilder.java:806)
> at
> org.apache.maven.project.DefaultProjectBuilder$BuildSession.doBuild(DefaultProjectBuilder.java:744)
> at
> org.apache.maven.project.DefaultProjectBuilder$BuildSession.lambda$build$6(DefaultProjectBuilder.java:706)
> at java.util.concurrent.FutureTask.run(FutureTask.java:264)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
> at java.lang.Thread.run(Thread.java:833)
> {quote}
> This makes no sense to me as the root folder is defined in the multi modules
> project and the PR describes it as " the project's directory or parent
> directory containing a .mvn subdirectory or a pom.xml flagged with the
> root="true" attribute".
> Notes:
> When the META-POM contains {session.rootDirectory} in the path definition of
> the exclude neither the META-POM needs the root definition nor the multi
> module project will refuse to build.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)