You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "wolfgang häfelinger (JIRA)" <ji...@codehaus.org> on 2011/02/22 14:31:23 UTC

[jira] Created: (MNG-5022) Unable to use a Mojo with a setter

Unable to use a Mojo with a setter
----------------------------------

                 Key: MNG-5022
                 URL: http://jira.codehaus.org/browse/MNG-5022
             Project: Maven 2 & 3
          Issue Type: Bug
          Components: Documentation:  General, Plugin API, Plugin Requests, Plugins and Lifecycle
    Affects Versions: 2.2.1
         Environment: $ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_22
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"

            Reporter: wolfgang häfelinger
            Priority: Critical


According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").

/**
 * @goal echo
 * @requiresProject false
 */
public class EchoMojo extends AbstractMojo {
	private String msg;
	
	/**
	 * @parameter expression="${echo.message}" 
	 */
	public void setMessage(String message) {
		this.msg = message;
	}
	
	public void execute() throws MojoExecutionException,MojoFailureException {
		getLog().info("what now??");
		getLog().info(msg);
		getLog().info("<>");
	}
}

It does not work.

The generated plugin.xml states, that there are *no* parameters for this Mojo:
== plugin.xml ==
..
    <mojo>
      <goal>echo</goal>
      <description></description>
      <requiresDirectInvocation>false</requiresDirectInvocation>
      <requiresProject>false</requiresProject>
      <requiresReports>false</requiresReports>
      <aggregator>false</aggregator>
      <requiresOnline>false</requiresOnline>
      <inheritedByDefault>true</inheritedByDefault>
      <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
      <language>java</language>
      <instantiationStrategy>per-lookup</instantiationStrategy>
      <executionStrategy>once-per-session</executionStrategy>
      <threadSafe>false</threadSafe>
      <parameters/>
    </mojo>
..
==



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

       

[jira] Commented: (MPLUGIN-182) Recognize annotations placed on setters

Posted by "wolfgang häfelinger (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=257246#action_257246 ] 

wolfgang häfelinger commented on MPLUGIN-182:
---------------------------------------------

_Using the preview button or reading the JIRA markup help might help with the formatting._

I would, I would .. reading Maven/Plexus documentation - just to do simple things - keeps me busy.




> Recognize annotations placed on setters
> ---------------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: New Feature
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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

       

[jira] Commented: (MPLUGIN-182) Recognize annotations placed on setters

Posted by "wolfgang häfelinger (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=257256#action_257256 ] 

wolfgang häfelinger commented on MPLUGIN-182:
---------------------------------------------

I suggest to improve documentation to either remove this setter stuff or add at least one example. 

> Recognize annotations placed on setters
> ---------------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: New Feature
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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

       

[jira] Commented: (MPLUGIN-182) Recognize annotations placed on setters

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=257258#action_257258 ] 

Benjamin Bentmann commented on MPLUGIN-182:
-------------------------------------------

Suggested reading: [Guide to Developing Java Plugins, Using Setters|http://maven.apache.org/guides/plugin/guide-java-plugin-development.html#Using_Setters].

> Recognize annotations placed on setters
> ---------------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: New Feature
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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

       

[jira] Commented: (MPLUGIN-182) Recognize annotations placed on setters

Posted by "wolfgang häfelinger (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=257268#action_257268 ] 

wolfgang häfelinger commented on MPLUGIN-182:
---------------------------------------------

Still, a lot more could be said about this. For example, if I have property="p" and there is setP(X x) and setP(Y y) which one will be chosen?

> Recognize annotations placed on setters
> ---------------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: New Feature
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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

       

[jira] Moved: (MPLUGIN-182) Unable to use a Mojo with a setter

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann moved MNG-5022 to MPLUGIN-182:
------------------------------------------------

           Complexity:   (was: Intermediate)
          Component/s:     (was: Plugin Requests)
                           (was: Plugin API)
                           (was: Documentation:  General)
                           (was: Plugins and Lifecycle)
                       Plugin Plugin
                       Java Plugins
    Affects Version/s:     (was: 2.2.1)
                       2.7
           Issue Type: New Feature  (was: Bug)
                  Key: MPLUGIN-182  (was: MNG-5022)
              Project: Maven 2.x Plugin Tools  (was: Maven 2 & 3)

> Unable to use a Mojo with a setter
> ----------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: New Feature
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>            Priority: Critical
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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

       

[jira] Updated: (MPLUGIN-182) Improve documentation of annotations on setters.

Posted by "Benson Margulies (JIRA)" <ji...@codehaus.org>.
     [ https://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benson Margulies updated MPLUGIN-182:
-------------------------------------

    Issue Type: Improvement  (was: New Feature)
       Summary: Improve documentation of annotations on setters.  (was: Recognize annotations placed on setters)

> Improve documentation of annotations on setters.
> ------------------------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: https://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: Improvement
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] Updated: (MPLUGIN-182) Recognize annotations placed on setters

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann updated MPLUGIN-182:
--------------------------------------

    Priority: Major  (was: Critical)
     Summary: Recognize annotations placed on setters  (was: Unable to use a Mojo with a setter)

> Recognize annotations placed on setters
> ---------------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: New Feature
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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

       

[jira] Commented: (MPLUGIN-182) Recognize annotations placed on setters

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=257231#action_257231 ] 

Benjamin Bentmann commented on MPLUGIN-182:
-------------------------------------------

Using the preview button or reading the JIRA markup help might help with the formatting.

Regarding the setters, the annotations have curently to be placed on the fields, the setters will be called at runtime when present but are not scanned for annotations.

> Recognize annotations placed on setters
> ---------------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: New Feature
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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

       

[jira] Commented: (MPLUGIN-182) Recognize annotations placed on setters

Posted by "wolfgang häfelinger (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MPLUGIN-182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=257254#action_257254 ] 

wolfgang häfelinger commented on MPLUGIN-182:
---------------------------------------------

Here is then a working example:
{code:java}
/**
 * @goal echo
 * @requiresProject false
 */
public class EchoMojo extends AbstractMojo {
	
	/**
         * Notice that I changed field msg to be of type StringBuffer. Would that
         * matter for our getter signature? It turns out, that only the field's 
         * name matters!
         *
         * I added this alias cause I was hoping that this would change the setter
         * from setMsg() to setMessage(). Helas, this does not work.
         *
	 * @parameter alias="message" expression="${echo.message}" 
	 */
	
	private StringBuffer msg;
	
        /* this setter is not used by Maven/Plexus .. regardless how much you twist
         * Maven/Plexus configuration.
         */
	public void setMessage(String message) {
		this.msg = via("setMessage", message);
	}

        /* This setter is used rather than field injection. This works (somehow)
         * despite that setMsg() expects a String rather than a StringBuffer.
         */

	public void setMsg(String m) {
		this.msg = via("setMsg", m);
	}

        /* small helper */
	private StringBuffer via(String method, String msg) {
		return new StringBuffer(String.format("%s [via %s(..)]", msg, method));
	}
	
	
	public void execute() throws MojoExecutionException,MojoFailureException {
		getLog().info("what now??");
		getLog().info(msg.toString());
		getLog().info("<>");
	}
}
{code}

On execution, this will eventually print a log message like 
{code}
mvn myplugin:echo -Decho.message="I love good old Ant"
[INFO] what now??
[INFO] I love good old Ant [via setMsg(..)]
[INFO] <>
{code}



> Recognize annotations placed on setters
> ---------------------------------------
>
>                 Key: MPLUGIN-182
>                 URL: http://jira.codehaus.org/browse/MPLUGIN-182
>             Project: Maven 2.x Plugin Tools
>          Issue Type: New Feature
>          Components: Java Plugins, Plugin Plugin
>    Affects Versions: 2.7
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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

       

[jira] Commented: (MNG-5022) Unable to use a Mojo with a setter

Posted by "wolfgang häfelinger (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-5022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=257229#action_257229 ] 

wolfgang häfelinger commented on MNG-5022:
------------------------------------------

What do I have to do to keep the format of pasted (Java) source code?? Now it looks really ugly..

> Unable to use a Mojo with a setter
> ----------------------------------
>
>                 Key: MNG-5022
>                 URL: http://jira.codehaus.org/browse/MNG-5022
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Documentation:  General, Plugin API, Plugin Requests, Plugins and Lifecycle
>    Affects Versions: 2.2.1
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>            Priority: Critical
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> == plugin.xml ==
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> ==

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

       

[jira] Updated: (MNG-5022) Unable to use a Mojo with a setter

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNG-5022?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann updated MNG-5022:
-----------------------------------

    Description: 
According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
{code:java}
/**
 * @goal echo
 * @requiresProject false
 */
public class EchoMojo extends AbstractMojo {
	private String msg;
	
	/**
	 * @parameter expression="${echo.message}" 
	 */
	public void setMessage(String message) {
		this.msg = message;
	}
	
	public void execute() throws MojoExecutionException,MojoFailureException {
		getLog().info("what now??");
		getLog().info(msg);
		getLog().info("<>");
	}
}
{code}
It does not work.

The generated plugin.xml states, that there are *no* parameters for this Mojo:
{code:xml}
..
    <mojo>
      <goal>echo</goal>
      <description></description>
      <requiresDirectInvocation>false</requiresDirectInvocation>
      <requiresProject>false</requiresProject>
      <requiresReports>false</requiresReports>
      <aggregator>false</aggregator>
      <requiresOnline>false</requiresOnline>
      <inheritedByDefault>true</inheritedByDefault>
      <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
      <language>java</language>
      <instantiationStrategy>per-lookup</instantiationStrategy>
      <executionStrategy>once-per-session</executionStrategy>
      <threadSafe>false</threadSafe>
      <parameters/>
    </mojo>
..
{code}



  was:
According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").

/**
 * @goal echo
 * @requiresProject false
 */
public class EchoMojo extends AbstractMojo {
	private String msg;
	
	/**
	 * @parameter expression="${echo.message}" 
	 */
	public void setMessage(String message) {
		this.msg = message;
	}
	
	public void execute() throws MojoExecutionException,MojoFailureException {
		getLog().info("what now??");
		getLog().info(msg);
		getLog().info("<>");
	}
}

It does not work.

The generated plugin.xml states, that there are *no* parameters for this Mojo:
== plugin.xml ==
..
    <mojo>
      <goal>echo</goal>
      <description></description>
      <requiresDirectInvocation>false</requiresDirectInvocation>
      <requiresProject>false</requiresProject>
      <requiresReports>false</requiresReports>
      <aggregator>false</aggregator>
      <requiresOnline>false</requiresOnline>
      <inheritedByDefault>true</inheritedByDefault>
      <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
      <language>java</language>
      <instantiationStrategy>per-lookup</instantiationStrategy>
      <executionStrategy>once-per-session</executionStrategy>
      <threadSafe>false</threadSafe>
      <parameters/>
    </mojo>
..
==




> Unable to use a Mojo with a setter
> ----------------------------------
>
>                 Key: MNG-5022
>                 URL: http://jira.codehaus.org/browse/MNG-5022
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Documentation:  General, Plugin API, Plugin Requests, Plugins and Lifecycle
>    Affects Versions: 2.2.1
>         Environment: $ mvn -version
> Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
> Java version: 1.6.0_22
> Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
> Default locale: en_US, platform encoding: MacRoman
> OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
>            Reporter: wolfgang häfelinger
>            Priority: Critical
>
> According to documentation (Maven Book, p405), the following example should work ("You can also use these annotations on public setter methods, [..]").
> {code:java}
> /**
>  * @goal echo
>  * @requiresProject false
>  */
> public class EchoMojo extends AbstractMojo {
> 	private String msg;
> 	
> 	/**
> 	 * @parameter expression="${echo.message}" 
> 	 */
> 	public void setMessage(String message) {
> 		this.msg = message;
> 	}
> 	
> 	public void execute() throws MojoExecutionException,MojoFailureException {
> 		getLog().info("what now??");
> 		getLog().info(msg);
> 		getLog().info("<>");
> 	}
> }
> {code}
> It does not work.
> The generated plugin.xml states, that there are *no* parameters for this Mojo:
> {code:xml}
> ..
>     <mojo>
>       <goal>echo</goal>
>       <description></description>
>       <requiresDirectInvocation>false</requiresDirectInvocation>
>       <requiresProject>false</requiresProject>
>       <requiresReports>false</requiresReports>
>       <aggregator>false</aggregator>
>       <requiresOnline>false</requiresOnline>
>       <inheritedByDefault>true</inheritedByDefault>
>       <implementation>org.epo.common.maven.plugins.epo.EchoMojo</implementation>
>       <language>java</language>
>       <instantiationStrategy>per-lookup</instantiationStrategy>
>       <executionStrategy>once-per-session</executionStrategy>
>       <threadSafe>false</threadSafe>
>       <parameters/>
>     </mojo>
> ..
> {code}

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