You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Attila Mezei-Horvati <at...@yahoo.com> on 2006/08/29 23:32:29 UTC

mvn2: war packaging

Hi,

Slowly I understand the life cycles but still not sure
in what order are their components run. 

My problem: I have a war package, in it I specify an
ant task at the package phase to copy a jar into the
lib so the war would take it. For some reason the copy
is done after the war creation. Can somebody tell me
why?

thanks,
Attila

<execution>
  <id>packaging</id>
  <phase>package</phase>
  <configuration>
  <tasks>
  <copy todir="target/matrix/WEB-INF/lib">
    <fileset dir="target"><include
name="sxmltypes.jar" /></fileset>
  </copy>
  </tasks>
  </configuration>
  <goals>
  <goal>run</goal>
  </goals>
</execution>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Re: mvn2: war packaging

Posted by Jared Bunting <li...@jaredbunting.com>.
I might be missing what you're trying to do here, and it seems to me that
creating a multi-module project, as suggested, would be the best way to go
about this.  However, what if you bound your source generation to the
"generate-sources" phase.  I'm not sure of how it would be done in ant, but
I know that you can then "add" the generated sources to the list of files to
compile in the compile phase and then they should be included in your
WEB-INF/classes directory in the war file. They won't be in a jar, but
they'll be in your war.

(and you can DEFINITELY guarantee that they will be generated before the war
is created - it seems that they are getting generated after the war because
you are binding to the packaging phase, which is meant to actually package,
and plugin order within a phase is undefined...)

I found an article that mentions doing this with a hibernate ant task here:

http://www.onjava.com/pub/a/onjava/2005/12/14/hibernate-class-generation-with-hbm2java.html?page=4

Maybe this will be helpful?



On 8/31/06, chua <ad...@ono.com> wrote:
>
>
> Hi!
>
> I had more or less the same problem as you.
> One of the solutions is to create a project based on modules.
>
> You just have to create a parent pom with:
>
> <modules>
> <module>module_for_jar</module>
> <module>module_for_war</module>
> </modules>
>
> Then, you have to create two subfolders with the same name as the modules
> and with the m2 folder structure, each one with its own pom.
>
> Now you just have to have in one pom a jar packaging, and in the other a
> war
> packaging.
>
> The last thing to do is to include the dependency of the jar created in
> the
> jar module in the pom.xml of the war module.
>
> That´s one solution and it works to me.
>
> Be sure your jar module is declared first, and second, declare your war
> module.
>
> I hope I had helped you
>
> --
> View this message in context:
> http://www.nabble.com/mvn2%3A-war-packaging-tf2186390.html#a6078489
> Sent from the Maven - Users forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Re: mvn2: war packaging

Posted by chua <ad...@ono.com>.
Hi!

I had more or less the same problem as you.
One of the solutions is to create a project based on modules.

You just have to create a parent pom with:

<modules>
<module>module_for_jar</module>
<module>module_for_war</module>
</modules>

Then, you have to create two subfolders with the same name as the modules
and with the m2 folder structure, each one with its own pom.

Now you just have to have in one pom a jar packaging, and in the other a war
packaging.

The last thing to do is to include the dependency of the jar created in the
jar module in the pom.xml of the war module.

That´s one solution and it works to me.

Be sure your jar module is declared first, and second, declare your war
module.

I hope I had helped you

-- 
View this message in context: http://www.nabble.com/mvn2%3A-war-packaging-tf2186390.html#a6078489
Sent from the Maven - Users forum at Nabble.com.


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


Re: Re: mvn2: war packaging

Posted by franz see <fr...@gmail.com>.


Attila Mezei-Horvati wrote:
> 
>> From: "Henry S. Isidro" <hi...@exist.com>
>> To: "Maven Users List" <us...@maven.apache.org>
>> Subject: Re: mvn2: war packaging
>> Date: Wed, 30 Aug 2006 07:43:56 +0800
>> 
>> If you're trying to include a jar in the lib folder
>> of a war package, just 
>> declare the jar file as a dependency in the war's
>> pom file. This will make 
>> maven automatically put it in the lib folder during
>> packaging.
>> 
>> - Henry
> 
> The problem is I am creating the jar file during the
> war compilation. As I know, I can specify dependency
> only for another pom jar package.
> 
> However I am running an ant task to generate code from
> xsd files and compiling it. I was hoping I don't have
> to move it out to a separate project; I can keep it in
> this project and just copy it. Unfortunately copy
> works _after_ the war is created and I don't know how
> to specify the order (first copy then war). I also
> tried to add it as web resource with a targetPath
> option. Unfortunately that doesn't work either. 
> 
> Any ideas?
> thanks,
> Attila
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

Good day to you, Attila,

Specifying to include that jar file using webResouces should have worked.
However, there is a known bug that sometimes, webResources does not work.
You may want to take a look at [1] and try and apply patch2 to your
maven-war-plugin and see if your webResources would then work.

Cheers,
Franz

[1] http://jira.codehaus.org/browse/MWAR-67
-- 
View this message in context: http://www.nabble.com/mvn2%3A-war-packaging-tf2186390.html#a6062426
Sent from the Maven - Users forum at Nabble.com.


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


Re: mvn2: war packaging

Posted by "Henry S. Isidro" <hi...@exist.com>.
On Wednesday, August 30, 2006 05:32, Attila Mezei-Horvati wrote:
> Hi,
>
> Slowly I understand the life cycles but still not sure
> in what order are their components run.
>
> My problem: I have a war package, in it I specify an
> ant task at the package phase to copy a jar into the
> lib so the war would take it. For some reason the copy
> is done after the war creation. Can somebody tell me
> why?
>
> thanks,
> Attila
>
> <execution>
>   <id>packaging</id>
>   <phase>package</phase>
>   <configuration>
>   <tasks>
>   <copy todir="target/matrix/WEB-INF/lib">
>     <fileset dir="target"><include
> name="sxmltypes.jar" /></fileset>
>   </copy>
>   </tasks>
>   </configuration>
>   <goals>
>   <goal>run</goal>
>   </goals>
> </execution>
>

If you're trying to include a jar in the lib folder of a war package, just 
declare the jar file as a dependency in the war's pom file. This will make 
maven automatically put it in the lib folder during packaging.

- Henry

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