You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Wendy Smoak <ws...@gmail.com> on 2006/04/07 02:53:04 UTC

[m2] Including the source code in a war

We ship some example apps and have always included the source code
(src/main/java) under WEB-INF/src.

How do I do that with Maven 2?

We tried a couple of things with <resources> such as:
     <targetPath>../${pom.artifactId}/WEB-INF/src/main/java</targetPath>
and
     <targetPath>${basedir}/${pom.artifactId}/WEB-INF/src/main/java</targetPath>
but each would work for one developer and not another.  Strange.

You can see it here, possibly commented out:
   http://svn.apache.org/repos/asf/struts/action/trunk/apps/pom.xml

--
Wendy

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


Re: [m2] Including the source code in a war

Posted by Wendy Smoak <ws...@gmail.com>.
On 4/6/06, Martin Cooper <ma...@apache.org> wrote:
> Yes, I'm now of the belief that we can't treat this as a plain vanilla
> resource thing. However, looking at the source for the war plugin, I see
> that a <webResources> section is permitted, and it looks like this may do
> what you want. Unfortunately, my attempt to add this to the POM made no
> difference at all, so it may be that it hasn't made it into a release of the
> plugin yet. (Or I'm just doing it wrong, which is entirely possible. ;)

I don't see <webResources> listed here, so it's probably not in a release yet:
   http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html

Meanwhile, I solved it with an execution of the antrun plugin bound to
the process-sources phase.  It works, but... maven-copier-plugin,
anyone??

 *   http://svn.apache.org/repos/asf/struts/action/trunk/apps/pom.xml

Other ideas are welcome. :)

--
Wendy

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


Re: [m2] Including the source code in a war

Posted by Martin Cooper <ma...@apache.org>.
On 4/6/06, Wendy Smoak <ws...@gmail.com> wrote:
>
> On 4/6/06, Martin Cooper <ma...@apache.org> wrote:
>
> > > We tried a couple of things with <resources> such as:
> > >      <targetPath>../${pom.artifactId
> }/WEB-INF/src/main/java</targetPath>
> > > and
> > >      <targetPath>${basedir}/${pom.artifactId
> > > }/WEB-INF/src/main/java</targetPath>
> > > but each would work for one developer and not another.  Strange.
> >
> >
> > I'm probably misunderstanding, but why not just:
> >
> > <targetPath>${project.build.directory}/${pom.artifactId
> > }/WEB-INF/src/main/java</targetPath>
>
> Looks like I missed 'target' in the second path, it should have been
> ${basedir}/target/...
> And with that,
> <targetPath>${basedir}/target/${pom.artifactId
> }/WEB-INF/src/main/java</targetPath>
>
> I get this error:
> [INFO] Error copying resources
>
> Embedded error:
> c:\svn\struts\current\action\apps\cookbook\target\classes\c:\svn
>
> \struts\current\action\apps\cookbook\target\struts-cookbook\WEB-INF\src\main\jav
> a\examples\bean\ExampleBean.java (The filename, directory name, or volume
> label
> syntax is incorrect)
>
> (<finalName> is defined as ${pom.artifactId} for this build, so that
> the war files are named without version numbers.)
>
> I tried Martin's suggestion, but it just put the sources in
> (literally) WEB-INF/classes/${project.build.directory}/struts-cookbook/...
> Very strange that ${project.build.directory} wasn't evaluated, I
> think it works elsewhere.  But this suffers from the same problem that
> the path is relative to WEB-INF/classes.


Yep, I discovered the same things, including the weird ${
project.build.directory} not being expanded. That seems like it has to be a
bug.

So, since <resource>s are meant to be under target/classes, which ends
> up in WEB-INF/classes, trying to place things directly under WEB-INF
> with <resource> is causing problems.


Yes, I'm now of the belief that we can't treat this as a plain vanilla
resource thing. However, looking at the source for the war plugin, I see
that a <webResources> section is permitted, and it looks like this may do
what you want. Unfortunately, my attempt to add this to the POM made no
difference at all, so it may be that it hasn't made it into a release of the
plugin yet. (Or I'm just doing it wrong, which is entirely possible. ;)

--
Martin Cooper


All I need to do is copy some files from one place to another during
> the build... ISTR trying this once before though and not finding a
> Maven-approved solution.  Perhaps the antrun plugin would work?
>
> That or I've been staring at this too long and I'm missing something
> really simple.
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: [m2] Including the source code in a war

Posted by Wendy Smoak <ws...@gmail.com>.
On 4/6/06, Martin Cooper <ma...@apache.org> wrote:

> > We tried a couple of things with <resources> such as:
> >      <targetPath>../${pom.artifactId}/WEB-INF/src/main/java</targetPath>
> > and
> >      <targetPath>${basedir}/${pom.artifactId
> > }/WEB-INF/src/main/java</targetPath>
> > but each would work for one developer and not another.  Strange.
>
>
> I'm probably misunderstanding, but why not just:
>
> <targetPath>${project.build.directory}/${pom.artifactId
> }/WEB-INF/src/main/java</targetPath>

Looks like I missed 'target' in the second path, it should have been
${basedir}/target/...
And with that,
<targetPath>${basedir}/target/${pom.artifactId}/WEB-INF/src/main/java</targetPath>

I get this error:
[INFO] Error copying resources

Embedded error: c:\svn\struts\current\action\apps\cookbook\target\classes\c:\svn
\struts\current\action\apps\cookbook\target\struts-cookbook\WEB-INF\src\main\jav
a\examples\bean\ExampleBean.java (The filename, directory name, or volume label
syntax is incorrect)

(<finalName> is defined as ${pom.artifactId} for this build, so that
the war files are named without version numbers.)

I tried Martin's suggestion, but it just put the sources in
(literally) WEB-INF/classes/${project.build.directory}/struts-cookbook/...
 Very strange that ${project.build.directory} wasn't evaluated, I
think it works elsewhere.  But this suffers from the same problem that
the path is relative to WEB-INF/classes.

So, since <resource>s are meant to be under target/classes, which ends
up in WEB-INF/classes, trying to place things directly under WEB-INF
with <resource> is causing problems.

All I need to do is copy some files from one place to another during
the build... ISTR trying this once before though and not finding a
Maven-approved solution.  Perhaps the antrun plugin would work?

That or I've been staring at this too long and I'm missing something
really simple.

--
Wendy

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


Re: [m2] Including the source code in a war

Posted by Martin Cooper <ma...@apache.org>.
On 4/6/06, Wendy Smoak <ws...@gmail.com> wrote:
>
> We ship some example apps and have always included the source code
> (src/main/java) under WEB-INF/src.
>
> How do I do that with Maven 2?
>
> We tried a couple of things with <resources> such as:
>      <targetPath>../${pom.artifactId}/WEB-INF/src/main/java</targetPath>
> and
>      <targetPath>${basedir}/${pom.artifactId
> }/WEB-INF/src/main/java</targetPath>
> but each would work for one developer and not another.  Strange.


I'm probably misunderstanding, but why not just:

<targetPath>${project.build.directory}/${pom.artifactId
}/WEB-INF/src/main/java</targetPath>

--
Martin Cooper


You can see it here, possibly commented out:
>    http://svn.apache.org/repos/asf/struts/action/trunk/apps/pom.xml
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>