Reputation: 4621
I have multi-moduled ejb3-web application outlined as follows:
project
- pom.xml
project_ear
- pom.xml
project_ejb
- pom.xml
project_web
- pom.xml
And I have different similar project in which the previous one (project_ejb) is included.
project2
- pom.xml
project2_ear
- pom.xml
project2_ejb
- pom.xml (here, project_ejb is gonna be included as a dependency)
project2_web
- pom.xml
As you see they have similar structure. Anyways, the problem which I face is when I want to use ${project.version} I cannot clean or build the project2 anymore.
Here the pom samples of project
"project" Parent pom:
<modelVersion>4.0.0</modelVersion>
<groupId>com.project</groupId>
<artifactId>project</artifactId>
<version>${project.version}</version>
<packaging>pom</packaging>
"project_ejb" pom:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.project</groupId>
<artifactId>project</artifactId>
<version>${project.version}</version>
<relativePath>../project/pom.xml</relativePath>
</parent>
<artifactId>projectEjb</artifactId>
<packaging>ejb</packaging>
project2 parent pom:
<modelVersion>4.0.0</modelVersion>
<groupId>com.projectdata</groupId>
<artifactId>projectdata</artifactId>
<version>${project.version}</version>
<packaging>pom</packaging>
project2_ejb pom
<modelVersion>4.0.0</modelVersion>
<artifactId>projectdataEjb</artifactId>
<packaging>ejb</packaging>
<parent>
<groupId>com.projectdata</groupId>
<artifactId>projectdata</artifactId>
<version>${project.version}</version>
<relativePath>../projectdata/pom.xml</relativePath>
</parent>
And I have added project_ejb module into project2_ejb as a dependency:
<dependency>
<groupId>com.project</groupId>
<artifactId>projectEjb</artifactId>
<scope>provided</scope>
<type>ejb</type>
</dependency>
All in all, when I build project, everything is ok. However, when I try to build project2, it comes up with a problem appearing maven console and says that:
IllegalArgumentException: Illegal character in path at index 79: http://abcsvn01.host.myproject.net/maven/my/inhouse/com/project/project/${project.version}/project-${project.version}.pom -> [Help 1]
It is worth mentioning that when I remove ${project.version} and write constants, everything is ok. However, why I do not use this feature while maven3 is providing me already.
I would appreciate any help. Thanks in advance.
Upvotes: 3
Views: 2234
Reputation: 48105
When you are referencing a parent you must include a specific version. You cannot use ${project.version}
. This is because you may want to build just the child and the parent is in a repo. Then you will need to point to a specific parent.
The thing that happened in your child is that it tries to locate a pom file named project-${project.version}.pom
and that is because you didn't give an explicit version number to relate to.
This will work (change the version to your specific version). The version will be inherited by the child.
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.project</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../project/pom.xml</relativePath>
</parent>
<artifactId>projectEjb</artifactId>
<packaging>ejb</packaging>
Next thing is that you will need to give the version of the dependent projectEjb
in project2_ejb
. Otherwise it will not know what version of the projectEjb
to use. Your project
and project2
are unrelated so their versions will differ.
Added a version tag (change to your specific versions):
<dependency>
<groupId>com.project</groupId>
<artifactId>projectEjb</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
<type>ejb</type>
</dependency>
Upvotes: 2