You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by alanhay <Al...@cigna.com> on 2011/01/12 15:37:12 UTC

Plugin Execution Config : Remove Duplication

I have something like the following to generate two WARs during the install
phase, with resources filtered differently for each WAR war_name_UK.war,
war_name_SP.war. 

Everything works as expected however there is obviously a lot of duplication
(in some POMs I have to generate 5 different WARs) and all that differs
between the <execution/> blocks is the ID, classifer and filtered file names
UK or SP.

Is there a cleaner way to do this?

Generates two WAR files one suffixed _UK and one _SP:

===========================================

<plugin>
	<artifactId>maven-war-plugin</artifactId>
	<version>2.1.1</version>
	<configuration>
		 <classifier>UK</classifier>
		 <warSourceExcludes>**/*web.xml</warSourceExcludes>
		 <filters>
			 
<filter>${project.basedir}/build_properties/uk.build.properties</filter>
		 </filters>
		 <webResources>
			  <resource>
				   <directory>src/main/filtered</directory>
				   <filtering>true</filtering>
				   <targetPath>WEB-INF</targetPath>
			  </resource>
			  <resource>
				   <directory>src/main/config</directory>
				   <targetPath>WEB-INF/config</targetPath>
				   <filtering>false</filtering>
			  </resource>
		 </webResources>
	</configuration>

	<executions>
		 <execution>
			  <id>SP</id>
			  <configuration>
				   <classifier>SP</classifier>
				   <warSourceExcludes>**/*web.xml</warSourceExcludes>
				   <filters>
					
<filter>${project.basedir}/build_properties/sp.build.properties</filter>
				   </filters>
				   <webResources>
						<resource>
							 <directory>src/main/filtered</directory>
							 <filtering>true</filtering>
							 <targetPath>WEB-INF</targetPath>
						</resource>
						<resource>
							 <directory>src/main/config</directory>
							 <targetPath>WEB-INF/config</targetPath>
							 <filtering>false</filtering>
						</resource>
				   </webResources>
			  </configuration>
			  <goals>
				   <goal>war</goal>
			  </goals>
		 </execution>
	</executions>
</plugin>
-- 
View this message in context: http://maven.40175.n5.nabble.com/Plugin-Execution-Config-Remove-Duplication-tp3338224p3338224.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: Plugin Execution Config : Remove Duplication

Posted by alanhay <Al...@cigna.com>.
Thanks Mike. Defining in a Parent POM was what i was thinking but am unsure
exactly how this might look.

I will have a play about with it and see how it goes.


Alan



-- 
View this message in context: http://maven.40175.n5.nabble.com/Plugin-Execution-Config-Remove-Duplication-tp3338224p3339431.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: Plugin Execution Config : Remove Duplication

Posted by Mike Calmus <mi...@calmus.org>.
You should be able to put all this into a parent pom. Use variables for the
items that vary and then simply override the variables in the implementation
pom files.

On Wed, Jan 12, 2011 at 9:37 AM, alanhay <Al...@cigna.com> wrote:

>
> I have something like the following to generate two WARs during the install
> phase, with resources filtered differently for each WAR war_name_UK.war,
> war_name_SP.war.
>
> Everything works as expected however there is obviously a lot of
> duplication
> (in some POMs I have to generate 5 different WARs) and all that differs
> between the <execution/> blocks is the ID, classifer and filtered file
> names
> UK or SP.
>
> Is there a cleaner way to do this?
>
> Generates two WAR files one suffixed _UK and one _SP:
>
> ===========================================
>
> <plugin>
>        <artifactId>maven-war-plugin</artifactId>
>        <version>2.1.1</version>
>        <configuration>
>                 <classifier>UK</classifier>
>                 <warSourceExcludes>**/*web.xml</warSourceExcludes>
>                 <filters>
>
> <filter>${project.basedir}/build_properties/uk.build.properties</filter>
>                 </filters>
>                 <webResources>
>                          <resource>
>                                   <directory>src/main/filtered</directory>
>                                   <filtering>true</filtering>
>                                   <targetPath>WEB-INF</targetPath>
>                          </resource>
>                          <resource>
>                                   <directory>src/main/config</directory>
>                                   <targetPath>WEB-INF/config</targetPath>
>                                   <filtering>false</filtering>
>                          </resource>
>                 </webResources>
>        </configuration>
>
>        <executions>
>                 <execution>
>                          <id>SP</id>
>                          <configuration>
>                                   <classifier>SP</classifier>
>
> <warSourceExcludes>**/*web.xml</warSourceExcludes>
>                                   <filters>
>
> <filter>${project.basedir}/build_properties/sp.build.properties</filter>
>                                   </filters>
>                                   <webResources>
>                                                <resource>
>
> <directory>src/main/filtered</directory>
>
> <filtering>true</filtering>
>
> <targetPath>WEB-INF</targetPath>
>                                                </resource>
>                                                <resource>
>
> <directory>src/main/config</directory>
>
> <targetPath>WEB-INF/config</targetPath>
>
> <filtering>false</filtering>
>                                                </resource>
>                                   </webResources>
>                          </configuration>
>                          <goals>
>                                   <goal>war</goal>
>                          </goals>
>                 </execution>
>        </executions>
> </plugin>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Plugin-Execution-Config-Remove-Duplication-tp3338224p3338224.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
>
>