Quantcast

create war and jar files at same time.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

create war and jar files at same time.

minhaj-2
Hi,

i am working on maven;s multi module project i have three modules with three
pom.xml files all of them generating war files successfully and i want to
generate a jar file as well for one of the module.

i am confuse that how can we define two times the <packaging> tag in same
pom.xml file.

it can be done with Profiles??


Tx
Minhajkk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create war and jar files at same time.

Yves Dessertine
Okay. You can't define two packaging types (I think, not 100% sure).

But,

you can "attach" other plugins to the "package" phase. I did this.
Something like this in your <plugins> section. Example:

                       <plugin>
                               <groupId>org.apache.maven.plugins</groupId>
                               <artifactId>maven-war-plugin</artifactId>
                               <version>2.1-alpha-1</version>
                               <configuration>
                                       <!-- your war plugin conf here (see
http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html ) -->
                               </configuration>
                       </plugin>


Forget about adding one more submodule :)

Regards,

2009/1/27 Yves Dessertine <[hidden email]>:

> Okay. You can't define two packaging types (I think, not 100% sure).
>
> But,
>
> you can "attach" other plugins to the "package" phase. I did this.
> Something like this in your <plugins> section. Example:
>
>                        <plugin>
>                                <groupId>org.apache.maven.plugins</groupId>
>                                <artifactId>maven-war-plugin</artifactId>
>                                <version>2.1-alpha-1</version>
>                                <configuration>
>                                        <!-- your war plugin conf here (see
> http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html ) -->
>                                </configuration>
>                        </plugin>
>
>
> Forget about adding one more submodule :)
>
> Regards,
>
> Yves
>
>
> 2009/1/27 Minhaj <[hidden email]>:
>> thanks for your reply,
>>
>> but the problem is i want to create jar and war for the same module like we
>> can do in ant...we can specify goals for creating jar and war separately and
>> then execute by command prompt ant war or ant jar
>>
>>
>> Tx
>> Minhaj
>>
>> On Tue, Jan 27, 2009 at 2:57 PM, Yves Dessertine <[hidden email]>
>> wrote:
>>>
>>> Is it an acceptable solution for you, to create one more subproject
>>> generating a jar. And then make the war-project depend on your jar ?
>>>
>>> PS : don't crosspost on dev and users (this questions has nothing to
>>> do with dev, don't ?)
>>>
>>> Yves
>>>
>>> 2009/1/27 Minhaj <[hidden email]>:
>>> > Hi,
>>> >
>>> > i am working on maven;s multi module project i have three modules with
>>> > three
>>> > pom.xml files all of them generating war files successfully and i want
>>> > to
>>> > generate a jar file as well for one of the module.
>>> >
>>> > i am confuse that how can we define two times the <packaging> tag in
>>> > same
>>> > pom.xml file.
>>> >
>>> > it can be done with Profiles??
>>> >
>>> >
>>> > Tx
>>> > Minhajkk
>>> >
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: create war and jar files at same time.

Wendy Smoak
In reply to this post by minhaj-2
[Answered only on users@ list.  Please don't cross-post.]

On Tue, Jan 27, 2009 at 1:08 AM, Minhaj <[hidden email]> wrote:

> i am working on maven;s multi module project i have three modules with three
> pom.xml files all of them generating war files successfully and i want to
> generate a jar file as well for one of the module.

It's better to create a separate jar module for the classes you want
to package in a jar, and add it as a dependency in your war module.

If that doesn't make sense for your project, then you can configure
the war plugin to create an 'attached' jar by configuring the war
plugin:

http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#attachClasses

--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...