You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Adrian Gonzalez <ad...@yahoo.fr> on 2007/10/17 10:29:13 UTC

RE : Configuration not working for multiple calls of same plugin

If I understand Maven correclty (I'm quite a newbie),
there can only be one plugin of the same groupId /
artifactId in the plugins element.
If you have multiple execution elements you should put
them together in <executions>.

So your pom.xml should rather loog like :
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.axway</groupId>
  <artifactId>SimpleMavenProject</artifactId>
  <version>1.0</version>
  <packaging>jar</packaging>
  <name>A Simple Maven Test Project</name>

  <profiles>
    <profile>
      <id>integration</id>
      <activation>
        <property>
          <name>integration</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
           
<groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
              <execution>
                <id>build-jar</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
              <execution>
                <id>sign-jar</id>
                <configuration>
                  <alias>myalias</alias>
                  <storepass>mypass</storepass>
                 
<keystore>/path/to/my/keystore</keystore>
                </configuration>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>


--- Veyret Stephane <sv...@axway.com> a écrit :

> Hi,
> 
> I got into a very strange problem. I think this is
> an issue, but I would like to have your opinion
> first.
> 
> In the following pom.xml file, I have got 2 calls to
> the maven-jar-plugin. I need to do that, because
> there are other plugins working on the generated jar
> before it is signed, and all this at the same
> lifecycle phase. You will also see that the
> configuration, for the second call, is in the
> execution section. This again is needed, because I
> have more executions to do with different
> configurations. But anyway, if I put configuration
> directly under the plugin definition, this does not
> change anything to my problem. If you wonder about
> the profiles, this is because lot of things must
> only be done while in "integration" mode.
> 
> To test the pom, I run "mvn -Dintegration clean
> install".
> 
> The problem I have is that for the second call of
> the jar plugin, the configuration I give is totally
> ignored. I can put whatever I want, Maven will never
> consider it. As a result, I have got an error that
> says that the "alias" parameter is not set… More
> strange: if I run a "help:effective-pom", and use
> the generated pom instead of my original one, it
> works as expected, i.e. Maven "sees" the parameters!
> 
> I did the tests on different computers with Maven
> 2.0.7, Maven 2.0.5, Java 1.4.2, Java 6, and always
> have the same result.
> 
> Does anyone have an idea?
> 
> Thank you very much.
> 
> 
> ***** Here is the pom file I use: *****
> <project>
>   <modelVersion>4.0.0</modelVersion>
>   <groupId>com.axway</groupId>
>   <artifactId>SimpleMavenProject</artifactId>
>   <version>1.0</version>
>   <packaging>jar</packaging>
>   <name>A Simple Maven Test Project</name>
> 
>   <profiles>
>     <profile>
>       <id>integration</id>
>       <activation>
>         <property>
>           <name>integration</name>
>         </property>
>       </activation>
>       <build>
>         <plugins>
>           <plugin>
>            
> <groupId>org.apache.maven.plugins</groupId>
>            
> <artifactId>maven-jar-plugin</artifactId>
>             <executions>
>               <execution>
>                 <id>build-jar</id>
>                 <goals>
>                   <goal>jar</goal>
>                 </goals>
>               </execution>
>             </executions>
>           </plugin>
>           <!-- Calls to other plugins here -->
>           <plugin>
>            
> <groupId>org.apache.maven.plugins</groupId>
>            
> <artifactId>maven-jar-plugin</artifactId>
>             <executions>
>               <execution>
>                 <id>sign-jar</id>
>                 <configuration>
>                   <alias>myalias</alias>
>                   <storepass>mypass</storepass>
>                  
> <keystore>/path/to/my/keystore</keystore>
>                 </configuration>
>                 <goals>
>                   <goal>sign</goal>
>                 </goals>
>               </execution>
>             </executions>
>           </plugin>
>         </plugins>
>       </build>
>     </profile>
>   </profiles>
> </project>
> ***************************************
> 
> Kore,
> S. Veyret
> 
> [Ce message a été écrit sur un clavier BÉPO -
> http://www.clavier-dvorak.org/]
> ---
> "Dès que quelqu'un comprend qu'il est contraire à 
> sa dignité d'homme d'obéir à des lois injustes,
> aucune tyrannie ne peut l'asservir." (Mohandas
> Karamchand Gandhi)
> 



      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 

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


RE: RE : Configuration not working for multiple calls of same plugin

Posted by Veyret Stephane <sv...@axway.com>.
> What do you mean by "the effective-pom works correctly"? How does it look like? Two different entries for the
> plugin, one for each phase/configuration ??

It creates the same pom than in my example, except that everything that is in the profiles zone is also copied outside.

> IMHO you've hit a cornercase where the exact behaviour is simply not defined. What happens if you define the
> configuration once for all executions? The jar goal should simply ignore the entries for the SignMojo.

Yes, you're probably right...

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


RE: RE : Configuration not working for multiple calls of same plugin

Posted by Jörg Schaible <Jo...@Elsag-Solutions.com>.
Veyret Stephane wrote on Wednesday, October 17, 2007 1:42 PM:

>> OK. This one is true. But IIRC there is always a pre- and
> post-phase also. So try to use post-package to sign
>> the jar.
> 
> Yes, I'll try this. But the question is: do you think this is
> a bug, especially knowing that the pom generated by
> help:effective-pom works correctly!

What do you mean by "the effective-pom works correctly"? How does it look like? Two different entries for the plugin, one for each phase/configuration ??

IMHO you've hit a cornercase where the exact behaviour is simply not defined. What happens if you define the configuration once for all executions? The jar goal should simply ignore the entries for the SignMojo.

- Jörg

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


RE: RE : Configuration not working for multiple calls of same plugin

Posted by Veyret Stephane <sv...@axway.com>.
> OK. This one is true. But IIRC there is always a pre- and post-phase also. So try to use post-package to sign
> the jar.

Yes, I'll try this. But the question is: do you think this is a bug, especially knowing that the pom generated by help:effective-pom works correctly!

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


RE: RE : Configuration not working for multiple calls of same plugin

Posted by Jörg Schaible <Jo...@Elsag-Solutions.com>.
Veyret Stephane wrote on Wednesday, October 17, 2007 11:25 AM:

> Thanks all for suggestions. The problem is that there is not
> an infinite number of phases in a standard lifecycle, and I
> cannot take another phase than the default one (packaging)
> for these. Other phases are already used for other treatments
> (or it would be somehow dangerous to use them for a job they should
> not do). And to answer Jörg, yes, for plugins executing goals at the
> same phase, declaration order defines the position in
> lifecycle. There even was an issue about this, corrected in version
> 2.0.5. 

OK. This one is true. But IIRC there is always a pre- and post-phase also. So try to use post-package to sign the jar.

- Jörg

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


RE: RE : Configuration not working for multiple calls of same plugin

Posted by Veyret Stephane <sv...@axway.com>.
Thanks all for suggestions. The problem is that there is not an infinite number of phases in a standard lifecycle, and I cannot take another phase than the default one (packaging) for these. Other phases are already used for other treatments (or it would be somehow dangerous to use them for a job they should not do).
And to answer Jörg, yes, for plugins executing goals at the same phase, declaration order defines the position in lifecycle. There even was an issue about this, corrected in version 2.0.5.

-----Message d'origine-----
De : Adrian Gonzalez [mailto:adr_gonzalez@yahoo.fr] 
Envoyé : mercredi 17 octobre 2007 11:12
À : Maven Users List
Objet : RE : Configuration not working for multiple calls of same plugin

As Joerg says, just merging the two execution in the same executions element, and including a phase element ?

<executions>
<execution>
<id>ear-eclipse-manifest</id>
<phase>generate-resources</phase>
<configuration>
...
</configuration>
</execution>
<execution>
<id>another-task</id>
<phase>anotherphase-after-generateersources</phase>
<configuration>
...
</configuration>
</execution>
</executions>

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


RE: RE : Configuration not working for multiple calls of same plugin

Posted by Jörg Schaible <Jo...@Elsag-Solutions.com>.
Veyret Stephane wrote on Wednesday, October 17, 2007 10:40 AM:

> Hi Adrian,
> 
> Thank you for your answer.
> 
> Actually, I can't do what you suggest for I need to execute
> other plugins between jar building and jar signing. Anyway, I
> often need to separate 2 plugin executions, I've never seen
> anywhere that it was forbiden, and this is the first time it does not
> work... 

This is nonsense. The phase of the execution defines the position in the lifecycle, not the declaration order.

- Jörg

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


RE : Configuration not working for multiple calls of same plugin

Posted by Adrian Gonzalez <ad...@yahoo.fr>.
As Joerg says, just merging the two execution in the
same executions element, and including a phase element
?

<executions>
<execution>
<id>ear-eclipse-manifest</id>
<phase>generate-resources</phase>
<configuration>
...
</configuration>
</execution>
<execution>
<id>another-task</id>
<phase>anotherphase-after-generateersources</phase>
<configuration>
...
</configuration>
</execution>
</executions>
--- Veyret Stephane <sv...@axway.com> a écrit :

> Hi Adrian,
> 
> Thank you for your answer.
> 
> Actually, I can't do what you suggest for I need to
> execute other plugins between jar building and jar
> signing. Anyway, I often need to separate 2 plugin
> executions, I've never seen anywhere that it was
> forbiden, and this is the first time it does not
> work...
> 
> -----Message d'origine-----
> De : Adrian Gonzalez [mailto:adr_gonzalez@yahoo.fr] 
> Envoyé : mercredi 17 octobre 2007 10:29
> À : Maven Users List
> Objet : RE : Configuration not working for multiple
> calls of same plugin
> 
> If I understand Maven correclty (I'm quite a
> newbie), there can only be one plugin of the same
> groupId / artifactId in the plugins element.
> If you have multiple execution elements you should
> put them together in <executions>.
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@maven.apache.org
> For additional commands, e-mail:
> users-help@maven.apache.org
> 
> 



      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 

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


RE : Configuration not working for multiple calls of same plugin

Posted by Veyret Stephane <sv...@axway.com>.
Hi Adrian,

Thank you for your answer.

Actually, I can't do what you suggest for I need to execute other plugins between jar building and jar signing. Anyway, I often need to separate 2 plugin executions, I've never seen anywhere that it was forbiden, and this is the first time it does not work...

-----Message d'origine-----
De : Adrian Gonzalez [mailto:adr_gonzalez@yahoo.fr] 
Envoyé : mercredi 17 octobre 2007 10:29
À : Maven Users List
Objet : RE : Configuration not working for multiple calls of same plugin

If I understand Maven correclty (I'm quite a newbie), there can only be one plugin of the same groupId / artifactId in the plugins element.
If you have multiple execution elements you should put them together in <executions>.

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