You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by motes motes <mo...@gmail.com> on 2011/11/02 23:01:07 UTC

Common build jobs for sub modules should not be executed in parent

I have the following project structure:

parent
  |-> childA
  |-> childB

Is it possible to put a build task/plugin in the parent which is
common for childA and childB but should not be applied to the parent?

Eg.:

In childA and childB I have some identical build tasks using eg.
maven-antrun-plugin, maven-resources-plugin etc. and I would like to
eliminate this duplication.

I have tried to move these identical build tasks to the build scope in
the parent pom like:

<build>
...
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<configuration>
					<nonFilteredFileExtensions>
						<nonFilteredFileExtension>ico</nonFilteredFileExtension>
					</nonFilteredFileExtensions>
				</configuration>
				<executions>
					<execution>
						<id>copy-resources</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${data.basedir}</outputDirectory>
							<resources>
								<resource>
									<directory>data</directory>
									<filtering>true</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
					<execution>
						<id>filter-spec-file</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${basedir}</outputDirectory>
							<resources>
								<resource>
							        <filtering>true</filtering>
							        <directory>${basedir}/unfiltered</directory>
							        <includes>
							          <include>**/*.dat</include>
							        </includes>								
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
...
</build>


but it fails since it first tries to run the build plugin on the
parent which does not make sense - since its only the child modules
that have the specified files/directories.

So are there any way to remove build duplication for sub modules and
put them in a simple pom parent?

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


Re: Common build jobs for sub modules should not be executed in parent

Posted by Barrie Treloar <ba...@gmail.com>.
On Thu, Nov 3, 2011 at 8:29 PM, motes motes <mo...@gmail.com> wrote:
> Thanks!

Can I recommend you read the freely available books at
http://maven.apache.org/articles.html
You will save yourself a lot of time.

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


Re: Common build jobs for sub modules should not be executed in parent

Posted by motes motes <mo...@gmail.com>.
Thanks!

On Thu, Nov 3, 2011 at 3:03 AM, Wayne Fay <wa...@gmail.com> wrote:
>> Is it possible to put a build task/plugin in the parent which is
>> common for childA and childB but should not be applied to the parent?
>
> Sounds like you are looking for a way to MANAGE your PLUGINS, right?
>
> http://maven.apache.org/pom.html#Plugin_Management
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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


Re: Common build jobs for sub modules should not be executed in parent

Posted by Wayne Fay <wa...@gmail.com>.
> Is it possible to put a build task/plugin in the parent which is
> common for childA and childB but should not be applied to the parent?

Sounds like you are looking for a way to MANAGE your PLUGINS, right?

http://maven.apache.org/pom.html#Plugin_Management

Wayne

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