You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Martin M <ma...@qfs.de> on 2007/01/11 13:15:08 UTC

passing custom parameters to a custom compiler-plugin

Hi all,

I implemented a custom compiler-plugin. Now I'd like to pass some parameters
to it, but I don't get it working. My plugin always tells me that the
parameters have null-value. I assume it's possible to pass parameters to a
compiler-plugin, isn't it.

The plugin-code looks like this:


/**
 * custom compiler 
 *
 * @version $Id$
 * @goal compile
 * @phase compile
 * @requiresDependencyResolution compile
 */

public class javamake extends AbstractMojo
{

    /**
     * @parameter 
     **/
    private String testParam

    public void execute() throws MojoExecutionException
    {
        getLog().info("Start compiling, ... with " + testParam);
     }


I'm calling the plugin in my pom.xml like this:



          
           maven-compiler-plugin
           
           c1
           

           
           
           mygroup
           customCompile
           1.0-SNAPSHOT
           
           
          



Ihave also replaced the standard-compiler in maven's components.xml to get
my compiler activated.


   
      org.apache.maven.lifecycle.mapping.LifecycleMapping
      jar
      org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping

      
        
          
            default
            
            
              org.apache.maven.plugins:maven-resources-plugin
:resources
              mygroup:customCompile:1.0-SNAPSHOT:compile
               etc.


Does anyone have a hint, how I could pass my custom parameter?

Thanks in advance!

Regards,
Martin



-- 
View this message in context: http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-plugin-tf2958426s177.html#a8276238
Sent from the Maven - Users mailing list archive at Nabble.com.

Re: passing custom parameters to a custom compiler-plugin

Posted by Martin Moser <ma...@qfs.de>.
I'm sorry,I hope now it's better :-)

Hi all,

 I implemented a custom compiler-plugin. Now I'd like to pass some
 parameters to it, but I don't get it working. My plugin always tells me
 that the parameters have null-value. I assume it's possible to pass
 parameters to a compiler-plugin, isn't it.

 The plugin-code looks like this:


 /**
  * custom compiler
  *
  * @version $Id$
  * @goal compile
  * @phase compile
  * @requiresDependencyResolution compile
  */

 public class javamake extends AbstractMojo
 {

     /**
      * @parameter
      **/
     private String testParam

   public void execute() throws MojoExecutionException
     {
         getLog().info("Start compiling, ... with " + testParam);
      }


 I'm calling the plugin in my pom.xml like this:



           <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
            <testParam>c1</testParam>
            </configuration>

            <dependencies>
            <dependency>
            <groupId>mygroup</groupId>
            <artifactId>customCompile</artifactId>
            <version>1.0-SNAPSHOT</version>
            </dependency>
            </dependencies>
           </plugin>



 I have also replaced the standard-compiler in maven's components.xml to
 get my compiler activated.


    <component>
       <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
       <role-hint>jar</role-hint>

 <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping 
</implementation>
       <configuration>
         <lifecycles>
           <lifecycle>
             <id>default</id>
             <!-- START SNIPPET: jar-lifecycle -->
             <phases>

 <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources
</process-resources>

 <compile>mygroup:customCompile:1.0-SNAPSHOT:compile</compile>
                etc.



Does anyone have a hint, how I could pass my custom parameter?

 Thanks in advance!

Regards,
Martin





--On Donnerstag, Januar 11, 2007 08:29:51 -0800 franz see 
<fr...@gmail.com> wrote:

>
> Good day to you, Martin M,
>
> May I ask you to repost this again. It seems as though your message have
> been made into one long line which makes it hard to read.
>
> Thanks,
> Franz
>
>
> Martin M wrote:
>>
>> Hi all,
>>
>> I implemented a custom compiler-plugin. Now I'd like to pass some
>> parameters to it, but I don't get it working. My plugin always tells me
>> that the parameters have null-value. I assume it's possible to pass
>> parameters to a compiler-plugin, isn't it.
>>
>> The plugin-code looks like this:
>>
>>
>> /**
>>  * custom compiler
>>  *
>>  * @version $Id$
>>  * @goal compile
>>  * @phase compile
>>  * @requiresDependencyResolution compile
>>  */
>>
>> public class javamake extends AbstractMojo
>> {
>>
>>     /**
>>      * @parameter
>>      **/
>>     private String testParam
>>
>>     public void execute() throws MojoExecutionException
>>     {
>>         getLog().info("Start compiling, ... with " + testParam);
>>      }
>>
>>
>> I'm calling the plugin in my pom.xml like this:
>>
>>
>>
>>           <plugin>
>>            <artifactId>maven-compiler-plugin</artifactId>
>>            <configuration>
>>            <testParam>c1</testParam>
>>            </configuration>
>>
>>            <dependencies>
>>            <dependency>
>>            <groupId>mygroup</groupId>
>>            <artifactId>customCompile</artifactId>
>>            <version>1.0-SNAPSHOT</version>
>>            </dependency>
>>            </dependencies>
>>           </plugin>
>>
>>
>>
>> Ihave also replaced the standard-compiler in maven's components.xml to
>> get my compiler activated.
>>
>>
>>    <component>
>>       <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
>>       <role-hint>jar</role-hint>
>>
>> <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMappi
>> ng </implementation>
>>       <configuration>
>>         <lifecycles>
>>           <lifecycle>
>>             <id>default</id>
>>             <!-- START SNIPPET: jar-lifecycle -->
>>             <phases>
>>
>> <process-resources>org.apache.maven.plugins:maven-resources-plugin
>> :resources</process-resources>
>>
>> <compile>mygroup:customCompile:1.0-SNAPSHOT:compile</compile>
>>                etc.
>>
>>
>> Does anyone have a hint, how I could pass my custom parameter?
>>
>> Thanks in advance!
>>
>> Regards,
>> Martin
>>
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-plug
> in-tf2958426s177.html#a8278077 Sent from the Maven - Users mailing list
> archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>



--
Martin Moser

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: passing custom parameters to a custom compiler-plugin

Posted by Martin Moser <ma...@qfs.de>.
Hi Franz,

thank you for your detailed explanation. Now I can understand, what you've 
meant :-)

You are completely right. The usage of maven-compiler plugin was the 
reason, because the parameter "testParam" wasn't used, which is ok, because 
the parameter isn't defined for that plugin.

So my second try, using the plugin directly, is the proper way of 
integrating it.


In the meantime I've been able to simplify the syntax in pom.xml as it was 
in my previous posts.

1.) Change components.xml
	For the role-hint "jar", I activated the custom compiler again. Like I did 
in my first post.

2.) In pom.xml I used the plugin:

 <plugin>
   <groupId>mygroup</groupId>
   <artifactId>customCompile</artifactId>
   <version>1.0-SNAPSHOT</version>
   <configuration>
         <testParam>testValue</testParam>
   </configuration>
 </plugin>


Now it works, like I expect.


Regards,
Martin

--On Samstag, Januar 13, 2007 01:13:59 -0800 franz see 
<fr...@gmail.com> wrote:

>
> Good day to you, Martin M.,
>
> Yes. I believe that your plugin does get executed ( since you did mention
> that you were getting null in your test param, meaning that it did run :)
> ). However, that does not mean that it is what you were configuring.
>
> Ok, you played around with the built-in lifecycle so that your custom
> compiler is ran, which I think you accomplished.
>
> Next, you tried setting the value of your test parameter which you failed
> ( since you said it's always null ). My suggestion then is that to use the
> whole artifact key ( groupId:artifactId:version ) during the
> configuration. Just like what you did with this
>
> <plugin>
>   <groupId>mygroup</groupId>
>   <artifactId>customCompile</artifactId>
>   <version>1.0-SNAPSHOT</version>
>   <executions>
>     <execution>
>       <id>custom-compilation</id>
>       <phase>compile</phase>
>       <configuration>
>         <testParam>testValue</testParam>
>       </configuration>
>       <goals>
>         <goal>compile</goal>
>       </goals>
>     </execution>
>   </executions>
> </plugin>
>
> Notice that in the snippet above, you mentioned that you're setting the
> testParam value of mygroup:customCompile:1.0-SNAPSHOT. While in the
> snippet below
>
> <plugin>
>   <artifactId>maven-compiler-plugin</artifactId>
>   <configuration>
>     <testParam>c1</testParam>
>   </configuration>
>
>   <dependencies>
>     <dependency>
>       <groupId>mygroup</groupId>
>       <artifactId>customCompile</artifactId>
>       <version>1.0-SNAPSHOT</version>
>     </dependency>
>   </dependencies>
> </plugin>
>
> you were configuring the testParam of a plugin with the artifactId
> maven-compiler-plugin ( which could be
> org.apache.maven.plugins:maven-compiler-plugin:RELEASE or some custom
> maven-compiler-plugin that you made ).
>
> Thus, in the post you made in [1], you were configuring some plugin with
> an artifactId maven-compiler-plugin eventhough you were running
> mygroup:customCompile:1.0-SNAPSHOT.
>
> Thanks,
> Franz
>
> [1]
> http://www.nabble.com/Re%3A-passing-custom-parameters-to-a-custom-compile
> r-plugin-p8281436s177.html
>
>
> Martin M wrote:
>>
>> Hi all,
>>
>> @Jörg
>> I tried your suggestion, but it didn't work. As I understood the
>> documentation the expression-syntax is for properties and not for
>> parameters.
>>
>> @Franz
>> During compile phase, my compiler is definitely used. I can see the
>> output  and the execution of the goal in maven's output.
>> The only problem is the parameter passing.
>>
>> In the meantime I found a workaround. But I would like to know the
>> proper  way to implement such a plugin.
>>
>> As workaround I did following:
>>
>> .) Disable the compiler in the components.xml. So no <compile> tag is
>> defined for <role-hint>jar</role-hint>
>>
>> .) Call the plugin in the pom.xml like this:
>>  <plugin>
>>            <groupId>mygroup</groupId>
>>            <artifactId>customCompile</artifactId>
>>            <version>1.0-SNAPSHOT</version>
>>            <executions>
>>            <execution>
>>            <id>custom-compilation</id>
>>            <phase>compile</phase>
>>            <configuration>
>>            <testParam>testValue</testParam>
>>              </configuration>
>>            <goals>
>>            <goal>compile</goal>
>>            </goals>
>>            </execution>
>>            </executions>
>> </plugin>
>>
>>
>>
>>
>>
>> Regards,
>> Martin
>>
>> --On Donnerstag, Januar 11, 2007 23:04:40 -0800 franz see
>> <fr...@gmail.com> wrote:
>>
>>>
>>> Good day,
>>>
>>> Actually, using @parameter only should be sufficient for it to be
>>> configured via the pom. The @expression is used for setting the
>>> parameter via commandline.
>>>
>>> Anyway, Martin M., try specifying in your plugin tag the groupId and
>>> version as well. It might still be trying to configure
>>> org.apache.maven.plugins:maven-compiler-plugin:RELEASE instead of your
>>> custom compiler plugin.
>>>
>>> Cheers,
>>> Franz
>>>
>>>
>>> Jörg Schaible wrote:
>>>>
>>>> Hi Martin,
>>>>
>>>>
>>>> there's no automation. You need to provide the expression for the
>>>> parameter to initialize:
>>>>
>>>> [snip]
>>>>
>>>>      /**
>>>>       * @parameter expression="${testParam}"
>>>>       **/
>>>>      private String testParam
>>>>
>>>> [snip]
>>>>
>>>> Within the expression you can also address other parts of the POM ...
>>>> another typical parameter is:
>>>>
>>>> 	/**
>>>> 	 * The directory for the generated file.
>>>> 	 *
>>>> 	 * @parameter expression="${project.build.directory}"
>>>> 	 * @required
>>>> 	 */
>>>> 	private String outputDirectory;
>>>>
>>>> - Jörg
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>>> For additional commands, e-mail: users-help@maven.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-pl
>>> ug in-tf2958426s177.html#a8292757 Sent from the Maven - Users mailing
>>> list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>
>>
>>
>> --
>> Martin Moser
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-plug
> in-tf2958426s177.html#a8312544 Sent from the Maven - Users mailing list
> archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>



--
Martin Moser

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: passing custom parameters to a custom compiler-plugin

Posted by franz see <fr...@gmail.com>.
Good day to you, Martin M.,

Yes. I believe that your plugin does get executed ( since you did mention
that you were getting null in your test param, meaning that it did run :) ).
However, that does not mean that it is what you were configuring.

Ok, you played around with the built-in lifecycle so that your custom
compiler is ran, which I think you accomplished. 

Next, you tried setting the value of your test parameter which you failed (
since you said it's always null ). My suggestion then is that to use the
whole artifact key ( groupId:artifactId:version ) during the configuration.
Just like what you did with this

<plugin>
  <groupId>mygroup</groupId>
  <artifactId>customCompile</artifactId>
  <version>1.0-SNAPSHOT</version>
  <executions>
    <execution>
      <id>custom-compilation</id>
      <phase>compile</phase>
      <configuration>
        <testParam>testValue</testParam>
      </configuration>
      <goals>
        <goal>compile</goal>
      </goals>
    </execution>
  </executions>
</plugin> 

Notice that in the snippet above, you mentioned that you're setting the
testParam value of mygroup:customCompile:1.0-SNAPSHOT. While in the snippet
below

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <testParam>c1</testParam>
  </configuration>

  <dependencies>
    <dependency>
      <groupId>mygroup</groupId>
      <artifactId>customCompile</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
</plugin>

you were configuring the testParam of a plugin with the artifactId
maven-compiler-plugin ( which could be
org.apache.maven.plugins:maven-compiler-plugin:RELEASE or some custom
maven-compiler-plugin that you made ).

Thus, in the post you made in [1], you were configuring some plugin with an
artifactId maven-compiler-plugin eventhough you were running
mygroup:customCompile:1.0-SNAPSHOT.

Thanks,
Franz

[1]
http://www.nabble.com/Re%3A-passing-custom-parameters-to-a-custom-compiler-plugin-p8281436s177.html


Martin M wrote:
> 
> Hi all,
> 
> @Jörg
> I tried your suggestion, but it didn't work. As I understood the 
> documentation the expression-syntax is for properties and not for 
> parameters.
> 
> @Franz
> During compile phase, my compiler is definitely used. I can see the output 
> and the execution of the goal in maven's output.
> The only problem is the parameter passing.
> 
> In the meantime I found a workaround. But I would like to know the proper 
> way to implement such a plugin.
> 
> As workaround I did following:
> 
> .) Disable the compiler in the components.xml. So no <compile> tag is 
> defined for <role-hint>jar</role-hint>
> 
> .) Call the plugin in the pom.xml like this:
>  <plugin>
>            <groupId>mygroup</groupId>
>            <artifactId>customCompile</artifactId>
>            <version>1.0-SNAPSHOT</version>
>            <executions>
>            <execution>
>            <id>custom-compilation</id>
>            <phase>compile</phase>
>            <configuration>
>            <testParam>testValue</testParam>
>              </configuration>
>            <goals>
>            <goal>compile</goal>
>            </goals>
>            </execution>
>            </executions>
> </plugin>
> 
> 
> 
> 
> 
> Regards,
> Martin
> 
> --On Donnerstag, Januar 11, 2007 23:04:40 -0800 franz see 
> <fr...@gmail.com> wrote:
> 
>>
>> Good day,
>>
>> Actually, using @parameter only should be sufficient for it to be
>> configured via the pom. The @expression is used for setting the parameter
>> via commandline.
>>
>> Anyway, Martin M., try specifying in your plugin tag the groupId and
>> version as well. It might still be trying to configure
>> org.apache.maven.plugins:maven-compiler-plugin:RELEASE instead of your
>> custom compiler plugin.
>>
>> Cheers,
>> Franz
>>
>>
>> Jörg Schaible wrote:
>>>
>>> Hi Martin,
>>>
>>>
>>> there's no automation. You need to provide the expression for the
>>> parameter to initialize:
>>>
>>> [snip]
>>>
>>>      /**
>>>       * @parameter expression="${testParam}"
>>>       **/
>>>      private String testParam
>>>
>>> [snip]
>>>
>>> Within the expression you can also address other parts of the POM ...
>>> another typical parameter is:
>>>
>>> 	/**
>>> 	 * The directory for the generated file.
>>> 	 *
>>> 	 * @parameter expression="${project.build.directory}"
>>> 	 * @required
>>> 	 */
>>> 	private String outputDirectory;
>>>
>>> - Jörg
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-plug
>> in-tf2958426s177.html#a8292757 Sent from the Maven - Users mailing list
>> archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
> 
> 
> 
> --
> Martin Moser
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-plugin-tf2958426s177.html#a8312544
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: passing custom parameters to a custom compiler-plugin

Posted by Martin Moser <ma...@qfs.de>.
Hi all,

@Jörg
I tried your suggestion, but it didn't work. As I understood the 
documentation the expression-syntax is for properties and not for 
parameters.

@Franz
During compile phase, my compiler is definitely used. I can see the output 
and the execution of the goal in maven's output.
The only problem is the parameter passing.

In the meantime I found a workaround. But I would like to know the proper 
way to implement such a plugin.

As workaround I did following:

.) Disable the compiler in the components.xml. So no <compile> tag is 
defined for <role-hint>jar</role-hint>

.) Call the plugin in the pom.xml like this:
 <plugin>
           <groupId>mygroup</groupId>
           <artifactId>customCompile</artifactId>
           <version>1.0-SNAPSHOT</version>
           <executions>
           <execution>
           <id>custom-compilation</id>
           <phase>compile</phase>
           <configuration>
           <testParam>testValue</testParam>
             </configuration>
           <goals>
           <goal>compile</goal>
           </goals>
           </execution>
           </executions>
</plugin>





Regards,
Martin

--On Donnerstag, Januar 11, 2007 23:04:40 -0800 franz see 
<fr...@gmail.com> wrote:

>
> Good day,
>
> Actually, using @parameter only should be sufficient for it to be
> configured via the pom. The @expression is used for setting the parameter
> via commandline.
>
> Anyway, Martin M., try specifying in your plugin tag the groupId and
> version as well. It might still be trying to configure
> org.apache.maven.plugins:maven-compiler-plugin:RELEASE instead of your
> custom compiler plugin.
>
> Cheers,
> Franz
>
>
> Jörg Schaible wrote:
>>
>> Hi Martin,
>>
>>
>> there's no automation. You need to provide the expression for the
>> parameter to initialize:
>>
>> [snip]
>>
>>      /**
>>       * @parameter expression="${testParam}"
>>       **/
>>      private String testParam
>>
>> [snip]
>>
>> Within the expression you can also address other parts of the POM ...
>> another typical parameter is:
>>
>> 	/**
>> 	 * The directory for the generated file.
>> 	 *
>> 	 * @parameter expression="${project.build.directory}"
>> 	 * @required
>> 	 */
>> 	private String outputDirectory;
>>
>> - Jörg
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-plug
> in-tf2958426s177.html#a8292757 Sent from the Maven - Users mailing list
> archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>



--
Martin Moser

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: passing custom parameters to a custom compiler-plugin

Posted by franz see <fr...@gmail.com>.
Good day,

Actually, using @parameter only should be sufficient for it to be configured
via the pom. The @expression is used for setting the parameter via
commandline.

Anyway, Martin M., try specifying in your plugin tag the groupId and version
as well. It might still be trying to configure
org.apache.maven.plugins:maven-compiler-plugin:RELEASE instead of your
custom compiler plugin.

Cheers,
Franz


Jörg Schaible wrote:
> 
> Hi Martin,
> 
> 
> there's no automation. You need to provide the expression for the
> parameter to initialize:
> 
> [snip]
> 
>      /**
>       * @parameter expression="${testParam}"
>       **/
>      private String testParam
> 
> [snip]
> 
> Within the expression you can also address other parts of the POM ...
> another typical parameter is:
> 
> 	/**
> 	 * The directory for the generated file.
> 	 *
> 	 * @parameter expression="${project.build.directory}"
> 	 * @required
> 	 */
> 	private String outputDirectory;
> 
> - Jörg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-plugin-tf2958426s177.html#a8292757
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: passing custom parameters to a custom compiler-plugin

Posted by franz see <fr...@gmail.com>.
Good day to you, Martin M,

May I ask you to repost this again. It seems as though your message have
been made into one long line which makes it hard to read.

Thanks,
Franz


Martin M wrote:
> 
> Hi all,
> 
> I implemented a custom compiler-plugin. Now I'd like to pass some
> parameters to it, but I don't get it working. My plugin always tells me
> that the parameters have null-value. I assume it's possible to pass
> parameters to a compiler-plugin, isn't it.
> 
> The plugin-code looks like this:
> 
> 
> /**
>  * custom compiler 
>  *
>  * @version $Id$
>  * @goal compile
>  * @phase compile
>  * @requiresDependencyResolution compile
>  */
> 
> public class javamake extends AbstractMojo
> {
> 
>     /**
>      * @parameter 
>      **/
>     private String testParam
> 
>     public void execute() throws MojoExecutionException
>     {
>         getLog().info("Start compiling, ... with " + testParam);
>      }
> 
> 
> I'm calling the plugin in my pom.xml like this:
> 
> 
> 
>           <plugin>
>            <artifactId>maven-compiler-plugin</artifactId>
>            <configuration>
>            <testParam>c1</testParam>
>            </configuration>
> 
>            <dependencies>
>            <dependency>
>            <groupId>mygroup</groupId>
>            <artifactId>customCompile</artifactId>
>            <version>1.0-SNAPSHOT</version>
>            </dependency>
>            </dependencies>
>           </plugin>
> 
> 
> 
> Ihave also replaced the standard-compiler in maven's components.xml to get
> my compiler activated.
> 
> 
>    <component>
>       <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
>       <role-hint>jar</role-hint>
>      
> <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
> </implementation>
>       <configuration>
>         <lifecycles>
>           <lifecycle>
>             <id>default</id>
>             <!-- START SNIPPET: jar-lifecycle -->
>             <phases>
>              
> <process-resources>org.apache.maven.plugins:maven-resources-plugin
> :resources</process-resources>
>              
> <compile>mygroup:customCompile:1.0-SNAPSHOT:compile</compile>
>                etc.
> 
> 
> Does anyone have a hint, how I could pass my custom parameter?
> 
> Thanks in advance!
> 
> Regards,
> Martin
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/passing-custom-parameters-to-a-custom-compiler-plugin-tf2958426s177.html#a8278077
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org