You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by alesky <al...@gmail.com> on 2012/04/26 18:14:15 UTC

how to copy-dependencies related to one profile

Hi guys

i have a question related to the use of the copy-dependencies plugin.
with the target to copy only the dependences of a related profile.

In my project i have 2 profile one used for the develop and another one used
for the production
the develop is configure to be active by default 


the dependences are defined outside the profiles if are common for both, or
specific dependences are inside the profile that need them.

Inside the production profile is defined in the build section of the mvn.xml
file the configuration of the maven dependences plug-in 

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
		<execution>
			<id>copy-dependencies</id>
			<phase>package</phase>
			<goals>
				<goal>copy-dependencies</goal>
			</goals>
			<configuration>
				<outputDirectory>target/dist/lib</outputDirectory>
				<overWriteReleases>true</overWriteReleases>
				<overWriteSnapshots>true</overWriteSnapshots>
				<overWriteIfNewer>true</overWriteIfNewer>
			</configuration>
		</execution>
	</executions>
</plugin>

the issue is when i run the package phase from command line with the flag
that identify that i'm using the  production profile,  
the dependences are copied, but the plug-in doesn't care what is the list of
dependences definition related to the profile production, it copy always all
the dependences and the indirect dependences and dont take care about the
profile and the dependences defined in it

it is the normale beavour of the plug-in? 
and in case... if i have to manage two different production environment with
two different application server, so dependences needed are different how
can i manage the configuration in the pom files and let to maven to help me
to undestand what are the required dependences based on the profile?

thanks








--
View this message in context: http://maven.40175.n5.nabble.com/how-to-copy-dependencies-related-to-one-profile-tp5668047p5668047.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: how to copy-dependencies related to one profile

Posted by Wayne Fay <wa...@gmail.com>.
> but this doesn't resolve my problem becouse i have to change every time the
> pom file to generate the production version and put back after the
> generation.

Perhaps instead of using profiles and 1 project, you should set this
up to use more than 1 project (one for dev, one for prod) and get rid
of profiles.

Wayne

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


Re: how to copy-dependencies related to one profile

Posted by Wayne Fay <wa...@gmail.com>.
> Another way to handle this might be to set the conflicting libraries as
> "provided" on both systems and make up run-time jars that are installed
> in the container's (tomcat or Websphere)  shared library.
> This way you could run the same WARs on both environments.
> You would just need an assembly project for each environment to build
> the right set of dependencies to provide.

Ron's approach is sound. Another way to handle this is via separate
artifacts -- so one might be called product-tomcat and another is
product-ws7 and a third is product-jbossee.

I'd probably prefer Ron's approach to this, to be honest. But this is
also viable. I am definitely not a fan of using profiles to decide
which dependencies come in to your build (and then maybe pushing them
out with classifiers etc) -- that is a total nonstarter for me.

Wayne

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


Re: how to copy-dependencies related to one profile

Posted by Ron Wheeler <rw...@artifact-software.com>.
Another way to handle this might be to set the conflicting libraries as 
"provided" on both systems and make up run-time jars that are installed 
in the container's (tomcat or Websphere)  shared library.
This way you could run the same WARs on both environments.
You would just need an assembly project for each environment to build 
the right set of dependencies to provide.

You probably only build these once per release cycle once you decide on 
the versions of the shared libraries that you want to use.

We did this in order to get control over versions of third party 
libraries and to reduce development time by reducing the build times.
We ended up with a set of about 10 common libraries (JSF, CXF, 
Spring-Hibernate-MySQL, jasper reports) that we put in Tomcat's shared 
library.
The wars got very small since they only only had our code in them.
We have over 40 projects that produced WARs and a few that made 
executable JARs so the saving is time and network bandwidth was significant.
It also made the container start a bit quicker.

 From a QA perspective it is a bit sounder since you run the same WAR in 
test and production without rebuilding it after you test it.

Ron


On 27/04/2012 12:20 PM, alesky wrote:
> Hi Jorg, thank for your response
>
> the dependences are different becouse i usually test the application in my
> machine with tomcat instead in production i use websphere 7 and soon i will
> have also another production envrionment for another customer with jboss
> enterprice edition
>
> so i would like to generate the application with all the dependences
> necessary for tomcat or websphere or jboss based on the profile
>
>
> this is one concrete example for the difference in the libraries
> el-libraries is not necessary with tomcat becouse is sheped with it and if i
> bring it the application doesn't start instead in websphere are necessary
>
> but there are a lot of case like this in my project
>
> for example i used axis2 for the generation of the client to call web
> services
> and to use this generated clients at run time in tomcat i have to use all
> the necessary dependences
> instead in websphere most of theme are not imported otherways i create big
> classpath issue
>
> anyway the activation of profiles base on properties values can help me for
> the generation of the distribution, i can use -Denvironment=websphere7 or
> -Denvironment=jboss
>
> but can be a problem in develop phase, becouse (i use eclipse) in this way
> the maven plugin will get not all the necessary libraries but only that one
> outside all the profiles that are the libraries common to all the profiles
>
> Jorg if u have a better solution i will be glade to hear
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/how-to-copy-dependencies-related-to-one-profile-tp5668047p5670743.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
>
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


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


Re: how to copy-dependencies related to one profile

Posted by alesky <al...@gmail.com>.
Hi Jorg, thank for your response

the dependences are different becouse i usually test the application in my
machine with tomcat instead in production i use websphere 7 and soon i will
have also another production envrionment for another customer with jboss
enterprice edition

so i would like to generate the application with all the dependences
necessary for tomcat or websphere or jboss based on the profile


this is one concrete example for the difference in the libraries
el-libraries is not necessary with tomcat becouse is sheped with it and if i
bring it the application doesn't start instead in websphere are necessary

but there are a lot of case like this in my project

for example i used axis2 for the generation of the client to call web
services 
and to use this generated clients at run time in tomcat i have to use all
the necessary dependences
instead in websphere most of theme are not imported otherways i create big
classpath issue

anyway the activation of profiles base on properties values can help me for
the generation of the distribution, i can use -Denvironment=websphere7 or
-Denvironment=jboss

but can be a problem in develop phase, becouse (i use eclipse) in this way
the maven plugin will get not all the necessary libraries but only that one
outside all the profiles that are the libraries common to all the profiles

Jorg if u have a better solution i will be glade to hear











--
View this message in context: http://maven.40175.n5.nabble.com/how-to-copy-dependencies-related-to-one-profile-tp5668047p5670743.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: how to copy-dependencies related to one profile

Posted by Jörg Schaible <jo...@gmx.de>.
alesky wrote:

> I did some test
> 
> and i undestant that it take always the dependences of the profile that is
> configured has default
> 
> <activation>
> <activeByDefault>true</activeByDefault>
> </activation>
> 
> in fact if i change the activation default in the production environment
> are copied only that dependences
> 
> but this doesn't resolve my problem becouse i have to change every time
> the pom file to generate the production version and put back after the
> generation.

Don't use activeByDefault. Use a property for activation. Activate one 
profile if it is set, the other one if it is not present.

However, what are the differences between those dependencies (please explain 
exactly what changes in GAV)? You understand that messing dependencies with 
profiles will typically cause some grieve?

- Jörg


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


Re: how to copy-dependencies related to one profile

Posted by alesky <al...@gmail.com>.
I did some test

and i undestant that it take always the dependences of the profile that is
configured has default

<activation>
		<activeByDefault>true</activeByDefault>
</activation>

in fact if i change the activation default in the production environment are
copied only that dependences

but this doesn't resolve my problem becouse i have to change every time the
pom file to generate the production version and put back after the
generation.


--
View this message in context: http://maven.40175.n5.nabble.com/how-to-copy-dependencies-related-to-one-profile-tp5668047p5668094.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