Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

maven pom placeholder in parent/version tag is not replaced

The "WCB: Java development" forum contains threads on issues that are related to Java while programming a WCB (WebManager Component Bundle). If you have questions that have impact on Java code, post them in this forum. Some example topics: authorization, the different component types, setting up component dependencies, data access, and so forth.

Answered
Not marked as answered yet

Forums  >  WCB: Java development  >  maven pom placeholder in parent/version tag is not replaced


Author maven pom placeholder in parent/version tag is not replaced
maxzilla


Posts: 48

Posted: 14-10-2009 12:02

You GX guys got this working in the web-apps poms, how did you guys do this?
when i do this with a WCB POM placeholders in the parent/version tag are totally ignored. Any ideas why?
The property is defined in the settings.xml

patricka



Posts: 255

Posted: 16-10-2009 11:30

Can you give an example of what you are trying to do?

For local development, I usually copy this bit into my WCB's pom.xml:


<!-- plugin to copy the WCB to a local installation -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy
file="${project.build.directory}\${project.build.finalName}.jar"
todir="${webmanager.wcbdeploydir}" overwrite="true" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>



As you can see, this uses properties defined in the settings.xml and it works like a charm. I'm not sure what magic was involved to get it working - if any at all.

Greetings,

Patrick

maxzilla


Posts: 48

Posted: 19-10-2009 08:18

Hi Patrick,

placeholders do work, but not in the parent tag.
see code below. I can't make the parent -> version tag dynamic.


<?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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>webmanager-libraries</artifactId>
<groupId>nl.gx.webmanager.libraries</groupId>
<version>9.6.2 <!-- why has this to be hardcoded? --> </version>
</parent>
<groupId>nl.gx.srb</groupId>
<artifactId>snsbankstaticlib</artifactId>
<name>SNS Bank static library</name>
<description>Static library for the www.snsregiobank.nl website</description>
<url>www.snsregiobank.nl</url>
<version>1.2.0</version>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="Copying the WCB jar to deploy directory" />
<copy file="${project.build.directory}\${project.build.finalName}.jar" todir="${webmanager.wcbdeploydir}" overwrite="true" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Cthulhu



Posts: 198

Posted: 19-10-2009 13:36 Helpful

that's probably because the ${parent.version} tag is only made available after the parent is actually loaded in. It can't know the value of parent.version without knowing which parent version it has - if you know what I mean, I'm confusing myself.

Say you've got WebManager 1.3.7, 9.8.5, and 9.502346.1 on your system - which one of the three should your WCB use? It can't know unless you specify one, which is why at least ${parent.version} won't work in the pom.

Hope that's what you mean.

bramk



Posts: 34

Posted: 22-10-2009 17:17

More or less correct and effectively so.. The fact that this works for the webapp poms in the SDK is kind because of the way maven resolve parent references...


Maven looks for the parent pom first in the reactor of currently building projects, then in this location
on the filesystem, then the local repository, and lastly in the remote repo. relativePath allows you to
select a different location, for example when your structure is flat, or deeper without an intermediate
parent pom. However, the group ID, artifact ID and version are still required, and must match the file
in the location given or it will revert to the repository for the POM.



In the SDK case you will see that the backend webapp module actually has a parent declaration that matches (as in equals) the ../pom.xml, which in turn has a parent declaration that matches it's own ../pom.xml being the SDK root pom. This is not true for your WCB and therefore it fails.

So, basically this kind of works by accident and you can and should not use it outside your own project. In general I prefer to stick a project pom between the webmanager-wcbs pom and my own WCB poms so I can control the webmanager version an possibly other global settings in one place.

Regards,
Bram


Cthulhu



Posts: 198

Posted: 23-10-2009 12:13

One point I did see in a presentation on Maven 3 (see this thread, too) was a note on 'Versionless parent elements'. I'm not entirely sure if this applies to this particular case, but it might. Although I'd still recommend adding a parent element version in all cases - else you can get funky results / compiler errors if it chooses a parent that has a different API than the one you intended it to.

Back to top

New message: "maven pom placeholder in parent/version tag is not replaced"
Message:
bold boitalicd underline url quote code smile cool eek grin mad razz sad wink
 
© 2010 GX creative online development B.V.

Disclaimer

This website (GXdeveloperweb.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.