Discussion:
maven-dependency-plugin: Question about copy-dependencies goal
Luciano Mantuaneli
2010-04-26 14:23:19 UTC
Permalink
Greetings.



I have a very specific need in a java project in Eclipse: The jars which
the project depends on must be copied to an external folder.



The maven-dependency-plugin and its copy-dependencies goal come to mind
immediately.



As a test, I wrote the following pom.xml:



-----

<project ...>

...

<build>

...

<plugins>

...

<plugin>


<groupId>org.apache.maven.plugins</groupId>


<artifactId>maven-dependency-plugin</artifactId>

<executions>

<execution>


<id>copy-dependencies</id>


<phase>process-resources</phase>


<goals>


<goal>copy-dependencies</goal>


</goals>


<configuration>


<outputDirectory>${my.external.location}/alterloc</outputDirectory>


<excludeArtifactIds>servlet-api</excludeArtifactIds>


</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

</project>

-----



However, the above pom shows some bogus behavior, depending on the user
action:

1) Right-clicking the project and selecting "Maven >
Update Project Configuration": The folder "alterloc" is created in
"my.external.location", and the jars, but servlet-api, are copied to it
- Just as expected.

2) Compiling the project: The folder "dependency" is
created in "project.build.directory", and the jars, including
servlet-api, are copied to it - Not expected, once the configurations
seems to be ignored



I already tried to change the phase to "compile", to "process-classes",
but in that case it's even worst: The dependencies wasn't copied at all.



What am I doing wrong?



Thanks in advance





Luciano Mantuaneli <http://www.linkedin.com/in/lucianomantuaneli>



TI Melhorias - Suporte a Canais



CPM Braxis

Cel: 55 11 8399 0319

Tel: 55 11 4196 4622

www.cpm.com.br <http://www.cpm.com.br>

www.cpminternational.com <http://www.cpminternational.com>

www.braxis.com.br <http://www.braxis.com.br>
Karl Heinz Marbaise
2010-04-26 15:16:00 UTC
Permalink
Hi,
Post by Luciano Mantuaneli
<project ...>
<phase>process-resources</phase>
Have you thought about linking the plugin to the package phase for example....

and did you tried that on command line ?

Kind regards
Karl Heinz Marbaise
--
MfG
Karl Heinz Marbaise
--
SoftwareEntwicklung Beratung Schulung Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl Heinz Marbaise ICQ#: 135949029
Hauptstrasse 177 USt.IdNr: DE191347579
52146 Würselen http://www.soebes.de
Luciano Mantuaneli
2010-04-26 16:28:42 UTC
Permalink
Hi, Karl. Thanks for answering!
Have you thought about linking the plugin to the package phase for >example....
and did you tried that on command line ?
I wish I could, but it's not possible due to restrictions on the specification of this job. It's imperative that the "magic" happens while using Eclipse and it must be at the moment that he builds (just compile) the project.

I know that this is pretty dumb and this is not the correct way to proceed, but I don't have the permission to change those restrictions...

If you need, I'll gladly explain more about this bizarre task I have to manage... I really enjoy making people laugh!

Luciano Mantuaneli
TI Melhorias - Suporte a Canais

CPM Braxis
Cel: 55 11 8399 0319
Tel: 55 11 4196 4622
www.cpm.com.br
www.cpminternational.com
www.braxis.com.br
-----Mensagem original-----
De: Karl Heinz Marbaise [mailto:***@gmx.de]
Enviada em: segunda-feira, 26 de abril de 2010 12:16
Para: Maven Users List; ***@maven.apache.org
Assunto: Re: maven-dependency-plugin: Question about copy-dependencies goal

Hi,
<project ...>
<phase>process-resources</phase>
Have you thought about linking the plugin to the package phase for example....

and did you tried that on command line ?

Kind regards
Karl Heinz Marbaise
--
MfG
Karl Heinz Marbaise
--
SoftwareEntwicklung Beratung Schulung Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl Heinz Marbaise ICQ#: 135949029
Hauptstrasse 177 USt.IdNr: DE191347579
52146 Würselen http://www.soebes.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@maven.apache.org
For additional commands, e-mail: users-***@maven.apache.org
Brian Fox
2010-04-27 18:05:35 UTC
Permalink
When you compile in eclipse using m2e it's not executing the lifecycle. How
are you executing the build, exactly?

On Mon, Apr 26, 2010 at 10:23 AM, Luciano Mantuaneli <
Post by Luciano Mantuaneli
Greetings.
I have a very specific need in a java project in Eclipse: The jars which
the project depends on must be copied to an external folder.
The *maven-dependency-plugin* and its *copy-*dependencies goal come to
mind immediately.
-----
<project ...>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${my.external.location}/alterloc</outputDirectory>
<excludeArtifactIds>servlet-api</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
-----
However, the above pom shows some bogus behavior, depending on the user
1) Right-clicking the project and selecting “Maven >
Update Project Configuration”: The folder “alterloc” is created in
“my.external.location”, and the jars, but servlet-api, are copied to it -
Just as expected.
2) Compiling the project: The folder “dependency” is
created in “project.build.directory”, and the jars, including servlet-api,
are copied to it – Not expected, once the configurations seems to be ignored
I already tried to change the phase to “compile”, to “process-classes”, but
in that case it’s even worst: The dependencies wasn’t copied at all.
What am I doing wrong?
Thanks in advance
*Luciano Mantuaneli ** <http://www.linkedin.com/in/lucianomantuaneli>*
TI Melhorias - Suporte a Canais
*CPM Braxis*
Cel: 55 11 8399 0319
Tel: 55 11 4196 4622
www.cpm.com.br
www.cpminternational.com
www.braxis.com.br
Loading...