maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ovidio Mallo <ovid...@student.ethz.ch>
Subject Re: creating a new project with the MavenEmbedder
Date Sun, 04 Jun 2006 14:51:36 GMT
Hi,

I'm attaching a patch which tries to solve the issue with the basedir
discussed in this thread. The value of the ${basedir} expression is
thereby computed by one of the following fallbacks (in the given order):

1. If the goal being executed is attached to a project, take the directory where
    the POM file of the project resides as the ${basedir}.
2. If a basedir has been specified on the MavenExecutionRequest, take this as
    the ${basedir}.
3. Otherwise, take System.getProperty( "user.dir" ) as the ${basedir}.

The patch merely introduces the fallback 2. In the current implementation,
1. and 3. are already used.

Before taking any further step, I wanted to ask whether the above behavior would
be OK. So, if anyone is willing to have a brief look at the patch (it's very
short), that would be great as I'm still very new to the code.
Thanks a lot in advance!

BTW: Combining this patch with Hermod's one for the archetype plugin should
      solve the problem of the plugin not respecting the specified basedir when
      creating a new project.

Greets,
   Ovidio



hermod.opstvedt@dnbnor.no wrote:
> Hi
> 
> Something must be wrong in another place. The eclipse:eclipse goal excutes ok with the
supplied (i.e correct) basedir, but the MavenArchetypeMojo for some reason is supplied the
working directory, which is not what is supplied in the call.
> 
> Here is the patch :
> 
> Index: MavenArchetypeMojo.java
> ===================================================================
> --- MavenArchetypeMojo.java	(revisjon 410213)
> +++ MavenArchetypeMojo.java	(arbeidskopi)
> @@ -33,6 +33,7 @@
>  import java.util.HashMap;
>  import java.util.List;
>  import java.util.Map;
> +import java.io.File;
>  
>  /**
>   * The archetype creation goal looks for an archetype with a given groupId, artifactId,
and
> @@ -122,6 +123,12 @@
>       */
>      private MavenProject project;
>  
> +    /**
> +     * @parameter expression="${basedir}"
> +     */
> +    private File basedir;
> +
> +
>      public void execute()
>          throws MojoExecutionException
>      {
> @@ -143,8 +150,6 @@
>              groupId = project.getGroupId();
>          }
>  
> -        String basedir = System.getProperty( "user.dir" );
> -
>          if ( packageName == null )
>          {
>              getLog().info( "Defaulting package to group ID: " + groupId );
> @@ -155,7 +160,7 @@
>          // TODO: context mojo more appropriate?
>          Map map = new HashMap();
>  
> -        map.put( "basedir", basedir );
> +        map.put( "basedir", basedir.getAbsolutePath() );
>  
>          map.put( "package", packageName );
>   
> 
> -----Original Message-----
> From: Trygve Laugstøl [mailto:trygvis@apache.org]
> Sent: Friday, June 02, 2006 9:26 AM
> To: Maven Developers List
> Subject: Re: creating a new project with the MavenEmbedder
> 
> 
> hermod.opstvedt@dnbnor.no wrote:
> 
>>Hi
>>
>>Have not had the time before now.
>>
>>It still does not work. The basedir is still set to the current directory.
> 
> 
> The ${basedir} will be set to the value you set in the embedder, this is 
> working for me in my IDEA plugin where I use the embedder.
> 
> Can you include the patch from the assembly plugin so I can see what you 
> did?
> 
> --
> Trygve
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 
> 
> 
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> 
> This email with attachments is solely for the use of the individual or
> entity to whom it is addressed. Please also be aware that DnB NOR cannot
> accept any payment orders or other legally binding correspondence with
> customers as a part of an email. 
> 
> This email message has been virus checked by the anti virus programs used
> in the DnB NOR Group.
> 
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 




Mime
View raw message