[ 
http://jira.codehaus.org/browse/MNG-3099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_107214
 ] 

William Ferguson edited comment on MNG-3099 at 9/13/07 12:57 AM:
-----------------------------------------------------------------

Invoking a Mojo that doesn't require a project (ie [EMAIL PROTECTED] false* in 
your Mojo) doesn't load the Profiles defined in LOCAL_HOME settings or 
MAVEN_HOME settings.

In an effort to make this issue as explicit as possible, I have attached 
Plugin-showing-MNG3099.zip

It contains a plugin project (with a Mojo conigured with [EMAIL PROTECTED] 
false*) and local and global settings files.

Put the local and global settings files in the normal place and build and 
install the plugin.

Then from the plugin project folder execute:
{quote}
D:\Modules\maven-test-plugin>mvn 
com.yarris.maven.plugins:maven-test-plugin:profile-props
[INFO] Scanning for projects...
[INFO] snapshot com.yarris.maven.plugins:maven-test-plugin:1.0-SNAPSHOT: 
checking for updates from snapshot
[INFO] 
----------------------------------------------------------------------------
[INFO] Building maven-test-plugin
[INFO]    task-segment: 
[com.yarris.maven.plugins:maven-test-plugin:profile-props] (aggregator-style)
[INFO] 
----------------------------------------------------------------------------
[INFO] [test:profile-props]
[INFO] local-profile-prop=local-profile-prop-value
[INFO] global-profile-prop=global-profile-prop-value
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Sep 13 15:47:18 EST 2007
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------
{quote}

Note that the  local-profile-prop and global-profile-prop have resolved to the 
expected values.

Now execute:
{quote}
D:\Modules\maven-test-plugin>mvn 
com.yarris.maven.plugins:maven-test-plugin:profile-props -f no-pom.xml
[INFO] Scanning for projects...
[INFO] 
----------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: 
[com.yarris.maven.plugins:maven-test-plugin:profile-props] (aggregator-style)
[INFO] 
----------------------------------------------------------------------------
[INFO] [test:profile-props]
[INFO] local-profile-prop=null
[INFO] global-profile-prop=null
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Sep 13 15:48:56 EST 2007
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------
{quote}
Note how local-profile-prop and global-profile-prop no longer have values.

As has been noted the most common example of this is archetype:create which 
requires the remote repository to be explicitly provided on the command line 
via the remoteRepositories System property if you are pulling an archetype from 
somewhere other than central. Eg
{code}
mvn archetype:create -DgroupId=com.yarris -DartifactId=foo-project 
-DarchetypeGroupId=com.yarris.maven.archetype \
  -DarchetypeArtifactId=archetype-standard 
-DremoteRepositories=http://somewhere.com.au:8080/proximity/repository/release
{code}
It should be possible to define an active Profile in either local or global 
settings.xml that defines a remote repository, and have the archetype pulled 
from that repository.

It should also be possible to refer to a property provided by an active Profile
But it occurs for any Mojo that does not require a project.



 was:
Invoking a Mojo that doesn't require a project (ie [EMAIL PROTECTED] false* in 
your Mojo) doesn't load the Profiles defined in LOCAL_HOME settings or 
MAVEN_HOME settings.

In an effort to make this issue as explicit as possible, I have attached 
Plugin-showing-MNG3099.zip

It contains a plugin project (with a Mojo conigured with *requiresProject 
false*) and local and global settings files.

Put the local and global settings files in the normal place and build and 
install the plugin.

Then from the plugin project folder execute:
{code}
D:\Modules\maven-test-plugin>mvn 
com.yarris.maven.plugins:maven-test-plugin:profile-props
[INFO] Scanning for projects...
[INFO] snapshot com.yarris.maven.plugins:maven-test-plugin:1.0-SNAPSHOT: 
checking for updates from snapshot
[INFO] 
----------------------------------------------------------------------------
[INFO] Building maven-test-plugin
[INFO]    task-segment: 
[com.yarris.maven.plugins:maven-test-plugin:profile-props] (aggregator-style)
[INFO] 
----------------------------------------------------------------------------
[INFO] [test:profile-props]
[INFO] local-profile-prop=local-profile-prop-value
[INFO] global-profile-prop=global-profile-prop-value
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Sep 13 15:47:18 EST 2007
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------
{code}

Note that the  local-profile-prop and global-profile-prop have resolved to the 
expected values.

Now execute:
{code}
D:\Modules\maven-test-plugin>mvn 
com.yarris.maven.plugins:maven-test-plugin:profile-props -f no-pom.xml
[INFO] Scanning for projects...
[INFO] 
----------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: 
[com.yarris.maven.plugins:maven-test-plugin:profile-props] (aggregator-style)
[INFO] 
----------------------------------------------------------------------------
[INFO] [test:profile-props]
[INFO] local-profile-prop=null
[INFO] global-profile-prop=null
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Sep 13 15:48:56 EST 2007
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------
{code}
Note how local-profile-prop and global-profile-prop no longer have values.

As has been noted the most common example of this is archetype:create which 
requires the remote repository to be explicitly provided on the command line 
via the remoteRepositories System property if you are pulling an archetype from 
somewhere other than central. Eg
{code}
mvn archetype:create -DgroupId=com.yarris -DartifactId=foo-project 
-DarchetypeGroupId=com.yarris.maven.archetype \
  -DarchetypeArtifactId=archetype-standard 
-DremoteRepositories=http://somewhere.com.au:8080/proximity/repository/release
{code}
It should be possible to define an active Profile in either local or global 
settings.xml that defines a remote repository, and have the archetype pulled 
from that repository.

It should also be possible to refer to a property provided by an active Profile
But it occurs for any Mojo that does not require a project.


> Profiles ignored when working with non-projects (such as archetype:create)
> --------------------------------------------------------------------------
>
>                 Key: MNG-3099
>                 URL: http://jira.codehaus.org/browse/MNG-3099
>             Project: Maven 2
>          Issue Type: Bug
>            Reporter: Joakim Erdfelt
>            Assignee: John Casey
>            Priority: Blocker
>             Fix For: 2.1
>
>         Attachments: MNG-2261-2.patch, MNG-2261.patch, 
> Plugin-showing-MNG3099.zip
>
>
> Several conditions have to be met to show this bug.
> 1) Be in an environment that does not have access to repo1.maven.org, (such 
> as a corporate environment)
> 2) Have no content in your local repository (a fresh install of maven 2.0.4)
> 3) Attempt to use a plugin that has no project requirement (such as 
> archetype:create)
> The plugin fails because access to repo1.maven.org cannot be accessed.
> Recommended solution:
> Create a settings.xml profile that changes the location of the 'central' 
> repository to point to an internal resource (such as a maven-proxy 
> installation).
> <settings>
>   <profiles>
>     <profile>
>       <id>use_internal</id>
>       <repositories>
>         <repository>
>           <id>central</id>
>           <name>Internal Central Repository</name>
>           <url>http://repo.internal.com/maven2</url>
>           <releases>
>             <enabled>true</enabled>
>           </releases>
>           <snapshots>
>             <enabled>true</enabled>
>           </snapshots>
>         </repository>
>       </repositories>
>       <pluginRepositories>
>         <pluginRepository>
>           <id>central</id>
>           <name>Internal Central Repository</name>
>           <url>http://repo.internal.com/maven2</url>
>           <releases>
>             <enabled>true</enabled>
>           </releases>
>           <snapshots>
>             <enabled>true</enabled>
>           </snapshots>
>         </pluginRepository>
>       </pluginRepositories>
>     </profile>
>   </profiles>
>   <activeProfiles>
>     <activeProfile>use_internal</activeProfile>
>   </activeProfiles>
> </settings>
> Try again.
> Still fails.
> The reason is that the default behaviour for non-project execution is to use 
> the maven super pom, however there is a bug with that flow that  does not 
> allow for the merging of the settings.xml profiles.

-- 
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