IIUC, this feature is available since Maven 3.2.1 (MNG-5530)

Regards,

Hervé

Le mardi 21 février 2017, 22:54:41 CET Igor Fedorenko a écrit :
> MavenProject is injected as a MojoExecutionScope'd component (see
> DefaultBuildPluginManager around line 119). Since old-style Plexus
> components are singleton's by default, there is only one
> AsciidoctorParser instance which holds the first MavenProject it was
> used with for the entire build.
> 
> Couple of ways to solve this.
> 
> If AsciidoctorParser instances are cheap to create and are disposable,
> then the easiest solution is to make AsciidoctorParser as non-singleton
> (this is the default for jsr330 components, and for plexus @Component
> use instantiationStrategy = "per-lookup").
> 
> If AsciidoctorParser must be a singleton, then you need to use
> javax.inject.Provider to access current context MavenProject instance.
> 
> Hope this helps.
> 
> > ie. see line 61 of the maven-plugin-tools annotations reference
> > documentation
> > 
> > http://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/
> > index.html#Supported_Annotations
> > 
> > Regards,
> > 
> > Hervé
> > 
> > Le mardi 21 février 2017, 19:47:05 CET Robert Scholte a écrit :
> > > On Tue, 21 Feb 2017 16:16:55 +0100, Petar Tahchiev
> > > <paranoia...@gmail.com>
> > > 
> > > wrote:
> > > > Hello guys,
> > > > 
> > > > I've recently found out something weird while working with the
> > > > asciidoctor
> > > > maven plugin.My project has the following structure:
> > > > 
> > > > PARENT:
> > > >  - MODULEA
> > > >  - MODULEB
> > > >  - MODULEC
> > > > 
> > > > and the asciidoctor team have created this doxia parser to be able to
> > > > render asciidoc content as part of your maven site:
> > > > 
> > > > https://github.com/asciidoctor/asciidoctor-maven-plugin/blob/master/sr
> > > > c/ma
> > > > in/java/org/asciidoctor/maven/site/AsciidoctorParser.java#L53>
> > > > 
> > > > Note that they are injecting the MavenProject like this:
> > > >     @Requirement
> > > >     protected MavenProject project;
> > > > 
> > > > and when I run the site generation at the PARENT (mvn clean site) this
> > > > parser gets called 4 times, and all the 4 times the MavenProject that
> > > > gets
> > > > injected is PARENT.
> > > > 
> > > > However, if I run the site generation at PARENT but tell it to resume
> > > > from
> > > > MODULEA:
> > > > 
> > > > mvn clean site -rf :MODULEA
> > > > 
> > > > then the MavenProject is MODULEA every time. First time it is MODULEA,
> > > > second time it is MODULEA and third time it is MODULEA.
> > > > 
> > > > This may seem like a very small difference, but if you use properties
> > > > like
> > > > ${project.build.directory} then suddenly your site and images are
> > > > generated
> > > > in wrong folders.
> > > > 
> > > > My questions is:
> > > >   1) Does it look like a bug in Maven reactor? Or perhaps plexus?
> > > 
> > > MavenProject is not something which should work like this. It would mean
> > > that project is a @Named component (JSR330), which it isn't. So I think
> > > that it leaks to the plexus context, which shouldn't happen, but might
> > > explain why you always get the same instance.
> > > A MavenProject is something which needs to be passed as an argument.
> > > 
> > > Robert
> > > 
> > > >   2) Is there any special way that I can inject the current child
> > > >   module
> > > > 
> > > > of
> > > > the mulit-module build. I want the MavenProject that is injected to be
> > > > first time MODULEA, second time MODULEB and third time MODULEC.
> > > > 
> > > > Regarding point 2 I saw Anders had the same question here:
> > > > 
> > > > http://maven.40175.n5.nabble.com/Get-hold-of-MavenProject-object-of-a-> 
> > > > > > > modu
> > > > le-in-a-multi-module-build-td5811486.html
> > > > 
> > > > but I didn't get the answer.
> > > > 
> > > > Thank you.
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
> > > For additional commands, e-mail: dev-h...@maven.apache.org
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
> > For additional commands, e-mail: dev-h...@maven.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
> For additional commands, e-mail: dev-h...@maven.apache.org



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

Reply via email to