[ 
http://jira.codehaus.org/browse/MNG-2632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mike Beaubien updated MNG-2632:
-------------------------------

    Attachment: fix.patch

I've been having problems with this as well.

The problem is that in the file DefaultMavenProjectBuilder.java there's lots of 
public methods for constructing projects. Most of the methods have a parameter 
into which the user is supposed to pass an object of type ProfileManager which 
is supposed to be the information contained in profile xml files like 
settings.xml.

Unfortunately, much of the code was using these methods incorrectly and was 
passing in null for this argument. When that was the case, only java system 
parameters get interpolated into the model, not the ones defined in 
settings.xml.

What I did to fix this was remove the ProfileManager parameter from the public 
methods. This is expected to be the global ProfileManager, the user of the 
interface is not supposed to be able to change this.

The second thing that I did was make the ProfileManager a global variable so 
that it's easier to access. I created a class called GlobalProfileManager. The 
main method in MavenCli sets this after it creates it. I changed everywhere 
else in the code to use the global variable rather than relying on passed in 
parameters.

I tested it using a simple pom file that has a transitive dependency part of 
which is a parameter set in settings.xml. It seems to work fine. I did make 
significant changes to Maven though, and I would appreciate it if someone more 
familiar with the Maven source could look at it and see if they can see any 
problems with the changes.

> Setting property in profiles is not evaluated for POM validation
> ----------------------------------------------------------------
>
>                 Key: MNG-2632
>                 URL: http://jira.codehaus.org/browse/MNG-2632
>             Project: Maven 2
>          Issue Type: Bug
>          Components: POM
>    Affects Versions: 2.0.4
>         Environment: WinXP
>            Reporter: Christoph Amshoff
>             Fix For: Reviewed Pending Version Assignment
>
>         Attachments: fix.patch
>
>
> There seems to be a problem concerning POM validation and setting properties 
> in profiles.xml: when I set a property in my profiles.xml it is not evaluated 
> for POM validation in a multi module build. 
> The details: My project C depends on module B, which itself is a child of 
> module A. Module A defines a system scope dependency like this: 
> {code}
> <dependency> 
>   <groupId>db2</groupId> 
>   <artifactId>db2</artifactId> 
>   <version>8.2</version> 
>   <scope>system</scope> 
>   <systemPath>${path.db2jar}</systemPath> 
> </dependency>
> {code}
> The path to db2.jar depends on the developer's machine and is specified in 
> the profiles.xml, toghether with other settings. Both A and B are building 
> and deploying fine. 
> Now, when I try to build C, it complains about missing definition for 
> 'path.db2jar': 
> {code}
> [WARNING] POM for '...B:pom:4.4.0-SNAPSHOT:compile' is invalid. It will be 
> ignored for artifact resolution. Reason: 
> Failed to validate POM 
> [DEBUG] Reason: Failed to validate POM 
> [DEBUG] 
> Validation Errors: 
> [DEBUG] For dependency Dependency {groupId=db2, artifactId=db2, version=8.2, 
> type=jar}: system-scoped dependency 
> must specify an absolute path systemPath. 
> {code}
> I'm using a profiles.xml section like this one: 
> {code}
> <profile> 
>   <id>env-nb</id> 
>   <activation> 
>     <property> 
>       <name>env</name> 
>       <value>nb</value> 
>     </property> 
>   </activation> 
>   <properties> 
>     <path.db2jar>c:/programme/IBM/SQLLIB/java/db2java.zip</path.db2jar> 
>     ... 
>   </properties> 
> </profile> 
> {code}
> which is triggered by -Denv=nb, and this activation is working fine since 
> 'help:effective-pom' is correctly showing me something like 
> {code}
> <properties> 
>   <path.db2jar>c:/programme/IBM/SQLLIB/java/db2java.zip</path.db2jar> 
>   ... 
> </properties> 
> {code}
> So the profiles.xml seems to be evaluated correctly, but the property is not 
> used for validating the POM of dependent modules.
> And yes, when I run Maven without the profiles.xml, but with specifying the 
> property on command line (like '-Dpath.db2jar=...'), all is working fine! But 
> that's not exactly what we want, since profiles are meant to encapsulate 
> those kind of settings... 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to