You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Oliver B. Fischer" <ma...@swe-blog.net> on 2015/12/19 12:48:57 UTC

.jar is installed as .war

Hi,

my project is build as war but I need also a jar of the classes. 
Therefore I build also a .jar and use the build-helper-maven-plugin to 
attach it to artifacts to be installed. With this configuration the .jar 
will be installed as .war and as .jar. The .war itself will be not 
installed.

Sounds like a bug or isn't it a bug?

I prepared an example project available at 
https://bitbucket.org/obfischer/bug-maven-install-plugin/src

Oliver

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


Re: .jar is installed as .war

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Olivier

Why not using standard war plugin for that:
https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#attachClasses
Le 19 déc. 2015 12:49, "Oliver B. Fischer" <ma...@swe-blog.net> a écrit :

> Hi,
>
> my project is build as war but I need also a jar of the classes. Therefore
> I build also a .jar and use the build-helper-maven-plugin to attach it to
> artifacts to be installed. With this configuration the .jar will be
> installed as .war and as .jar. The .war itself will be not installed.
>
> Sounds like a bug or isn't it a bug?
>
> I prepared an example project available at
> https://bitbucket.org/obfischer/bug-maven-install-plugin/src
>
> Oliver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: .jar is installed as .war

Posted by "Oliver B. Fischer" <ma...@swe-blog.net>.
Hi,

I decided to create an additional jar while refactoring the the 
buildstructure of an old project not created by me. The integration and 
component tests, which I moved to an separated modul, have dependecies 
to classes of the war producing module. As I can not add a war to the 
classepath I decided to create an additional war out of the classes 
attached to the project. It seemed to me as the best and easiest 
solution wile refactoring the projeckt. And it works for the tests.


Am 19.12.15 um 13:07 schrieb Karl Heinz Marbaise:
> Hi,
>
>
> you can use a configuration option of the maven-war-plugin
> (attachClasses) which will produce a separate jar of the classes you
> have in your war module:
>
> http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#attachClasses

I will try this out.

>
>
> This jar is separately installed and can be used by other as a usual
> dependency ...but be aware that you need to use a classifier for this
> artifact..
>
>
> The problem with build-helper-maven-plugin is that is will replace the
> original artifact which is the default...in such cases you should use a
> classifier...

Ok, It could replace the original artifact but it shouldn't be installed 
as war. Replacing would be ok but not installing it twice.

And the description if the attach-artifact goal is

    Attach additional artifacts to be installed and deployed.

Additional means not replacing the original one.

>
> Furthermore you have configured the maven-jar-plugin a second time in
> your build which will also replace the original artifact...cause
> maven-jar-plugin is not being part of the life cycle in case of
> packaging "war"....


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


Re: .jar is installed as .war

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,


you can use a configuration option of the maven-war-plugin 
(attachClasses) which will produce a separate jar of the classes you 
have in your war module:

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

This jar is separately installed and can be used by other as a usual 
dependency ...but be aware that you need to use a classifier for this 
artifact..


The problem with build-helper-maven-plugin is that is will replace the 
original artifact which is the default...in such cases you should use a 
classifier...

Furthermore you have configured the maven-jar-plugin a second time in 
your build which will also replace the original artifact...cause 
maven-jar-plugin is not being part of the life cycle in case of 
packaging "war"....

Kind regards
Karl Heinz Marbaise


On 12/19/15 12:48 PM, Oliver B. Fischer wrote:
> Hi,
>
> my project is build as war but I need also a jar of the classes.
> Therefore I build also a .jar and use the build-helper-maven-plugin to
> attach it to artifacts to be installed. With this configuration the .jar
> will be installed as .war and as .jar. The .war itself will be not
> installed.
>
> Sounds like a bug or isn't it a bug?
>
> I prepared an example project available at
> https://bitbucket.org/obfischer/bug-maven-install-plugin/src
>
> Oliver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

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


Re: .jar is installed as .war

Posted by "Oliver B. Fischer" <ma...@swe-blog.net>.
Yes, this would be the clean solution and I am refactoring the project 
to go there. But first I have to separate integration and component 
tests. Therefore I need the classes in the war module also available as 
jar for those tests.

Oliver

Am 19.12.15 um 13:28 schrieb Tibor Digana:
> @Oliver
> What is your use case?
> I want to know why you want to split classes/resources and web content. Is
> not it more clean solution to have multi-module project where jar module
> would contain Java files+resources and war module dependent on jar artifact?
>
> On Sat, Dec 19, 2015 at 12:48 PM, Oliver B. Fischer <ma...@swe-blog.net>
> wrote:
>
>> Hi,
>>
>> my project is build as war but I need also a jar of the classes. Therefore
>> I build also a .jar and use the build-helper-maven-plugin to attach it to
>> artifacts to be installed. With this configuration the .jar will be
>> installed as .war and as .jar. The .war itself will be not installed.
>>
>> Sounds like a bug or isn't it a bug?
>>
>> I prepared an example project available at
>> https://bitbucket.org/obfischer/bug-maven-install-plugin/src
>>
>> Oliver
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>
>

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


Re: .jar is installed as .war

Posted by Tibor Digana <ti...@googlemail.com>.
@Oliver
What is your use case?
I want to know why you want to split classes/resources and web content. Is
not it more clean solution to have multi-module project where jar module
would contain Java files+resources and war module dependent on jar artifact?

On Sat, Dec 19, 2015 at 12:48 PM, Oliver B. Fischer <ma...@swe-blog.net>
wrote:

> Hi,
>
> my project is build as war but I need also a jar of the classes. Therefore
> I build also a .jar and use the build-helper-maven-plugin to attach it to
> artifacts to be installed. With this configuration the .jar will be
> installed as .war and as .jar. The .war itself will be not installed.
>
> Sounds like a bug or isn't it a bug?
>
> I prepared an example project available at
> https://bitbucket.org/obfischer/bug-maven-install-plugin/src
>
> Oliver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


-- 
Cheers
Tibor