You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Karl Heinz Marbaise <kh...@gmx.de> on 2014/06/20 13:20:06 UTC

Q: Thread Safety - Parallel Builds

Hi,

currently i'm working on a problem 
(http://jira.codehaus.org/browse/MASSEMBLY-684) in the 
maven-assembly-plugin which will fail if you use:

mvn -T2C clean package

after diving into that problem i found out that the components which are 
being injected are always the same so far so good, but those components 
are exactly causing the trouble in relationship with multithreaded build...

So the following component is the root cause:

     @Component
     private AssemblyArchiver assemblyArchiver;

So the question is: Is there a way to create new instances every time 
the execute() of the mojo is called? May be manually ? Or does exist 
already a solution for this kind of problems...



Mit freundlichem Gruß
Karl-Heinz Marbaise
-- 
SoftwareEntwicklung Beratung Schulung    Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl-Heinz Marbaise        ICQ#: 135949029
Hauptstrasse 177                         USt.IdNr: DE191347579
52146 Würselen                           http://www.soebes.de

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


Re: Q: Thread Safety - Parallel Builds

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

first thanks to Igor and Tamás for the hints...

I've changed some of them...and now i'm faced with the following:

The output says "BUILD SUCCESS"  but there are entries with "Skipped"...


[INFO] [INFO] Reading assembly descriptor: 
src/assembly/src-zip-only-assembly.xml
Reading assembly descriptor: src/assembly/src-zip-only-assembly.xml
[INFO] Reading assembly descriptor: src/assembly/src-zip-only-assembly.xml
[INFO] Reading assembly descriptor: src/assembly/src-zip-only-assembly.xml
[INFO] Reading assembly descriptor: src/assembly/src-zip-only-assembly.xml
[INFO] Reading assembly descriptor: src/assembly/src-zip-only-assembly.xml
[INFO] Reading assembly descriptor: src/assembly/src-zip-only-assembly.xml
[INFO] Reading assembly descriptor: src/assembly/src-zip-only-assembly.xml
[INFO] Building zip: 
/Users/kama/ws-git/apache/massembly/massembly-684/project1/target/project1-1.0.0-SNAPSHOT-src.zip
[INFO] Building zip: 
/Users/kama/ws-git/apache/massembly/massembly-684/project6/target/project6-1.0.0-SNAPSHOT-src.zip
[INFO] Building zip: 
/Users/kama/ws-git/apache/massembly/massembly-684/project8/target/project8-1.0.0-SNAPSHOT-src.zip
[INFO] Building zip: 
/Users/kama/ws-git/apache/massembly/massembly-684/project3/target/project3-1.0.0-SNAPSHOT-src.zip
[INFO] Building zip: 
/Users/kama/ws-git/apache/massembly/massembly-684/project5/target/project5-1.0.0-SNAPSHOT-src.zip
[INFO] Building zip: 
/Users/kama/ws-git/apache/massembly/massembly-684/project2/target/project2-1.0.0-SNAPSHOT-src.zip
[INFO] Building zip: 
/Users/kama/ws-git/apache/massembly/massembly-684/project7/target/project7-1.0.0-SNAPSHOT-src.zip
[INFO] Building zip: 
/Users/kama/ws-git/apache/massembly/massembly-684/project4/target/project4-1.0.0-SNAPSHOT-src.zip
[INFO] 
------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] project ........................................... SUCCESS [1.084s]
[INFO] project1 .......................................... SKIPPED
[INFO] project2 .......................................... SUCCESS [1.027s]
[INFO] project3 .......................................... SUCCESS [1.027s]
[INFO] project4 .......................................... SUCCESS [1.027s]
[INFO] project5 .......................................... SUCCESS [1.027s]
[INFO] project6 .......................................... SUCCESS [1.027s]
[INFO] project7 .......................................... SUCCESS [1.027s]
[INFO] project8 .......................................... SKIPPED
[INFO] 
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] 
------------------------------------------------------------------------
[INFO] Total time: 2.621s (Wall Clock)
[INFO] Finished at: Fri Jun 20 14:56:53 CEST 2014
[INFO] Final Memory: 19M/981M
[INFO] 
------------------------------------------------------------------------

So the question is what does this mean?

Kind regards
Karl-Heinz Marbaise

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


Re: Q: Thread Safety - Parallel Builds

Posted by Igor Fedorenko <ig...@ifedorenko.com>.
Components decide how often then are instantiated, so AssemblyArchiver
implementation(s) need to be changed.

You can use instantiationStrategy="per-lookup" to indicate new instance
is created each time component is injected. This is standard plexus/sisu
feature and should work on all Maven versions.

If you need the same component instance injected in multiple places
within the scope of a mojo execution, you can use @MojoExecutionScoped
annotation, which is new in Maven 3.2.

--
Regards,
Igor

On 2014-06-20, 7:20, Karl Heinz Marbaise wrote:
> Hi,
>
> currently i'm working on a problem
> (http://jira.codehaus.org/browse/MASSEMBLY-684) in the
> maven-assembly-plugin which will fail if you use:
>
> mvn -T2C clean package
>
> after diving into that problem i found out that the components which are
> being injected are always the same so far so good, but those components
> are exactly causing the trouble in relationship with multithreaded build...
>
> So the following component is the root cause:
>
>      @Component
>      private AssemblyArchiver assemblyArchiver;
>
> So the question is: Is there a way to create new instances every time
> the execute() of the mojo is called? May be manually ? Or does exist
> already a solution for this kind of problems...
>
>
>
> Mit freundlichem Gruß
> Karl-Heinz Marbaise

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


Re: Q: Thread Safety - Parallel Builds

Posted by Tamás Cservenák <ta...@cservenak.net>.
In Plexus, you can make the plexus component "prototype" (as opposite of
current singleton) by adding

instantiationStrategy="per-lookup"

in that case, Plexus container will create new instance of the component
for every injection/lookup.




On Fri, Jun 20, 2014 at 1:20 PM, Karl Heinz Marbaise <kh...@gmx.de>
wrote:

> Hi,
>
> currently i'm working on a problem (http://jira.codehaus.org/
> browse/MASSEMBLY-684) in the maven-assembly-plugin which will fail if you
> use:
>
> mvn -T2C clean package
>
> after diving into that problem i found out that the components which are
> being injected are always the same so far so good, but those components are
> exactly causing the trouble in relationship with multithreaded build...
>
> So the following component is the root cause:
>
>     @Component
>     private AssemblyArchiver assemblyArchiver;
>
> So the question is: Is there a way to create new instances every time the
> execute() of the mojo is called? May be manually ? Or does exist already a
> solution for this kind of problems...
>
>
>
> Mit freundlichem Gruß
> Karl-Heinz Marbaise
> --
> SoftwareEntwicklung Beratung Schulung    Tel.: +49 (0) 2405 / 415 893
> Dipl.Ing.(FH) Karl-Heinz Marbaise        ICQ#: 135949029
> Hauptstrasse 177                         USt.IdNr: DE191347579
> 52146 Würselen                           http://www.soebes.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>