Properties in parent definition are prohibited in the intellij maven on my mac osx

maven properties in parent definition
maven revision property
maven parent version
version' contains an expression but should be a constant
maven version property substitution
maven revision
maven ci friendly
project build error parent version is missing

I have a question about my maven configuration on my MAC Intellij. I get an error that ${a-web.version} "properties in parent definition are prohibited" within parent tag in child POM.xml and that properties is defined in parent POM.xml. But this same configuration works well on my Windows Intellij.

Below is my parent POM.xml.

<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 
http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>***</groupId>
   <artifactId>a-web</artifactId>
   <packaging>pom</packaging>
   <version>${a-web.version}</version>
   <name>a-web project</name>
   <url>http://***</url>

   <properties>
       <a-web.version>1.0.0</a-web.version>
   </properties>

   <modules>
       <module>a-core</module>
       <module>a-web</module>
   </modules>
</project>

And this is my child POM.xml that configure a parent block.

<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 
http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>a-web</artifactId>
        <groupId>***</groupId>
        <version>${a-web.version}</version>
        <relativePath>../</relativePath>
    </parent>

    <artifactId>aweb-web</artifactId>
    <version>${a-web.version}</version>
    <packaging>war</packaging>
    <name>aweb-web</name>
</project>

I've tried many methods from stackoverflow, but no one can fix it. I want to know why this Maven config have different behaviour in Mac and windows and how to fix it.

I have run into a very similar situation when the project started using parent version properties in the commit I have just pulled. The project would not build and felt "ill-imported". An attempt to show effective pom failed with no details presented by IDEA.

As @khmarbaise pointed out in the comments[1], there are some restrictions for properties usage in maven <parent> declarations - the most notable is maven 3.5+ is required. The IDEA might not be using maven new enough (the bundled one in the latest IDEA I have installed was too old) so I had to switch to local install using Settings > Build, Execution, Deployment > Build Tools > Maven > Maven Home Directory. Once pointed to newer version, it did not start to work immediately - some of the restart/rebuild/reimport routines caused the new setting to be effective and the project to successfully import and build again.

Despite the maven version requirement was enforced in pom, it have not caused IDEA to complain the maven version it uses is old. The lack of any details that IDEA fails to inspect the project with the maven it uses did not helped either. Now when everything else works, it still says "Properties in parent definition are prohibited" in pom files.

[1] https://maven.apache.org/maven-ci-friendly.html

properties in parent definition are prohibited on mac osx Intellij , Hi. Why do I get the error message "properties in parent definition are prohibited" for having ${revision}${sha1}${changelist} properties in parent definition are prohibited on mac osx Intellij 2018.1.2 – IDEs Support (IntelliJ Platform) | JetBrains.

Work for me in Idea 18.2:

1) Don't use embeded Maven. Install Maven from official site! It's help me (^_^)

2) You can try to add groupId in child pom, put <groupId>com.iqiyi.lego.web</groupId> before line <artifactId>legoweb-web</artifactId>.

Try this code:

<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 
http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>lego-web</artifactId>
        <groupId>com.iqiyi.lego.web</groupId>
        <version>${lego-web.version}</version>
        <relativePath>../</relativePath>
    </parent>

    **<groupId>com.iqiyi.lego.web</groupId>**
    <artifactId>legoweb-web</artifactId>
    <version>${lego-web.version}</version>
    <packaging>war</packaging>
    <name>legoweb-web</name>
</project>

Maven:Properties in parent definition are prohibited|maven , Returns Component A component of the matching type, if fo. .jetbrains.com/hc/​en-us/community/posts/360000439484-properties-in-parent-definition-are-​prohibited-on-mac-osx-Intel. [IntelliJ IDEA][maven]properties in parent definition are . 7 Spring Boot @Value Properties Apr 5 '17 1 How to get just the parent directory name of a specific file Feb 15 '18 1 Properties in parent definition are prohibited in the intellij maven on my mac osx Sep 13 '19

I think it's because when you push the compiled jar to central maven or private maven such as nexus, you can find the version in META-INF/maven/xxxxx/pom.xml of sub project is

<version>${lego-web.version}</version>

not real value <version>1.0.0</version>.so when you want to release a single jar, you cannot get the true version

Maven Plugin in IntelliJ IDEA does not correctly resolve properties defined in settings.xml Follow Assen Todorov Created December 04, 2009 12:46

It is the IntelliJ IDEA bug.

At least in the IntelliJ IDEA 2019.2 (Ultimate Edition) Build #IU-192.5728.98, built on July 23, 2019

Defining Runtime Properties. Use the Properties tab of the Build File Properties Dialog to pass properties to the build script at runtime. The specified values are equivalent to those defined after the -D option of the command line launcher. In addition to plain values, you can use macros that are evaluated at runtime.

Setting property revision in parent pom.xml and then inherit it into children, fixed the issue for me.

<groupId>com.java</groupId>
<artifactId>test</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>

<name>Test</name>
<description>Demo project for Spring Boot</description>

<modules>
    <module>backend</module>
    <module>frontend</module>
</modules>

<properties>
    <revision>1.0.0-SNAPSHOT</revision>
</properties>

In the child's pom.xml:

<parent>
    <artifactId>com.java</artifactId>
    <groupId>test</groupId>
    <version>${revision}</version>
</parent>

<artifactId>backend</artifactId>

I use Maven 3.6.1

Getting the properties defined in the parent POM inside the child modules [multi-module projects] the begining of maven's build saying that properties can be

Properties. By default, the columns in this area display system properties that are passed to Maven for creating a project from the archetype. You can click the following buttons to modify displayed properties: Add a Maven property. Remove a Maven property. Edit a Maven property.

Parent POM Relative Path. By default, Maven looks for the parent POM first at project’s root, then the local repository, and lastly in the remote repository. If parent POM file is not located in any other place, then you can use code tag. This relative path shall be relative to project root.

Is there a way that IntelliJ does not replace the parent in the pom.xml after being generated by a maven archetype? Background of this question is that I would like to the "new" CI friendly properties of maven 3.5.0 and above. So I would like to create a parent like this: <parent> <groupId>my.group</groupId> <artifactId>parent</artifactId>

Comments
  • Ask yourself: How should one (Maven) get the parent without knowing the exact version?
  • Exact version? the parent pom.xml has defined the lego-web.version to 1.0.0. Those configs work well on my windows, but give error on my Mac osx
  • What is the IntelliJ version in macOS and in Windows?
  • To use a property as version in pom as you did you have to use predefined names: ${revision}, ${sha1} and ${changelist} see for the details maven.apache.org/maven-ci-friendly.html Also you have to use Maven 3.5.0.
  • @王昭辉 Then let me be clear: While analyzing the child POM, Maven finds a reference to a parent POM with a version that is specified by a property: ${lego-web.version}. This property is nowhere defined in the child POM. So Maven simply can't find the referenced parent.
  • yup, I see the same ... all working fine but the editor complains "Properties in parent definition are prohibited". I guess the editor needs improving to understand this new capability of Maven, but that's all.
  • Worked for me in IDEA 2018.3 after I switch to my own Maven (3.6.0 instead of the bundled 3.3.9