You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Entner Harald <En...@afb.de> on 2009/09/24 12:01:49 UTC
copy file from dependent jar
Hello,
i face the following problem. Currently i'm refactoring a project so
that i can move from ant to maven. It works rather well (i have done
this in my old company as well), but some special cases occur. Most of
them i could fix, but one causes me a headache.
This is the simple view of the project layout:
Proj1
Resource1.xsd
Proj2
Proj3
The thing is, that Proj3 (actually all Webservices) needs Resource1
(besides it should do some replacements on the content of Resource1.xd).
So far ant copies the file using relative paths. I would really like to
avoid that (it would be easy with relative paths), because it adds a lot
of dependencies. (the project structure is much bigger and has a lot of
subprojects, the file is needed in many places).
So one solution would be to use the maven-resource-plugin and let it
copy the resource (additionally it could do the replacement).
Unfortunately, it only works with paths, but not with dependent
projects. Or am i missing something?
The solution i am thinking about is to use the dependency plugin and
copy the resource first (it can handle dependent jars) and place it in a
predefined-(project)-place (i think i can put it into the parent pom,
and hopefully this will work under all circumstances). Then i could use
the resource-plugin to do the rest and so i only have the resource
plugin inside the project poms.
The bad thing is that i need a second parent. Because Proj1 should not
execute dependency:copy (as it is depends on itself). I could leave the
phase undefined, but then i would have to add the plugin in every
project pom, which i would like to avoid. I think i could live with this
solution, but i m wondering if nobody had the same problem and maybe
there is a better solution.
Every input is appreciated.
regards, Harald
Re: AW: copy file from dependent jar
Posted by Daniel Kulp <dk...@apache.org>.
On Sun September 27 2009 7:28:48 pm Brett Porter wrote:
> On 25/09/2009, at 6:24 PM, Entner Harald wrote:
> > The ant script has in my opinion a bad side effect. The structure is
> > not allowed to change, so i would prefer to use dependencies so
> > structure changes would have no side effects.
> >
> > Currently i use the maven-dependency-plugin that copies the file to
> > a defined position and wrote a plugin that handles the extraction
> > and the replacement.
>
> That's a reasonable solution (though I'm not sure why copying to a
> defined location is needed, you should be able to refer to it from the
> dependency:unpack location).
>
> However, the CXF codegen plugin also has an option to download the
> WSDL from a Maven artifact:
> http://cwiki.apache.org/CXF20DOC/maven-cxf-codegen-plugin-wsdl-to-java.htm
> l (at the bottom) which will work better for you.
One complication was that code was just added to CXF two weeks ago. It's not
released yet. SNAPSHOTs should have it though.
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
AW: AW: copy file from dependent jar
Posted by Entner Harald <En...@afb.de>.
Thx all for your input!
i'm currently using maven-dependency-plugin and unpack. It works perfectly, when one wants to extract a file from a dependent jar. Here's the code snipped, for those who are searching for a similar solution: Easy when you know the right plugin for the right job :). Especially because all logic is situated in parent poms (besides the special cases) - as i like it.
<!-- unpack xsd's of afbcommon.jar to temp, where temp is ${project.build.directory}/temp -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>de.afb</groupId>
<artifactId>afbCommon</artifactId>
<version>1.0-SNAPSHOT</version>
<outputDirectory>${temp.directory}</outputDirectory>
<includes>*.xsd</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
> That's a reasonable solution (though I'm not sure why copying to a
> defined location is needed, you should be able to refer to it from the
> dependency:unpack location).
@Brett: yes indeed, that was my plan. The temp directory IS the predefined position.
-----Ursprüngliche Nachricht-----
Von: Brett Porter [mailto:brett@porterclan.net] Im Auftrag von Brett Porter
Gesendet: Montag, 28. September 2009 01:29
An: Maven Users List
Betreff: Re: AW: copy file from dependent jar
On 25/09/2009, at 6:24 PM, Entner Harald wrote:
> The ant script has in my opinion a bad side effect. The structure is
> not allowed to change, so i would prefer to use dependencies so
> structure changes would have no side effects.
>
> Currently i use the maven-dependency-plugin that copies the file to
> a defined position and wrote a plugin that handles the extraction
> and the replacement.
That's a reasonable solution (though I'm not sure why copying to a
defined location is needed, you should be able to refer to it from the
dependency:unpack location).
However, the CXF codegen plugin also has an option to download the
WSDL from a Maven artifact: http://cwiki.apache.org/CXF20DOC/maven-cxf-codegen-plugin-wsdl-to-java.html
(at the bottom) which will work better for you.
- Brett
---------------------------------------------------------------------
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: AW: copy file from dependent jar
Posted by Brett Porter <br...@apache.org>.
On 25/09/2009, at 6:24 PM, Entner Harald wrote:
> The ant script has in my opinion a bad side effect. The structure is
> not allowed to change, so i would prefer to use dependencies so
> structure changes would have no side effects.
>
> Currently i use the maven-dependency-plugin that copies the file to
> a defined position and wrote a plugin that handles the extraction
> and the replacement.
That's a reasonable solution (though I'm not sure why copying to a
defined location is needed, you should be able to refer to it from the
dependency:unpack location).
However, the CXF codegen plugin also has an option to download the
WSDL from a Maven artifact: http://cwiki.apache.org/CXF20DOC/maven-cxf-codegen-plugin-wsdl-to-java.html
(at the bottom) which will work better for you.
- Brett
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
AW: copy file from dependent jar
Posted by Entner Harald <En...@afb.de>.
Hi Brett,
Yes, Resource1.xsd is part of Proj1. And there is a dependency between Proj3 and Proj1.
Maybe i should explain it differently:
I need to run wsdl2java (i use the cxf plugin for that) which needs the Resource1.xsd to be able to run correctly. Additionally some namespaces have to be adapted.
So i need to extract one file from a dependent artifact, place it in a project specific directory and do some replacements.
The build script (in ant) looks like this:
<target name="copyXSDs" description="Copy XSDs to src/conf/xml-resources/....">
<copy file="${cms.root}/Common/afbCommon/xsd/xxxGlobal.xsd" todir="${xsd.dest}"/>
</target>
The ant script has in my opinion a bad side effect. The structure is not allowed to change, so i would prefer to use dependencies so structure changes would have no side effects.
Currently i use the maven-dependency-plugin that copies the file to a defined position and wrote a plugin that handles the extraction and the replacement.
regards,
Harald
-----Ursprüngliche Nachricht-----
Von: Brett Porter [mailto:brett@porterclan.net] Im Auftrag von Brett Porter
Gesendet: Freitag, 25. September 2009 03:55
An: Maven Users List
Betreff: Re: copy file from dependent jar
I'm a bit lost. Is Resource1 already included in Proj1 and is Proj1 a
dependency of Proj3?
- Brett
On 24/09/2009, at 8:01 PM, Entner Harald wrote:
> Hello,
>
>
>
> i face the following problem. Currently i'm refactoring a project so
> that i can move from ant to maven. It works rather well (i have done
> this in my old company as well), but some special cases occur. Most of
> them i could fix, but one causes me a headache.
>
>
>
> This is the simple view of the project layout:
>
>
>
> Proj1
>
> Resource1.xsd
>
> Proj2
>
> Proj3
>
>
>
>
>
> The thing is, that Proj3 (actually all Webservices) needs Resource1
> (besides it should do some replacements on the content of
> Resource1.xd).
> So far ant copies the file using relative paths. I would really like
> to
> avoid that (it would be easy with relative paths), because it adds a
> lot
> of dependencies. (the project structure is much bigger and has a lot
> of
> subprojects, the file is needed in many places).
>
>
>
> So one solution would be to use the maven-resource-plugin and let it
> copy the resource (additionally it could do the replacement).
> Unfortunately, it only works with paths, but not with dependent
> projects. Or am i missing something?
>
>
>
>
>
> The solution i am thinking about is to use the dependency plugin and
> copy the resource first (it can handle dependent jars) and place it
> in a
> predefined-(project)-place (i think i can put it into the parent pom,
> and hopefully this will work under all circumstances). Then i could
> use
> the resource-plugin to do the rest and so i only have the resource
> plugin inside the project poms.
>
>
>
> The bad thing is that i need a second parent. Because Proj1 should not
> execute dependency:copy (as it is depends on itself). I could leave
> the
> phase undefined, but then i would have to add the plugin in every
> project pom, which i would like to avoid. I think i could live with
> this
> solution, but i m wondering if nobody had the same problem and maybe
> there is a better solution.
>
>
>
> Every input is appreciated.
>
>
>
> regards, Harald
>
---------------------------------------------------------------------
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: copy file from dependent jar
Posted by Brett Porter <br...@apache.org>.
I'm a bit lost. Is Resource1 already included in Proj1 and is Proj1 a
dependency of Proj3?
- Brett
On 24/09/2009, at 8:01 PM, Entner Harald wrote:
> Hello,
>
>
>
> i face the following problem. Currently i'm refactoring a project so
> that i can move from ant to maven. It works rather well (i have done
> this in my old company as well), but some special cases occur. Most of
> them i could fix, but one causes me a headache.
>
>
>
> This is the simple view of the project layout:
>
>
>
> Proj1
>
> Resource1.xsd
>
> Proj2
>
> Proj3
>
>
>
>
>
> The thing is, that Proj3 (actually all Webservices) needs Resource1
> (besides it should do some replacements on the content of
> Resource1.xd).
> So far ant copies the file using relative paths. I would really like
> to
> avoid that (it would be easy with relative paths), because it adds a
> lot
> of dependencies. (the project structure is much bigger and has a lot
> of
> subprojects, the file is needed in many places).
>
>
>
> So one solution would be to use the maven-resource-plugin and let it
> copy the resource (additionally it could do the replacement).
> Unfortunately, it only works with paths, but not with dependent
> projects. Or am i missing something?
>
>
>
>
>
> The solution i am thinking about is to use the dependency plugin and
> copy the resource first (it can handle dependent jars) and place it
> in a
> predefined-(project)-place (i think i can put it into the parent pom,
> and hopefully this will work under all circumstances). Then i could
> use
> the resource-plugin to do the rest and so i only have the resource
> plugin inside the project poms.
>
>
>
> The bad thing is that i need a second parent. Because Proj1 should not
> execute dependency:copy (as it is depends on itself). I could leave
> the
> phase undefined, but then i would have to add the plugin in every
> project pom, which i would like to avoid. I think i could live with
> this
> solution, but i m wondering if nobody had the same problem and maybe
> there is a better solution.
>
>
>
> Every input is appreciated.
>
>
>
> regards, Harald
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org