Re: Call a custom plugin from another project
what i want to do is to force to execute my plugin in a specific phase with a specific goal (my plugin will have only one goal) without declare it i mean that i don't want that the user declare the execution tag as for example i use the jar-plugin -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758280.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Call a custom plugin from another project
Maven has a couple of default packaging types that have defined lifecycles. e.g. `jar`, `war`, `ear`, etc. If you don't specify `packaging` then Maven assumes that your project is `packagingjar/packaging` by default. Maven will then consult its registry of lifecycles and see the lifecycle for the `jar` (or whatever packaging you specified - assuming it exists) and based on that lifecycle it will add the plugin executions defined by the lifecycle. So, for example, if you don't specify a `packaging` then the `jar` lifecycle will be assumes, and the `jar` lifecycle binds `jar:jar` to the `package` phase. So you have (at first look) three choices: 1. Get your plugin goals added to the default lifecycle(s) in the appropriate phases 2. Define a custom lifecycle (with a corresponding custom packaging type) 3. Put up with having to define `executions` in the `pom.xml` Now, #1 is *never* going to happen for 99.99% of plugins. As that would push your plugin executions onto *every* Maven user. Changing the default lifecycles is not something we do on a whim. So let's cross that off your list of options. #3 is the one you are trying to avoid, so that leaves #2. How will #2 look? Well as you are defining a custom lifecycle, you will need to tell Maven about this custom packaging type. To do that you have to register the custom packaging type with Maven. This will require EITHER adding `extensionstrue/extensions` to the `plugin` section in the `pom.xml` using your custom packaging OR adding a `extension` to the `build` section. So, what I am saying is that there is no way you can have your plugin *magically* executed against a project which has not been informed of your plugins existence in some way or other... you will either have project ... build ... plugins ... plugin groupIdyour-group-id/groupId artifactIdyour-maven-plugin/artifactId versionx.y.z/version ... executions !-- some configuration goes here -- /executions ... /plugin ... /plugins ... /build ... /project or you will have project ... packagingyour-packaging/packaging ... build ... plugins ... plugin groupIdyour-group-id/groupId artifactIdyour-maven-plugin/artifactId versionx.y.z/version ... extensionstrue/extensions ... /plugin ... /plugins ... /build ... /project or you will have project ... packagingyour-packaging/packaging ... build ... extensions ... extension groupIdyour-group-id/groupId artifactIdyour-packaging-definition/artifactId versionx.y.z/version /extension ... /extensions ... /build ... /project Note: you could have the extensions registered in the parent (works for either the /project/build/plugins/plugin/extensions route or the /project/build/extensions/extension route), which might simplify things if you are building multiple modules of the same packaging. So it is really a question of picking which is the least pain. See http://developer-blog.cloudbees.com/2013/04/the-maven-way.html for some hints as to the end-game direction you want to head towards. Finally, the `execution` section does not have to be too bad. If you specify a default phase when you define your mojo, you can usually get away with just execution goals goalmy-goal/goal /goals /execution or if you have multiple goals with different default phases, you can have execution goals goalmy-goal/goal goalmy-other-goal/goal /goals /execution And they will execute against their respective default phases... you only need multiple `execution` sections with their own `id` for the case where you want to override / have to specify the `phase` HTH -Stephen On 5 June 2013 10:23, alesky alessandro.dotta...@gmail.com wrote: what i want to do is to force to execute my plugin in a specific phase with a specific goal (my plugin will have only one goal) without declare it i mean that i don't want that the user declare the execution tag as for example i use the jar-plugin -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758280.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
RE: Call a custom plugin from another project
Take a look at this tutorial to get you started binding your plugin to user-selected phase http://books.sonatype.com/mvnref-book/reference/writing-plugins-sect-plugins-lifecycle.html Bon Chance, Martin __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 4 Jun 2013 19:57:55 +0200 Subject: Re: Call a custom plugin from another project From: m...@batmat.net To: users@maven.apache.org If I understand correctly, you want to be able to execute your plugin without having to declare it. If so then your are on the right path since the only way to do that is to create a custom lifecycle. Hope this helps. Cheers -- Baptiste Le 4 juin 2013 19:17, alesky alessandro.dotta...@gmail.com a écrit : ok Stephen thanks specifying an execution to the plugin it works but i would like to injects an execution in the packaging for the specified plugin project in the way that i can use the plugin in this way, and don't have to force the user to specific the execution but i didn't found any documentation on-line or in the reference guide regarding this point or at list I'm not able to find a correct on-line document to do it what i i found is that in the plugin annotation there is the @execute annotation, but from my understand this annotation is complete different from what i want to do @execute goal=goal This will execute the given goal before execution of this one. The goal name is specified using the prefix:goal notation. @execute phase=phase This will fork an alternate build lifecycle up to the specified phase before continuing to execute the current one. If no lifecycle is specified, Maven will use the lifecycle of the current build. @execute lifecycle=lifecycle phase=phase This will execute the given alternate lifecycle. A custom lifecycle can be defined in META-INF/maven/lifecycles.xml. -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758242.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Call a custom plugin from another project
Hi guys i'm try to implement my first plugin so i did just a plugin that print a log on the screen this is the code and this is the pom related to this plugin, from the pom generated from the plugin archetype i have just add the maven-plugin-plugin to add the prefix pojo to make same test finally i have configure my setting to register my group of plugin now my proble,: from the command line i can call with any problem my plugin mvn pojo:log but if i try to use it in another project it is not used! for example this is the pom of my test project and if i run on this project mvn process-sources i should aspect to see my output but the plugin is not used at all any advice of the reason that the plugin work directly from command line and not if configured in the pom of another project? thanks this is the log of the pom project this is instead the plugin.xml generated by maven -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Call a custom plugin from another project
1. Please use a propper mail agent that does not strip the code from you email 2. Try `mvn it.spaghettisource.plugin:pojo:1.0:log` as Maven does not know where to look for your plugin On 4 June 2013 15:30, alesky alessandro.dotta...@gmail.com wrote: Hi guys i'm try to implement my first plugin so i did just a plugin that print a log on the screen this is the code and this is the pom related to this plugin, from the pom generated from the plugin archetype i have just add the maven-plugin-plugin to add the prefix pojo to make same test finally i have configure my setting to register my group of plugin now my proble,: from the command line i can call with any problem my plugin mvn pojo:log but if i try to use it in another project it is not used! for example this is the pom of my test project and if i run on this project mvn process-sources i should aspect to see my output but the plugin is not used at all any advice of the reason that the plugin work directly from command line and not if configured in the pom of another project? thanks this is the log of the pom project this is instead the plugin.xml generated by maven -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Call a custom plugin from another project
1. Please use a propper mail agent that does not strip the code from you email ok i will do the next time sorry to all, i was supposing that in this way there was all the information to undestand my issue 2. Try `mvn it.spaghettisource.plugin:pojo:1.0:log` as Maven does not know where to look for your plugin as is wrote in my previous mail i can call correctly the plugin from command line: using mvn it.spaghettisource.plugin:pojo:1.0:log and i have registered the group in the setting so i can call it also by prefix mvn pojo:log my question is related to the fact that if i had the plugin configuration in another project inside the plugin section, it is not executed -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758217.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Call a custom plugin from another project
plugins are not executed unless the packaging for the specified project injects an execution OR you specify an execution for the plugin yourself On 4 June 2013 16:01, alesky alessandro.dotta...@gmail.com wrote: 1. Please use a propper mail agent that does not strip the code from you email ok i will do the next time sorry to all, i was supposing that in this way there was all the information to undestand my issue 2. Try `mvn it.spaghettisource.plugin:pojo:1.0:log` as Maven does not know where to look for your plugin as is wrote in my previous mail i can call correctly the plugin from command line: using mvn it.spaghettisource.plugin:pojo:1.0:log and i have registered the group in the setting so i can call it also by prefix mvn pojo:log my question is related to the fact that if i had the plugin configuration in another project inside the plugin section, it is not executed -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758217.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Call a custom plugin from another project
eg project ...build ...plugins ...plugin ...executions ...execution On 4 June 2013 16:46, Stephen Connolly stephen.alan.conno...@gmail.comwrote: plugins are not executed unless the packaging for the specified project injects an execution OR you specify an execution for the plugin yourself On 4 June 2013 16:01, alesky alessandro.dotta...@gmail.com wrote: 1. Please use a propper mail agent that does not strip the code from you email ok i will do the next time sorry to all, i was supposing that in this way there was all the information to undestand my issue 2. Try `mvn it.spaghettisource.plugin:pojo:1.0:log` as Maven does not know where to look for your plugin as is wrote in my previous mail i can call correctly the plugin from command line: using mvn it.spaghettisource.plugin:pojo:1.0:log and i have registered the group in the setting so i can call it also by prefix mvn pojo:log my question is related to the fact that if i had the plugin configuration in another project inside the plugin section, it is not executed -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758217.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Call a custom plugin from another project
ok Stephen thanks specifying an execution to the plugin it works but i would like to injects an execution in the packaging for the specified plugin project in the way that i can use the plugin in this way, and don't have to force the user to specific the execution but i didn't found any documentation on-line or in the reference guide regarding this point or at list I'm not able to find a correct on-line document to do it what i i found is that in the plugin annotation there is the @execute annotation, but from my understand this annotation is complete different from what i want to do @execute goal=goal This will execute the given goal before execution of this one. The goal name is specified using the prefix:goal notation. @execute phase=phase This will fork an alternate build lifecycle up to the specified phase before continuing to execute the current one. If no lifecycle is specified, Maven will use the lifecycle of the current build. @execute lifecycle=lifecycle phase=phase This will execute the given alternate lifecycle. A custom lifecycle can be defined in META-INF/maven/lifecycles.xml. -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758242.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org
Re: Call a custom plugin from another project
IIUC, you are trying to bind a plugin execution to a phase? Check this link http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Configuring_Build_Plugins Basically, you need an execution tag with the configuration for the plugin and a phase that the plugin is bound to so if you bind it to package for example, your plugin will be executed when you run mvn package Alejandro Endo | Software Designer/Concepteur de logiciels From: alesky alessandro.dotta...@gmail.com To: users@maven.apache.org, Date: 04/06/2013 01:17 PM Subject:Re: Call a custom plugin from another project ok Stephen thanks specifying an execution to the plugin it works but i would like to injects an execution in the packaging for the specified plugin project in the way that i can use the plugin in this way, and don't have to force the user to specific the execution but i didn't found any documentation on-line or in the reference guide regarding this point or at list I'm not able to find a correct on-line document to do it what i i found is that in the plugin annotation there is the @execute annotation, but from my understand this annotation is complete different from what i want to do @execute goal=goal This will execute the given goal before execution of this one. The goal name is specified using the prefix:goal notation. @execute phase=phase This will fork an alternate build lifecycle up to the specified phase before continuing to execute the current one. If no lifecycle is specified, Maven will use the lifecycle of the current build. @execute lifecycle=lifecycle phase=phase This will execute the given alternate lifecycle. A custom lifecycle can be defined in META-INF/maven/lifecycles.xml. -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758242.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org DISCLAIMER: Privileged and/or Confidential information may be contained in this message. If you are not the addressee of this message, you may not copy, use or deliver this message to anyone. In such event, you should destroy the message and kindly notify the sender by reply e-mail. It is understood that opinions or conclusions that do not relate to the official business of the company are neither given nor endorsed by the company. Thank You.
Re: Call a custom plugin from another project
If I understand correctly, you want to be able to execute your plugin without having to declare it. If so then your are on the right path since the only way to do that is to create a custom lifecycle. Hope this helps. Cheers -- Baptiste Le 4 juin 2013 19:17, alesky alessandro.dotta...@gmail.com a écrit : ok Stephen thanks specifying an execution to the plugin it works but i would like to injects an execution in the packaging for the specified plugin project in the way that i can use the plugin in this way, and don't have to force the user to specific the execution but i didn't found any documentation on-line or in the reference guide regarding this point or at list I'm not able to find a correct on-line document to do it what i i found is that in the plugin annotation there is the @execute annotation, but from my understand this annotation is complete different from what i want to do @execute goal=goal This will execute the given goal before execution of this one. The goal name is specified using the prefix:goal notation. @execute phase=phase This will fork an alternate build lifecycle up to the specified phase before continuing to execute the current one. If no lifecycle is specified, Maven will use the lifecycle of the current build. @execute lifecycle=lifecycle phase=phase This will execute the given alternate lifecycle. A custom lifecycle can be defined in META-INF/maven/lifecycles.xml. -- View this message in context: http://maven.40175.n5.nabble.com/Call-a-custom-plugin-from-another-project-tp5758214p5758242.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org