What was wrong with

<properties>
  <my.username>${user.name}</my.username>
</properties>

?


On 3 April 2013 12:32, <khmarba...@codehaus.org> wrote:

> **
>  Revision 18159 <http://fisheye.codehaus.org/changelog/mojo/?cs=18159>
> Author khmarbaise Date 2013-04-03 06:32:37 -0500 (Wed, 03 Apr 2013) Log
> Message
>
> [MBUILDHELPER-59]
>   - Added goal to get the currently logged in user.
>
> Modified Paths
>
>    -
>    
> trunk/mojo/build-helper-maven-plugin/src/main/java/org/codehaus/mojo/buildhelper/AbstractDefinePropertyMojo.java<#13dcfab8d176e645_trunkmojobuildhelpermavenpluginsrcmainjavaorgcodehausmojobuildhelperAbstractDefinePropertyMojojava>
>    - 
> trunk/mojo/build-helper-maven-plugin/src/site/apt/index.apt<#13dcfab8d176e645_trunkmojobuildhelpermavenpluginsrcsiteaptindexapt>
>    - 
> trunk/mojo/build-helper-maven-plugin/src/site/apt/usage.apt.vm<#13dcfab8d176e645_trunkmojobuildhelpermavenpluginsrcsiteaptusageaptvm>
>
> Added Paths
>
>    - trunk/mojo/build-helper-maven-plugin/src/it/username/
>    -
>    
> trunk/mojo/build-helper-maven-plugin/src/it/username/invoker.properties<#13dcfab8d176e645_trunkmojobuildhelpermavenpluginsrcitusernameinvokerproperties>
>    - 
> trunk/mojo/build-helper-maven-plugin/src/it/username/pom.xml<#13dcfab8d176e645_trunkmojobuildhelpermavenpluginsrcitusernamepomxml>
>    - 
> trunk/mojo/build-helper-maven-plugin/src/it/username/verify.groovy<#13dcfab8d176e645_trunkmojobuildhelpermavenpluginsrcitusernameverifygroovy>
>    -
>    
> trunk/mojo/build-helper-maven-plugin/src/main/java/org/codehaus/mojo/buildhelper/UserNameMojo.java<#13dcfab8d176e645_trunkmojobuildhelpermavenpluginsrcmainjavaorgcodehausmojobuildhelperUserNameMojojava>
>
>  Diff
> Added:
> trunk/mojo/build-helper-maven-plugin/src/it/username/invoker.properties (0
> => 18159)
>
> --- trunk/mojo/build-helper-maven-plugin/src/it/username/invoker.properties   
>                         (rev 0)
> +++ trunk/mojo/build-helper-maven-plugin/src/it/username/invoker.properties   
> 2013-04-03 11:32:37 UTC (rev 18159)@@ -0,0 +1,2 @@+invoker.goals = test
> +invoker.buildResult = success
>
>  Added: trunk/mojo/build-helper-maven-plugin/src/it/username/pom.xml (0
> => 18159)
>
> --- trunk/mojo/build-helper-maven-plugin/src/it/username/pom.xml              
>                 (rev 0)
> +++ trunk/mojo/build-helper-maven-plugin/src/it/username/pom.xml      
> 2013-04-03 11:32:37 UTC (rev 18159)@@ -0,0 +1,59 @@+<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>
> +
> +  <groupId>org.codehaus.mojo</groupId>
> +  <artifactId>build-helper-maven-plugin-username-it</artifactId>
> +  <version>1.0-SNAPSHOT</version>
> +
> +  <name>build-helper-maven-plugin-username-it</name>
> +
> +
> +  <build>
> +
> +    <defaultGoal>package</defaultGoal>
> +
> +    <plugins>
> +
> +
> +      <plugin>
> +
> +         <groupId>@project.groupId@</groupId>
> +        <artifactId>@project.artifactId@</artifactId>
> +        <version>@project.version@</version>
> +        <executions>
> +
> +          <execution>
> +            <id>username-execution</id>
> +            <goals>
> +              <goal>username</goal>
> +            </goals>
> +          </execution>
> +        </executions>
> +      </plugin>
> +
> +       <plugin>
> +
> +        <artifactId>maven-antrun-plugin</artifactId>
> +        <executions>
> +          <execution>
> +            <id>echo-username</id>
> +            <phase>test</phase>
> +            <goals>
> +              <goal>run</goal>
> +            </goals>
> +            <configuration>
> +              <tasks>
> +                <echo>username=${username}</echo>
> +              </tasks>
> +            </configuration>
> +          </execution>
> +        </executions>
> +      </plugin>
> +
> +    </plugins>
> +
> +
> +  </build>
> +
> +</project>
>
>  Added:
> trunk/mojo/build-helper-maven-plugin/src/it/username/verify.groovy (0 =>
> 18159)
>
> --- trunk/mojo/build-helper-maven-plugin/src/it/username/verify.groovy        
>                         (rev 0)
> +++ trunk/mojo/build-helper-maven-plugin/src/it/username/verify.groovy        
> 2013-04-03 11:32:37 UTC (rev 18159)@@ -0,0 +1,9 @@+File file = new File( 
> basedir, "build.log" );
> +assert file.exists();
> +
> +String text = file.getText("utf-8");
> +
> +assert text =~ /\[DEBUG\] define property username = "(.*)"/
> +
> +assert text.contains("[echo] username=")
> +return true;
>
>  Modified:
> trunk/mojo/build-helper-maven-plugin/src/main/java/org/codehaus/mojo/buildhelper/AbstractDefinePropertyMojo.java
> (18158 => 18159)
>
> --- 
> trunk/mojo/build-helper-maven-plugin/src/main/java/org/codehaus/mojo/buildhelper/AbstractDefinePropertyMojo.java
>   2013-04-02 20:48:36 UTC (rev 18158)
> +++ 
> trunk/mojo/build-helper-maven-plugin/src/main/java/org/codehaus/mojo/buildhelper/AbstractDefinePropertyMojo.java
>   2013-04-03 11:32:37 UTC (rev 18159)@@ -46,9 +46,9 @@          
> project.getProperties().put( name, value );     }-    +     /**-     * Get 
> the current project instance. +     * Get the current project instance.      
> *       * @return the project      */
>
>  Added:
> trunk/mojo/build-helper-maven-plugin/src/main/java/org/codehaus/mojo/buildhelper/UserNameMojo.java
> (0 => 18159)
>
> --- 
> trunk/mojo/build-helper-maven-plugin/src/main/java/org/codehaus/mojo/buildhelper/UserNameMojo.java
>                                 (rev 0)
> +++ 
> trunk/mojo/build-helper-maven-plugin/src/main/java/org/codehaus/mojo/buildhelper/UserNameMojo.java
>         2013-04-03 11:32:37 UTC (rev 18159)@@ -0,0 +1,57 @@+package 
> org.codehaus.mojo.buildhelper;
> +
> +/*
> + * The MIT License
> + *
> + * Copyright (c) 2004, The Codehaus
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a 
> copy of
> + * this software and associated documentation files (the "Software"), to 
> deal in
> + * the Software without restriction, including without limitation the rights 
> to
> + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
> copies
> + * of the Software, and to permit persons to whom the Software is furnished 
> to do
> + * so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included 
> in all
> + * copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
> THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
> THE
> + * SOFTWARE.
> + */
> +
> +import org.apache.maven.plugin.MojoExecutionException;
> +import org.apache.maven.plugins.annotations.LifecyclePhase;
> +import org.apache.maven.plugins.annotations.Mojo;
> +import org.apache.maven.plugins.annotations.Parameter;
> +
> +/**
> + * Retrieve current username and place it under a configurable project 
> property
> + *
> + * @author <a href="k...@soebes.de">Karl-Heinz Marbaise</a>
> + * @since 1.9
> + */
> +@Mojo( name = "username", defaultPhase = LifecyclePhase.VALIDATE, threadSafe 
> = true )
> +public class UserNameMojo
> +    extends AbstractDefinePropertyMojo
> +{
> +
> +    /**
> +     * The name of the property in which to store the local user name.
> +     */
> +    @Parameter( defaultValue = "username" )
> +    private String userNameProperty;
> +
> +    /**
> +     * to be called from Maven.
> +     */
> +    public void execute()
> +        throws MojoExecutionException
> +    {
> +        defineProperty( this.userNameProperty, System.getProperty( 
> "user.name" ) );
> +    }
> +}
>
>  Modified: trunk/mojo/build-helper-maven-plugin/src/site/apt/index.apt
> (18158 => 18159)
>
> --- trunk/mojo/build-helper-maven-plugin/src/site/apt/index.apt       
> 2013-04-02 20:48:36 UTC (rev 18158)
> +++ trunk/mojo/build-helper-maven-plugin/src/site/apt/index.apt       
> 2013-04-03 11:32:37 UTC (rev 18159)@@ -71,6 +71,8 @@    * 
> {{{./os-mojo.html}build-helper:os}} Retrieve information about current 
> operation system. +  * {{{./username-mojo.html}build-helper:username}} 
> Retrieve information about currently logged in user.
> + * Usage    Instructions on how to use the Build Helper Maven Plugin can be 
> found on the {{{./usage.html}usage page}}.
>
>  Modified: trunk/mojo/build-helper-maven-plugin/src/site/apt/usage.apt.vm
> (18158 => 18159)
>
> --- trunk/mojo/build-helper-maven-plugin/src/site/apt/usage.apt.vm    
> 2013-04-02 20:48:36 UTC (rev 18158)
> +++ trunk/mojo/build-helper-maven-plugin/src/site/apt/usage.apt.vm    
> 2013-04-03 11:32:37 UTC (rev 18159)@@ -691,3 +691,37 @@  
> build.env.sun.management.compiler -------------------+
> +* Retrieve Currently logged in user.
> +
> +  The <<<username>>> goal can be used to get the currently logged in user 
> name.
> +
> +-------------------
> +<project>
> +  ...
> +  <build>
> +    <plugins>
> +      <plugin>
> +        <groupId>org.codehaus.mojo</groupId>
> +        <artifactId>build-helper-maven-plugin</artifactId>
> +        <version>${project.version}</version>
> +        <executions>
> +          <execution>
> +            <id>get-username</id>
> +            <goals>
> +              <goal>username</goal>
> +            </goals>
> +            <configuration>
> +              <!-- if not given, 'username' name is used -->
> +              <userNameProperty>my.username</userNameProperty>
> +            </configuration>
> +          </execution>
> +        </executions>
> +      </plugin>
> +    </plugins>
> +  </build>
> +  ...
> +</project>
> +-------------------
> +
> +  []
>
>   ------------------------------
>
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
>

Reply via email to