You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Petr Fišer <pe...@bcvsolutions.eu> on 2020/05/19 12:24:36 UTC
Hooking custom plugin into deploy phase
Hello,
I am trying to create custom maven plugin. Problem is I need to hook it
up into the "deploy" phase before the default maven-deploy-plugin gets
executed.
The plugin itself seems to be ok - I hooked it up to "package" phase to
verify its working. But when trying to get it into "deploy" phase, the
maven-deploy-plugin executes first (and of course complains that I do
not have the distributionManagement section in the pom.xml but I guess
that is not the root of my problem).
Could somebody point me in the right direction please?
Base class of the plugin:
@Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
public class AskpassDeployPluginMojoextends AbstractMojo {
public void execute()throws MojoExecutionException, MojoFailureException {
//do something here }
}
Reference from pom.xml of sample project where I am testing this:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
<artifactId>askpass-deploy-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>askpass</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Cheers,
--
Petr Fišer
Re: Hooking custom plugin into deploy phase
Posted by Petr Fišer <pe...@bcvsolutions.eu>.
Hi,
Sure thing. :)
I have set of private Maven repos which are readable (writeable) only to
logged-in users.
We need to use login:password credentials because it is a community
version of Nexus and AFAIK it does not allow use of API keys. Accounts
are centralized so this is not the only place they are used.
Current state of Maven forces me to have credentials stored in the
settings.xml which is a security issue. It leads to either
- Having one "application user" to read repos and distribute such user
to all our devs. (And this does not solve the write access part at all.)
or to a security nightmare where
- Each developer puts his credentials to the settings.xml in plaintext.
(I know that Maven lets you encrypt the credentials but you still have
to store the master key somewhere... so that actually does not solve
anything and only adds another secret you have to care about.)
Hence, I tried to find, and failing that, tried to create a plugin which
asks user for a password to the repository on the command line before
the actual deploy happens. My idea is, so far, collect the password and
inject it back into maven session with (just an example)
Server servers =session.getSettings().getServers().get(0);
char[] passwordArray = console.readPassword(Enter password: ");s.setPassword(new String(passwordArray));
There are few things to think about - multiple servers, if I am even
able to modify session like that, how to do it for the read of the repo
which happens when downloading dependencies, what happens when invoked
from IDE, ...
Way better would probably be to patch maven-deploy-plugin to ask for
password when it gets HTTP 401 from the remote repository... but hey,
this is a PoC idea I started hacking on yesterday. :)
I'd like to get some minimal working package, then think where it is
right to put it.
Cheers,
Petr Fišer
BCV solutions s.r.o.
Mobile: +420 607 618 243
E-mail: petr.fiser@bcvsolutions.eu
Jabber: petr.fiser@bcvsolutions.eu
On 05/19/2020 02:55 PM, Karl Heinz Marbaise wrote:
> Hi,
>
> On 19.05.20 14:24, Petr Fišer wrote:
>> Hello,
>> I am trying to create custom maven plugin. Problem is I need to hook it
>> up into the "deploy" phase before the default maven-deploy-plugin gets
>> executed.
>> The plugin itself seems to be ok - I hooked it up to "package" phase to
>> verify its working. But when trying to get it into "deploy" phase, the
>> maven-deploy-plugin executes first (and of course complains that I do
>> not have the distributionManagement section in the pom.xml but I guess
>> that is not the root of my problem).
>
> Can you explain what kind of plugin and why the plugin needs to be
> before deploy plugin? (It looks like asking password?) What kind of
> problem are you trying to solve?
>
> Kind regards
> Karl Heinz Marbaise
>>
>> Could somebody point me in the right direction please?
>>
>> Base class of the plugin:
>>
>> @Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
>> public class AskpassDeployPluginMojoextends AbstractMojo {
>> public void execute()throws MojoExecutionException,
>> MojoFailureException {
>> //do something here }
>> }
>>
>>
>> Reference from pom.xml of sample project where I am testing this:
>> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>> <modelVersion>4.0.0</modelVersion>
>> <groupId>com.mycompany.app</groupId>
>> <artifactId>my-app</artifactId>
>> <packaging>jar</packaging>
>> <version>1.0-SNAPSHOT</version>
>> <name>my-app</name>
>> <url>http://maven.apache.org</url>
>> <dependencies>
>> <dependency>
>> <groupId>junit</groupId>
>> <artifactId>junit</artifactId>
>> <version>3.8.1</version>
>> <scope>test</scope>
>> </dependency>
>> </dependencies>
>>
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
>> <artifactId>askpass-deploy-plugin</artifactId>
>> <version>1.0-SNAPSHOT</version>
>> <executions>
>> <execution>
>> <phase>deploy</phase>
>> <goals>
>> <goal>askpass</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> </plugins>
>> </build>
>> </project>
>>
>>
>> Cheers,
Re: Hooking custom plugin into deploy phase
Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,
On 19.05.20 14:24, Petr Fišer wrote:
> Hello,
> I am trying to create custom maven plugin. Problem is I need to hook it
> up into the "deploy" phase before the default maven-deploy-plugin gets
> executed.
> The plugin itself seems to be ok - I hooked it up to "package" phase to
> verify its working. But when trying to get it into "deploy" phase, the
> maven-deploy-plugin executes first (and of course complains that I do
> not have the distributionManagement section in the pom.xml but I guess
> that is not the root of my problem).
Can you explain what kind of plugin and why the plugin needs to be
before deploy plugin? (It looks like asking password?) What kind of
problem are you trying to solve?
Kind regards
Karl Heinz Marbaise
>
> Could somebody point me in the right direction please?
>
> Base class of the plugin:
>
> @Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
> public class AskpassDeployPluginMojoextends AbstractMojo {
> public void execute()throws MojoExecutionException,
> MojoFailureException {
> //do something here }
> }
>
>
> Reference from pom.xml of sample project where I am testing this:
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.mycompany.app</groupId>
> <artifactId>my-app</artifactId>
> <packaging>jar</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>my-app</name>
> <url>http://maven.apache.org</url>
> <dependencies>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>3.8.1</version>
> <scope>test</scope>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
> <plugin>
> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
> <artifactId>askpass-deploy-plugin</artifactId>
> <version>1.0-SNAPSHOT</version>
> <executions>
> <execution>
> <phase>deploy</phase>
> <goals>
> <goal>askpass</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </project>
>
>
> Cheers,
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: Hooking custom plugin into deploy phase
Posted by Petr Fišer <pe...@bcvsolutions.eu>.
Hi,
Yes, this works. Thank you. :)
A followup question... running whole build like this is a bit clunky.
Basically I have to execute:
mvn clean install
cz.fiisch.maven.plugin.deploy.askpass:askpass-deploy-plugin:1.0-SNAPSHOT:askpass
deploy
to do the whole build. This should be ok as long as I am able to squish
"cz.fiisch.maven.plugin.deploy.askpass:askpass-deploy-plugin:1.0-SNAPSHOT"
under some alias so devs will not need to use this whole line, but just
some condensed form like:
mvn clean install SOMEALIAS:askpass deploy
Cheers,
Petr Fišer
BCV solutions s.r.o.
Mobile: +420 607 618 243
E-mail: petr.fiser@bcvsolutions.eu
Jabber: petr.fiser@bcvsolutions.eu
On 05/20/2020 08:58 AM, Maarten Mulders wrote:
> Hi Petr,
>
> If you want to specifically invoke your plugin, you would need
> mvn
> cz.fiisch.maven.plugin.deploy.askpass:askpass-deploy-plugin:1.0-SNAPSHOT:askpass
> (so not mvn deploy:askpass - this looks for the askpass goal in the
> maven-deploy-plugin which doesn't exist)
>
> That said, I would expect that if you took the snippet from the
> pom.xml you have in your email (without the goals section commented
> out), the askpass goal of your plugin should be invoked.
>
> I do agree that - at this stage - seeing messages about missing
> distributionManagement is probably not the cause of the fact that your
> custom plugin not being invoked.
>
> You could add -X (e.g. mvn -X ....) - it will create a lot of
> debugging output, it might give some clues as to why your plugin is
> not executing.
>
> HTH,
>
> Maarten
>
> On May 20, 2020 at 07:56, Petr Fišer wrote:
>
>> Hi,
>> This sound interesting. I gave it a try but it didn't work for me. It
>> even seems that my plugin does not get picked up during "deploy" at all.
>> I added maven-deploy-plugin to the build config like this:
>>
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
>> <artifactId>askpass-deploy-plugin</artifactId>
>> <version>1.0-SNAPSHOT</version>
>> <executions>
>> <execution>
>> <phase>deploy</phase>
>> <!-- <goals> this does not matter for the result...
>> <goal>askpass</goal>
>> </goals> -->
>> </execution>
>> </executions>
>> </plugin>
>>
>> <plugin>
>> <artifactId>maven-deploy-plugin</artifactId>
>> <version>2.8.2</version>
>> <executions>
>> <execution>
>> <phase>deploy</phase>
>> </execution>
>> </executions>
>> </plugin>
>> </plugins>
>> </build>
>>
>> And when running "mvn deploy" there is still only maven-deploy-plugin
>> complaining about the distributionManagement config, blablabla. Like
>> I said before, don't think that is a cause. :)
>> When running specifically for the goal "deploy:askpass" the Maven
>> complains that "Could not find goal 'askpass' in plugin
>> org.apache.maven.plugins:maven-deploy-plugin:2.8.2 ..." which still
>> means that only maven-deploy-plugin got executed.
>>
>> Any idea what could be wrong? Maybe I have some error in my POM?
>> Cheers,
>>
>> Petr Fišer
>>
>> BCV solutions s.r.o.
>> Mobile: +420 607 618 243
>> E-mail: petr.fiser@bcvsolutions.eu
>> Jabber: petr.fiser@bcvsolutions.eu
>>
>> On 05/19/2020 02:39 PM, Maarten Mulders wrote: Hi Petr,
>>
>> As far as I know, when two plugins are bound to the same phase, the
>> order of execution is the same as the order in which you define them
>> in pom.xml.
>> So if you want your plugin to be executed before the
>> maven-deploy-plugin, I guess you'll need to explicitly list the
>> maven-deploy-plugin in your pom.xml, straight after your custom plugin.
>> (Besides, it would be a good idea to do that anyway since it allows
>> you to specify which version of the maven-deploy-plugin your project
>> uses.)
>>
>> Hope this helps!
>>
>> Maarten
>>
>> On May 19, 2020 at 14:24, Petr Fišer wrote:
>>
>> Hello,
>> I am trying to create custom maven plugin. Problem is I need to hook
>> it up into the "deploy" phase before the default maven-deploy-plugin
>> gets executed.
>> The plugin itself seems to be ok - I hooked it up to "package" phase
>> to verify its working. But when trying to get it into "deploy" phase,
>> the maven-deploy-plugin executes first (and of course complains that
>> I do not have the distributionManagement section in the pom.xml but I
>> guess that is not the root of my problem).
>>
>> Could somebody point me in the right direction please?
>>
>> Base class of the plugin:
>>
>> @Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
>> public class AskpassDeployPluginMojoextends AbstractMojo {
>> public void execute()throws MojoExecutionException,
>> MojoFailureException {
>> //do something here }
>> }
>>
>> Reference from pom.xml of sample project where I am testing this:
>> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>> <modelVersion>4.0.0</modelVersion>
>> <groupId>com.mycompany.app</groupId>
>> <artifactId>my-app</artifactId>
>> <packaging>jar</packaging>
>> <version>1.0-SNAPSHOT</version>
>> <name>my-app</name>
>> <url>http://maven.apache.org</url>
>> <dependencies>
>> <dependency>
>> <groupId>junit</groupId>
>> <artifactId>junit</artifactId>
>> <version>3.8.1</version>
>> <scope>test</scope>
>> </dependency>
>> </dependencies>
>>
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
>> <artifactId>askpass-deploy-plugin</artifactId>
>> <version>1.0-SNAPSHOT</version>
>> <executions>
>> <execution>
>> <phase>deploy</phase>
>> <goals>
>> <goal>askpass</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> </plugins>
>> </build>
>> </project>
>>
>> Cheers,
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: Hooking custom plugin into deploy phase
Posted by Petr Fišer <pe...@bcvsolutions.eu>.
Hi,
Thanks for the hint.
The wiki page you mentioned was the first thing I read when I started.
It's worth to say that it states only one explicit requirement: "Do not
name your plugin maven-SOMETHING-plugin."
The phrase You will typically name your
plugin|<yourplugin>-maven-plugin|. does not sound as a requirement at all.
Anyway, I renamed plugin to askpass-maven-plugin and tried to use it
that way. Probably nothing hardcoded here because results are the same
as before (with askpass-deploy-plugin name).
And even if named askpass-deploy-plugin, the plugin executes just fine
in the "package" phase (with changed config in pom.xml of sample project
and with different LifecyclePhase in the Mojo annotation in the plugin
source, of course).
Cheers,
Petr Fišer
BCV solutions s.r.o.
Mobile: +420 607 618 243
E-mail: petr.fiser@bcvsolutions.eu
Jabber: petr.fiser@bcvsolutions.eu
On 05/20/2020 09:28 AM, Slawomir Jaranowski wrote:
> Hi Peter
>
> Your plugin name doesn't meet maven plugin name requirements.
> Maybe some maven plugin name patterns are hardcoded in maven code.
>
> Please try rename your plugin to something as askpass-maven-plugin.
>
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
>
> śr., 20 maj 2020 o 08:58 Maarten Mulders <ma...@mulders.it> napisał(a):
>
>> Hi Petr,
>>
>> If you want to specifically invoke your plugin, you would need
>> mvn
>>
>> cz.fiisch.maven.plugin.deploy.askpass:askpass-deploy-plugin:1.0-SNAPSHOT:askpass
>> (so not mvn deploy:askpass - this looks for the askpass goal in the
>> maven-deploy-plugin which doesn't exist)
>>
>> That said, I would expect that if you took the snippet from the pom.xml
>> you have in your email (without the goals section commented out), the
>> askpass goal of your plugin should be invoked.
>>
>> I do agree that - at this stage - seeing messages about missing
>> distributionManagement is probably not the cause of the fact that your
>> custom plugin not being invoked.
>>
>> You could add -X (e.g. mvn -X ....) - it will create a lot of debugging
>> output, it might give some clues as to why your plugin is not executing.
>>
>> HTH,
>>
>> Maarten
>>
>> On May 20, 2020 at 07:56, Petr Fišer wrote:
>>
>>> Hi,
>>> This sound interesting. I gave it a try but it didn't work for me. It
>>> even seems that my plugin does not get picked up during "deploy" at
>>> all.
>>> I added maven-deploy-plugin to the build config like this:
>>>
>>> <build>
>>> <plugins>
>>> <plugin>
>>> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
>>> <artifactId>askpass-deploy-plugin</artifactId>
>>> <version>1.0-SNAPSHOT</version>
>>> <executions>
>>> <execution>
>>> <phase>deploy</phase>
>>> <!-- <goals> this does not matter for the
>>> result...
>>> <goal>askpass</goal>
>>> </goals> -->
>>> </execution>
>>> </executions>
>>> </plugin>
>>>
>>> <plugin>
>>> <artifactId>maven-deploy-plugin</artifactId>
>>> <version>2.8.2</version>
>>> <executions>
>>> <execution>
>>> <phase>deploy</phase>
>>> </execution>
>>> </executions>
>>> </plugin>
>>> </plugins>
>>> </build>
>>>
>>> And when running "mvn deploy" there is still only maven-deploy-plugin
>>> complaining about the distributionManagement config, blablabla. Like I
>>> said before, don't think that is a cause. :)
>>> When running specifically for the goal "deploy:askpass" the Maven
>>> complains that "Could not find goal 'askpass' in plugin
>>> org.apache.maven.plugins:maven-deploy-plugin:2.8.2 ..." which still
>>> means that only maven-deploy-plugin got executed.
>>>
>>> Any idea what could be wrong? Maybe I have some error in my POM?
>>> Cheers,
>>>
>>> Petr Fišer
>>>
>>> BCV solutions s.r.o.
>>> Mobile: +420 607 618 243
>>> E-mail: petr.fiser@bcvsolutions.eu
>>> Jabber: petr.fiser@bcvsolutions.eu
>>>
>>> On 05/19/2020 02:39 PM, Maarten Mulders wrote: Hi Petr,
>>>
>>> As far as I know, when two plugins are bound to the same phase, the
>>> order of execution is the same as the order in which you define them in
>>> pom.xml.
>>> So if you want your plugin to be executed before the
>>> maven-deploy-plugin, I guess you'll need to explicitly list the
>>> maven-deploy-plugin in your pom.xml, straight after your custom plugin.
>>> (Besides, it would be a good idea to do that anyway since it allows you
>>> to specify which version of the maven-deploy-plugin your project uses.)
>>>
>>> Hope this helps!
>>>
>>> Maarten
>>>
>>> On May 19, 2020 at 14:24, Petr Fišer wrote:
>>>
>>> Hello,
>>> I am trying to create custom maven plugin. Problem is I need to hook it
>>> up into the "deploy" phase before the default maven-deploy-plugin gets
>>> executed.
>>> The plugin itself seems to be ok - I hooked it up to "package" phase to
>>> verify its working. But when trying to get it into "deploy" phase, the
>>> maven-deploy-plugin executes first (and of course complains that I do
>>> not have the distributionManagement section in the pom.xml but I guess
>>> that is not the root of my problem).
>>>
>>> Could somebody point me in the right direction please?
>>>
>>> Base class of the plugin:
>>>
>>> @Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
>>> public class AskpassDeployPluginMojoextends AbstractMojo {
>>> public void execute()throws MojoExecutionException,
>>> MojoFailureException {
>>> //do something here }
>>> }
>>>
>>> Reference from pom.xml of sample project where I am testing this:
>>> <project xmlns="http://maven.apache.org/POM/4.0.0"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>>> http://maven.apache.org/maven-v4_0_0.xsd">
>>> <modelVersion>4.0.0</modelVersion>
>>> <groupId>com.mycompany.app</groupId>
>>> <artifactId>my-app</artifactId>
>>> <packaging>jar</packaging>
>>> <version>1.0-SNAPSHOT</version>
>>> <name>my-app</name>
>>> <url>http://maven.apache.org</url>
>>> <dependencies>
>>> <dependency>
>>> <groupId>junit</groupId>
>>> <artifactId>junit</artifactId>
>>> <version>3.8.1</version>
>>> <scope>test</scope>
>>> </dependency>
>>> </dependencies>
>>>
>>> <build>
>>> <plugins>
>>> <plugin>
>>> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
>>> <artifactId>askpass-deploy-plugin</artifactId>
>>> <version>1.0-SNAPSHOT</version>
>>> <executions>
>>> <execution>
>>> <phase>deploy</phase>
>>> <goals>
>>> <goal>askpass</goal>
>>> </goals>
>>> </execution>
>>> </executions>
>>> </plugin>
>>> </plugins>
>>> </build>
>>> </project>
>>>
>>> Cheers,
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
Re: Hooking custom plugin into deploy phase
Posted by Slawomir Jaranowski <s....@gmail.com>.
Hi Peter
Your plugin name doesn't meet maven plugin name requirements.
Maybe some maven plugin name patterns are hardcoded in maven code.
Please try rename your plugin to something as askpass-maven-plugin.
https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
śr., 20 maj 2020 o 08:58 Maarten Mulders <ma...@mulders.it> napisał(a):
> Hi Petr,
>
> If you want to specifically invoke your plugin, you would need
> mvn
>
> cz.fiisch.maven.plugin.deploy.askpass:askpass-deploy-plugin:1.0-SNAPSHOT:askpass
> (so not mvn deploy:askpass - this looks for the askpass goal in the
> maven-deploy-plugin which doesn't exist)
>
> That said, I would expect that if you took the snippet from the pom.xml
> you have in your email (without the goals section commented out), the
> askpass goal of your plugin should be invoked.
>
> I do agree that - at this stage - seeing messages about missing
> distributionManagement is probably not the cause of the fact that your
> custom plugin not being invoked.
>
> You could add -X (e.g. mvn -X ....) - it will create a lot of debugging
> output, it might give some clues as to why your plugin is not executing.
>
> HTH,
>
> Maarten
>
> On May 20, 2020 at 07:56, Petr Fišer wrote:
>
> > Hi,
> > This sound interesting. I gave it a try but it didn't work for me. It
> > even seems that my plugin does not get picked up during "deploy" at
> > all.
> > I added maven-deploy-plugin to the build config like this:
> >
> > <build>
> > <plugins>
> > <plugin>
> > <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
> > <artifactId>askpass-deploy-plugin</artifactId>
> > <version>1.0-SNAPSHOT</version>
> > <executions>
> > <execution>
> > <phase>deploy</phase>
> > <!-- <goals> this does not matter for the
> > result...
> > <goal>askpass</goal>
> > </goals> -->
> > </execution>
> > </executions>
> > </plugin>
> >
> > <plugin>
> > <artifactId>maven-deploy-plugin</artifactId>
> > <version>2.8.2</version>
> > <executions>
> > <execution>
> > <phase>deploy</phase>
> > </execution>
> > </executions>
> > </plugin>
> > </plugins>
> > </build>
> >
> > And when running "mvn deploy" there is still only maven-deploy-plugin
> > complaining about the distributionManagement config, blablabla. Like I
> > said before, don't think that is a cause. :)
> > When running specifically for the goal "deploy:askpass" the Maven
> > complains that "Could not find goal 'askpass' in plugin
> > org.apache.maven.plugins:maven-deploy-plugin:2.8.2 ..." which still
> > means that only maven-deploy-plugin got executed.
> >
> > Any idea what could be wrong? Maybe I have some error in my POM?
> > Cheers,
> >
> > Petr Fišer
> >
> > BCV solutions s.r.o.
> > Mobile: +420 607 618 243
> > E-mail: petr.fiser@bcvsolutions.eu
> > Jabber: petr.fiser@bcvsolutions.eu
> >
> > On 05/19/2020 02:39 PM, Maarten Mulders wrote: Hi Petr,
> >
> > As far as I know, when two plugins are bound to the same phase, the
> > order of execution is the same as the order in which you define them in
> > pom.xml.
> > So if you want your plugin to be executed before the
> > maven-deploy-plugin, I guess you'll need to explicitly list the
> > maven-deploy-plugin in your pom.xml, straight after your custom plugin.
> > (Besides, it would be a good idea to do that anyway since it allows you
> > to specify which version of the maven-deploy-plugin your project uses.)
> >
> > Hope this helps!
> >
> > Maarten
> >
> > On May 19, 2020 at 14:24, Petr Fišer wrote:
> >
> > Hello,
> > I am trying to create custom maven plugin. Problem is I need to hook it
> > up into the "deploy" phase before the default maven-deploy-plugin gets
> > executed.
> > The plugin itself seems to be ok - I hooked it up to "package" phase to
> > verify its working. But when trying to get it into "deploy" phase, the
> > maven-deploy-plugin executes first (and of course complains that I do
> > not have the distributionManagement section in the pom.xml but I guess
> > that is not the root of my problem).
> >
> > Could somebody point me in the right direction please?
> >
> > Base class of the plugin:
> >
> > @Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
> > public class AskpassDeployPluginMojoextends AbstractMojo {
> > public void execute()throws MojoExecutionException,
> > MojoFailureException {
> > //do something here }
> > }
> >
> > Reference from pom.xml of sample project where I am testing this:
> > <project xmlns="http://maven.apache.org/POM/4.0.0"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd">
> > <modelVersion>4.0.0</modelVersion>
> > <groupId>com.mycompany.app</groupId>
> > <artifactId>my-app</artifactId>
> > <packaging>jar</packaging>
> > <version>1.0-SNAPSHOT</version>
> > <name>my-app</name>
> > <url>http://maven.apache.org</url>
> > <dependencies>
> > <dependency>
> > <groupId>junit</groupId>
> > <artifactId>junit</artifactId>
> > <version>3.8.1</version>
> > <scope>test</scope>
> > </dependency>
> > </dependencies>
> >
> > <build>
> > <plugins>
> > <plugin>
> > <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
> > <artifactId>askpass-deploy-plugin</artifactId>
> > <version>1.0-SNAPSHOT</version>
> > <executions>
> > <execution>
> > <phase>deploy</phase>
> > <goals>
> > <goal>askpass</goal>
> > </goals>
> > </execution>
> > </executions>
> > </plugin>
> > </plugins>
> > </build>
> > </project>
> >
> > Cheers,
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>
--
Sławomir Jaranowski
Re: Hooking custom plugin into deploy phase
Posted by Maarten Mulders <ma...@mulders.it>.
Hi Petr,
If you want to specifically invoke your plugin, you would need
mvn
cz.fiisch.maven.plugin.deploy.askpass:askpass-deploy-plugin:1.0-SNAPSHOT:askpass
(so not mvn deploy:askpass - this looks for the askpass goal in the
maven-deploy-plugin which doesn't exist)
That said, I would expect that if you took the snippet from the pom.xml
you have in your email (without the goals section commented out), the
askpass goal of your plugin should be invoked.
I do agree that - at this stage - seeing messages about missing
distributionManagement is probably not the cause of the fact that your
custom plugin not being invoked.
You could add -X (e.g. mvn -X ....) - it will create a lot of debugging
output, it might give some clues as to why your plugin is not executing.
HTH,
Maarten
On May 20, 2020 at 07:56, Petr Fišer wrote:
> Hi,
> This sound interesting. I gave it a try but it didn't work for me. It
> even seems that my plugin does not get picked up during "deploy" at
> all.
> I added maven-deploy-plugin to the build config like this:
>
> <build>
> <plugins>
> <plugin>
> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
> <artifactId>askpass-deploy-plugin</artifactId>
> <version>1.0-SNAPSHOT</version>
> <executions>
> <execution>
> <phase>deploy</phase>
> <!-- <goals> this does not matter for the
> result...
> <goal>askpass</goal>
> </goals> -->
> </execution>
> </executions>
> </plugin>
>
> <plugin>
> <artifactId>maven-deploy-plugin</artifactId>
> <version>2.8.2</version>
> <executions>
> <execution>
> <phase>deploy</phase>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
>
> And when running "mvn deploy" there is still only maven-deploy-plugin
> complaining about the distributionManagement config, blablabla. Like I
> said before, don't think that is a cause. :)
> When running specifically for the goal "deploy:askpass" the Maven
> complains that "Could not find goal 'askpass' in plugin
> org.apache.maven.plugins:maven-deploy-plugin:2.8.2 ..." which still
> means that only maven-deploy-plugin got executed.
>
> Any idea what could be wrong? Maybe I have some error in my POM?
> Cheers,
>
> Petr Fišer
>
> BCV solutions s.r.o.
> Mobile: +420 607 618 243
> E-mail: petr.fiser@bcvsolutions.eu
> Jabber: petr.fiser@bcvsolutions.eu
>
> On 05/19/2020 02:39 PM, Maarten Mulders wrote: Hi Petr,
>
> As far as I know, when two plugins are bound to the same phase, the
> order of execution is the same as the order in which you define them in
> pom.xml.
> So if you want your plugin to be executed before the
> maven-deploy-plugin, I guess you'll need to explicitly list the
> maven-deploy-plugin in your pom.xml, straight after your custom plugin.
> (Besides, it would be a good idea to do that anyway since it allows you
> to specify which version of the maven-deploy-plugin your project uses.)
>
> Hope this helps!
>
> Maarten
>
> On May 19, 2020 at 14:24, Petr Fišer wrote:
>
> Hello,
> I am trying to create custom maven plugin. Problem is I need to hook it
> up into the "deploy" phase before the default maven-deploy-plugin gets
> executed.
> The plugin itself seems to be ok - I hooked it up to "package" phase to
> verify its working. But when trying to get it into "deploy" phase, the
> maven-deploy-plugin executes first (and of course complains that I do
> not have the distributionManagement section in the pom.xml but I guess
> that is not the root of my problem).
>
> Could somebody point me in the right direction please?
>
> Base class of the plugin:
>
> @Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
> public class AskpassDeployPluginMojoextends AbstractMojo {
> public void execute()throws MojoExecutionException,
> MojoFailureException {
> //do something here }
> }
>
> Reference from pom.xml of sample project where I am testing this:
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.mycompany.app</groupId>
> <artifactId>my-app</artifactId>
> <packaging>jar</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>my-app</name>
> <url>http://maven.apache.org</url>
> <dependencies>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>3.8.1</version>
> <scope>test</scope>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
> <plugin>
> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
> <artifactId>askpass-deploy-plugin</artifactId>
> <version>1.0-SNAPSHOT</version>
> <executions>
> <execution>
> <phase>deploy</phase>
> <goals>
> <goal>askpass</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </project>
>
> Cheers,
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: Hooking custom plugin into deploy phase
Posted by Petr Fišer <pe...@bcvsolutions.eu>.
Hi,
This sound interesting. I gave it a try but it didn't work for me. It
even seems that my plugin does not get picked up during "deploy" at all.
I added maven-deploy-plugin to the build config like this:
<build>
<plugins>
<plugin>
<groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
<artifactId>askpass-deploy-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<phase>deploy</phase>
<!-- <goals> this does not matter for the result...
<goal>askpass</goal>
</goals> -->
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
And when running "mvn deploy" there is still only maven-deploy-plugin
complaining about the distributionManagement config, blablabla. Like I
said before, don't think that is a cause. :)
When running specifically for the goal "deploy:askpass" the Maven
complains that "Could not find goal 'askpass' in plugin
org.apache.maven.plugins:maven-deploy-plugin:2.8.2 ..." which still
means that only maven-deploy-plugin got executed.
Any idea what could be wrong? Maybe I have some error in my POM?
Cheers,
Petr Fišer
BCV solutions s.r.o.
Mobile: +420 607 618 243
E-mail: petr.fiser@bcvsolutions.eu
Jabber: petr.fiser@bcvsolutions.eu
On 05/19/2020 02:39 PM, Maarten Mulders wrote:
> Hi Petr,
>
> As far as I know, when two plugins are bound to the same phase, the
> order of execution is the same as the order in which you define them
> in pom.xml.
> So if you want your plugin to be executed before the
> maven-deploy-plugin, I guess you'll need to explicitly list the
> maven-deploy-plugin in your pom.xml, straight after your custom plugin.
> (Besides, it would be a good idea to do that anyway since it allows
> you to specify which version of the maven-deploy-plugin your project
> uses.)
>
> Hope this helps!
>
> Maarten
>
> On May 19, 2020 at 14:24, Petr Fišer wrote:
>
>> Hello,
>> I am trying to create custom maven plugin. Problem is I need to hook
>> it up into the "deploy" phase before the default maven-deploy-plugin
>> gets executed.
>> The plugin itself seems to be ok - I hooked it up to "package" phase
>> to verify its working. But when trying to get it into "deploy" phase,
>> the maven-deploy-plugin executes first (and of course complains that
>> I do not have the distributionManagement section in the pom.xml but I
>> guess that is not the root of my problem).
>>
>> Could somebody point me in the right direction please?
>>
>> Base class of the plugin:
>>
>> @Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
>> public class AskpassDeployPluginMojoextends AbstractMojo {
>> public void execute()throws MojoExecutionException,
>> MojoFailureException {
>> //do something here }
>> }
>>
>> Reference from pom.xml of sample project where I am testing this:
>> <project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>> <modelVersion>4.0.0</modelVersion>
>> <groupId>com.mycompany.app</groupId>
>> <artifactId>my-app</artifactId>
>> <packaging>jar</packaging>
>> <version>1.0-SNAPSHOT</version>
>> <name>my-app</name>
>> <url>http://maven.apache.org</url>
>> <dependencies>
>> <dependency>
>> <groupId>junit</groupId>
>> <artifactId>junit</artifactId>
>> <version>3.8.1</version>
>> <scope>test</scope>
>> </dependency>
>> </dependencies>
>>
>> <build>
>> <plugins>
>> <plugin>
>> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
>> <artifactId>askpass-deploy-plugin</artifactId>
>> <version>1.0-SNAPSHOT</version>
>> <executions>
>> <execution>
>> <phase>deploy</phase>
>> <goals>
>> <goal>askpass</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>> </plugins>
>> </build>
>> </project>
>>
>> Cheers,
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: Hooking custom plugin into deploy phase
Posted by Maarten Mulders <ma...@mulders.it>.
Hi Petr,
As far as I know, when two plugins are bound to the same phase, the
order of execution is the same as the order in which you define them in
pom.xml.
So if you want your plugin to be executed before the
maven-deploy-plugin, I guess you'll need to explicitly list the
maven-deploy-plugin in your pom.xml, straight after your custom plugin.
(Besides, it would be a good idea to do that anyway since it allows you
to specify which version of the maven-deploy-plugin your project uses.)
Hope this helps!
Maarten
On May 19, 2020 at 14:24, Petr Fišer wrote:
> Hello,
> I am trying to create custom maven plugin. Problem is I need to hook it
> up into the "deploy" phase before the default maven-deploy-plugin gets
> executed.
> The plugin itself seems to be ok - I hooked it up to "package" phase to
> verify its working. But when trying to get it into "deploy" phase, the
> maven-deploy-plugin executes first (and of course complains that I do
> not have the distributionManagement section in the pom.xml but I guess
> that is not the root of my problem).
>
> Could somebody point me in the right direction please?
>
> Base class of the plugin:
>
> @Mojo( name ="askpass", defaultPhase = LifecyclePhase.DEPLOY )
> public class AskpassDeployPluginMojoextends AbstractMojo {
> public void execute()throws MojoExecutionException,
> MojoFailureException {
> //do something here }
> }
>
> Reference from pom.xml of sample project where I am testing this:
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.mycompany.app</groupId>
> <artifactId>my-app</artifactId>
> <packaging>jar</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>my-app</name>
> <url>http://maven.apache.org</url>
> <dependencies>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>3.8.1</version>
> <scope>test</scope>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
> <plugin>
> <groupId>cz.fiisch.maven.plugin.deploy.askpass</groupId>
> <artifactId>askpass-deploy-plugin</artifactId>
> <version>1.0-SNAPSHOT</version>
> <executions>
> <execution>
> <phase>deploy</phase>
> <goals>
> <goal>askpass</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> </project>
>
> Cheers,
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org