You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by laredotornado-3 <la...@gmail.com> on 2013/04/02 20:07:00 UTC

Can I force a plugin to not run during parent pom execution phase?

Hi,

I'm using Maven 3.0.3.  I've included this plugin in a profile in my parent
pom, however, when I run my parent pom, I don't want this to be executed as
part of the parent pom being built (I do want it executed for each of the
child modules).  How can I make this plugin not run during the parent
execution phase?

	<modelVersion>4.0.0</modelVersion>
	<groupId>org.mainco.subco</groupId>
	<artifactId>subco</artifactId>
	<version>12.0.0-SNAPSHOT</version>
	<modules>
		<module>moduleA</module>
		<module>moduleB</module>
		<module>moduleC</module>
		<packaging>pom</packaging>

	<profiles>
		<profile>
			...
					<plugin>
						<groupId>org.liquibase</groupId>
						<artifactId>liquibase-maven-plugin</artifactId>
						<version>2.0.1</version>
						<dependencies>
							<dependency>
								<groupId>mysql</groupId>
								<artifactId>mysql-connector-java</artifactId>
								<version>5.1.18</version>
							</dependency>
						</dependencies>
						<executions>
							<execution>
								<id>build-database</id>
								<phase>process-test-resources</phase>
								<configuration>
									<driver>com.mysql.jdbc.Driver</driver>
								
<url>jdbc:mysql://${test.mysql.db.host}:${test.mysql.db.port}/${test.mysql.db.sid}</url>
									<username>${test.mysql.db.user}</username>
									<password>${test.mysql.db.password}</password>
								
<changeLogFile>${project.build.directory}/db.changelog-master.xml</changeLogFile>
									<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
								</configuration>
								<goals>
									<goal>update</goal>
								</goals>
							</execution>
						</executions>
					</plugin>

Thanks, - Dave




--
View this message in context: http://maven.40175.n5.nabble.com/Can-I-force-a-plugin-to-not-run-during-parent-pom-execution-phase-tp5752479.html
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: Can I force a plugin to not run during parent pom execution phase?

Posted by Al...@miranda.com.
A trick i use, provided the plugin has a configuration to skip a run, is
having something like this in the parent

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-assembly-plugin</artifactId>
	<version>2.4</version>
	<executions>
		<execution>
			<id>my-id</id>
			<phase>package</phase>
			<inherited>true</inherited>
			<configuration>
				<descriptorRefs>
					<descriptorRef>config</descriptorRef>
				</descriptorRefs>
				<appendAssemblyId>false</appendAssemblyId>
			</configuration>
			<goals>
				<goal>single</goal>

			</goals>
			</execution>
	</executions>
	<configuration>
		<skipAssembly>true</skipAssembly>
	</configuration>
	<inherited>false</inherited> <!-- so skip isn't inherited -->
</plugin>


So as you can see, inside execution i enable inheritance and outside
execution i configure the plugin to skip the run using the skipAssembly
configuration and disable inheritance


Notice that this still starts the plugin execution, but the run will end
very early when it detects it will be skipped. This might be a problem when
e.g. the plugin has a mandatory config argument that you define in the
children. In that case, the verification for the parameter will make the
build fail before you get to skip it


I know this is limited but maybe your plugin has such a configuration. or
if you wrote it yourself you can add it



If this is not useful, take a look at this. The answer was not useful to me
but the discussion is there anyway

http://stackoverflow.com/questions/1625492/execute-maven-plugin-goal-on-child-modules-but-not-on-parent




Alejandro Endo | Software Designer/Concepteur de logiciels




From:	laredotornado-3 <la...@gmail.com>
To:	users@maven.apache.org,
Date:	02/04/2013 02:07 PM
Subject:	Can I force a plugin to not run during parent pom execution
            phase?



Hi,

I'm using Maven 3.0.3.  I've included this plugin in a profile in my parent
pom, however, when I run my parent pom, I don't want this to be executed as
part of the parent pom being built (I do want it executed for each of the
child modules).  How can I make this plugin not run during the parent
execution phase?

		 <modelVersion>4.0.0</modelVersion>
		 <groupId>org.mainco.subco</groupId>
		 <artifactId>subco</artifactId>
		 <version>12.0.0-SNAPSHOT</version>
		 <modules>
		 		 <module>moduleA</module>
		 		 <module>moduleB</module>
		 		 <module>moduleC</module>
		 		 <packaging>pom</packaging>

		 <profiles>
		 		 <profile>
		 		 		 ...
		 		 		 		 		 <plugin>

<groupId>org.liquibase</groupId>

<artifactId>liquibase-maven-plugin</artifactId>

<version>2.0.1</version>

<dependencies>

	 <dependency>

	 		 <groupId>mysql</groupId>

	 		 <artifactId>mysql-connector-java</artifactId>

	 		 <version>5.1.18</version>

	 </dependency>

</dependencies>

<executions>

	 <execution>

	 		 <id>build-database</id>

	 		 <phase>process-test-resources</phase>

	 		 <configuration>

	 		 		 <driver>com.mysql.jdbc.Driver</driver>


<url>jdbc:mysql://${test.mysql.db.host}:${test.mysql.db.port}/$
{test.mysql.db.sid}</url>

	 		 		 <username>${test.mysql.db.user}</username>

	 		 		 <password>$
{test.mysql.db.password}</password>


<changeLogFile>$
{project.build.directory}/db.changelog-master.xml</changeLogFile>


<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>

	 		 </configuration>

	 		 <goals>

	 		 		 <goal>update</goal>

	 		 </goals>

	 </execution>

</executions>
		 		 		 		 		 </plugin>

Thanks, - Dave




--
View this message in context:
http://maven.40175.n5.nabble.com/Can-I-force-a-plugin-to-not-run-during-parent-pom-execution-phase-tp5752479.html

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


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: Can I force a plugin to not run during parent pom execution phase?

Posted by Barrie Treloar <ba...@gmail.com>.
On 3 April 2013 23:39, Wayne Fay <wa...@gmail.com> wrote:

> IMO the right way of doing this is to use pluginManagement and add 1-2
> lines referring to this plugin in the various children poms where the
> plugin should be executed. This also satisfies the "least surprise"
> test.
>

It is better to "positively" configure where this is needed, rather than
"negatively" disable it because of over-specifying the plugin.
The main reason being that at some point in the future you will add a new
module that does something completely different and you will need to add a
negative thing as well.
It just doesn't make sense to do this.

Just add it where it is needed.

Re: Can I force a plugin to not run during parent pom execution phase?

Posted by Wayne Fay <wa...@gmail.com>.
> Actually I don't see that as a trick at all.

This breaks my "principle of least surprise" test. Without being
explicitly told what that pom fragment would do or running it myself,
I wouldn't be entirely certain how Maven would be behave in the parent
or in the children.

> If a future version of Maven were to break the feature (add the same
> execution twice, once with inherited=true and the second with
> inherited=false and the inherited=false configuration is closer so wins)
> then I would consider that a serious bug.

On that basis alone, I agree this could be perceived as "not a bug."
But unless we are certain this is desired functionality -AND- there is
a specific IT test to capture this functionality to avoid regressions,
I'd be a little bit wary of using it myself.

IMO the right way of doing this is to use pluginManagement and add 1-2
lines referring to this plugin in the various children poms where the
plugin should be executed. This also satisfies the "least surprise"
test.

Wayne

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


Re: Can I force a plugin to not run during parent pom execution phase?

Posted by Stephen Connolly <st...@gmail.com>.
Actually I don't see that as a trick at all.

If a future version of Maven were to break the feature (add the same
execution twice, once with inherited=true and the second with
inherited=false and the inherited=false configuration is closer so wins)
then I would consider that a serious bug.

Just my €0.02


On 3 April 2013 03:05, Wayne Fay <wa...@gmail.com> wrote:

> > Thanks to all for your answers.  Alejandro, tried yours and it worked.
>  Loved
> > the fact it didn't require any configurations in the child projects.
>  Rock
>
> I'd be slightly concerned with his answer (trick) because it seems
> like a bug that might get fixed at some point. So long as you realize
> this may occur, go ahead and use it, but don't be surprised if a
> future release fixes this loophole.
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Can I force a plugin to not run during parent pom execution phase?

Posted by Wayne Fay <wa...@gmail.com>.
> Thanks to all for your answers.  Alejandro, tried yours and it worked.  Loved
> the fact it didn't require any configurations in the child projects.  Rock

I'd be slightly concerned with his answer (trick) because it seems
like a bug that might get fixed at some point. So long as you realize
this may occur, go ahead and use it, but don't be surprised if a
future release fixes this loophole.

Wayne

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


Re: Can I force a plugin to not run during parent pom execution phase?

Posted by laredotornado-3 <la...@gmail.com>.
Thanks to all for your answers.  Alejandro, tried yours and it worked.  Loved
the fact it didn't require any configurations in the child projects.  Rock
on, - Dave



--
View this message in context: http://maven.40175.n5.nabble.com/Can-I-force-a-plugin-to-not-run-during-parent-pom-execution-phase-tp5752479p5752505.html
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: Can I force a plugin to not run during parent pom execution phase?

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Hello Dave,

you could try to activate this profile depending on the existence of a
given file in your modules, e.g. the existence of a
src/test/resources/liquibase.properties (see
http://www.liquibase.org/manual/liquibase.properties).

Regards
Mirko

Regards Mirko
-- 
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/
https://bitbucket.org/mfriedenhagen/


On Tue, Apr 2, 2013 at 8:07 PM, laredotornado-3 <la...@gmail.com>wrote:

> Hi,
>
> I'm using Maven 3.0.3.  I've included this plugin in a profile in my parent
> pom, however, when I run my parent pom, I don't want this to be executed as
> part of the parent pom being built (I do want it executed for each of the
> child modules).  How can I make this plugin not run during the parent
> execution phase?
>
>         <modelVersion>4.0.0</modelVersion>
>         <groupId>org.mainco.subco</groupId>
>         <artifactId>subco</artifactId>
>         <version>12.0.0-SNAPSHOT</version>
>         <modules>
>                 <module>moduleA</module>
>                 <module>moduleB</module>
>                 <module>moduleC</module>
>                 <packaging>pom</packaging>
>
>         <profiles>
>                 <profile>
>                         ...
>                                         <plugin>
>
> <groupId>org.liquibase</groupId>
>
> <artifactId>liquibase-maven-plugin</artifactId>
>                                                 <version>2.0.1</version>
>                                                 <dependencies>
>                                                         <dependency>
>
> <groupId>mysql</groupId>
>
> <artifactId>mysql-connector-java</artifactId>
>
> <version>5.1.18</version>
>                                                         </dependency>
>                                                 </dependencies>
>                                                 <executions>
>                                                         <execution>
>
> <id>build-database</id>
>
> <phase>process-test-resources</phase>
>
> <configuration>
>
> <driver>com.mysql.jdbc.Driver</driver>
>
>
> <url>jdbc:mysql://${test.mysql.db.host}:${test.mysql.db.port}/${test.mysql.db.sid}</url>
>
> <username>${test.mysql.db.user}</username>
>
> <password>${test.mysql.db.password}</password>
>
>
> <changeLogFile>${project.build.directory}/db.changelog-master.xml</changeLogFile>
>
> <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
>
> </configuration>
>                                                                 <goals>
>
> <goal>update</goal>
>                                                                 </goals>
>                                                         </execution>
>                                                 </executions>
>                                         </plugin>
>
> Thanks, - Dave
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Can-I-force-a-plugin-to-not-run-during-parent-pom-execution-phase-tp5752479.html
> 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: Can I force a plugin to not run during parent pom execution phase?

Posted by Baptiste MATHUS <bm...@batmat.net>.
At first sight, I'd say this is a use case for pluginManagement.
You'd need to add the configuration you show above inside the
<pluginManagement> part in your parent pom.

Then, in each child module where you want to execute maven-antrun-plugin
based on that config, you just put:
<build>
 <plugins>
  <plugin>
     <artifactId>maven-antrun-plugin</artifactId>
  </plugin>
 </plugins>
</build>

Anything you put inside the pluginManagement part in your parent pom will
get inherited here when used, but actually not executed for the parent pom
(unless you also it inside the build/plugins part, obviously).

Another convoluted way could have been to tweak this based on a profile
activation declared in the parent, and only activated in the children, but
it doesn't seem possible:
http://stackoverflow.com/questions/1504850/maven-activate-child-profile-based-on-property


-- Cheers


2013/4/2 laredotornado-3 <la...@gmail.com>

> Hi,
>
> I'm using Maven 3.0.3.  I've included this plugin in a profile in my parent
> pom, however, when I run my parent pom, I don't want this to be executed as
> part of the parent pom being built (I do want it executed for each of the
> child modules).  How can I make this plugin not run during the parent
> execution phase?
>
>         <modelVersion>4.0.0</modelVersion>
>         <groupId>org.mainco.subco</groupId>
>         <artifactId>subco</artifactId>
>         <version>12.0.0-SNAPSHOT</version>
>         <modules>
>                 <module>moduleA</module>
>                 <module>moduleB</module>
>                 <module>moduleC</module>
>                 <packaging>pom</packaging>
>
>         <profiles>
>                 <profile>
>                         ...
>                                         <plugin>
>
> <groupId>org.liquibase</groupId>
>
> <artifactId>liquibase-maven-plugin</artifactId>
>                                                 <version>2.0.1</version>
>                                                 <dependencies>
>                                                         <dependency>
>
> <groupId>mysql</groupId>
>
> <artifactId>mysql-connector-java</artifactId>
>
> <version>5.1.18</version>
>                                                         </dependency>
>                                                 </dependencies>
>                                                 <executions>
>                                                         <execution>
>
> <id>build-database</id>
>
> <phase>process-test-resources</phase>
>
> <configuration>
>
> <driver>com.mysql.jdbc.Driver</driver>
>
>
> <url>jdbc:mysql://${test.mysql.db.host}:${test.mysql.db.port}/${test.mysql.db.sid}</url>
>
> <username>${test.mysql.db.user}</username>
>
> <password>${test.mysql.db.password}</password>
>
>
> <changeLogFile>${project.build.directory}/db.changelog-master.xml</changeLogFile>
>
> <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
>
> </configuration>
>                                                                 <goals>
>
> <goal>update</goal>
>                                                                 </goals>
>                                                         </execution>
>                                                 </executions>
>                                         </plugin>
>
> Thanks, - Dave
>
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Can-I-force-a-plugin-to-not-run-during-parent-pom-execution-phase-tp5752479.html
> 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
>
>


-- 
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !