Re: How to replace a Maven core component with a custom one?

2024-04-30 Thread Francois-Xavier Bonnet
Thanks Tamas,

I am using Maven 3.9.6 and building my extension with java 11
The project I am using to test the extension is built with Maven 3.9.6 and
java 11 and I can tell the extension is loaded because it also contains an
EventSpy that logs some stuff.
This is the code for my custom ProjectDepedencyResolver but it is not
loaded. What am I doing wrong?

import org.apache.maven.project.*;
import org.codehaus.plexus.component.annotations.Component;
import org.eclipse.sisu.Priority;

import javax.inject.Inject;
import javax.inject.Named;

@Named
@Component(role = ProjectDependenciesResolver.class)
@Priority(999)
public class CustomProjectDependencyResolver extends
DefaultProjectDependenciesResolver implements ProjectDependenciesResolver {

@Inject
public CustomProjectDependencyResolver() {
}

@Override
public DependencyResolutionResult resolve(DependencyResolutionRequest
request) throws DependencyResolutionException {
throw new RuntimeException(); // just crashing for now to check if
this class is properly injected
}
}

On Wed, 1 May 2024 at 08:54, Tamás Cservenák  wrote:

> Howdy,
>
> IF you target latest Maven 3.9.x (uses Sisu 0.9.0.M2), then:
> - use max Java 17 bytecode
> - use JSR330 instead of plexus annotations
> - use org.eclipse.sisu.Priority annotation to override a component
>
> IF you target Maven 3.8.x or so, similar, but use Java 11 bytecode max
>
> Thanks
> T
>
>
> On Wed, May 1, 2024 at 12:42 AM Francois-Xavier Bonnet <
> fx.bon...@gmail.com>
> wrote:
>
> > Hey there,
> >
> > I am writing an extension that needs to replace the
> > default ProjectDependenciesResolver with a custom one.
> > According to the documentation I think I should be able to do it: "The
> > mechanism allows extensions to either replace default Sisu components
> with
> > custom ones or add new components which are used at run time."
> > But I could not figure out how to do it or find any example.
> >
> > I have tried to create a new class like this:
> >
> > @Component(role = ProjectDependenciesResolver.class)
> > public class CustomProjectDependencyResolver implements
> > ProjectDependenciesResolver {
> > ...
> > }
> >
> > This did not work.
> >
>


Re: A book on Maven

2024-04-30 Thread Tomo Suzuki
I would rather use the getting started guide in the Maven website:
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

Regards,
Tomo


On Tue, Apr 30, 2024 at 18:23 Arbol One  wrote:

> Anyone here can recommend a book on maven for a truly nubby?
> Thanks!!
>
> --
> */ArbolOne.ca/* Using Fire Fox and Thunderbird. ArbolOne is composed of
> students and volunteers dedicated to providing free services to
> charitable organizations. ArbolOne on Java Development is in progress [ í ]


Re: How to replace a Maven core component with a custom one?

2024-04-30 Thread Tamás Cservenák
Howdy,

IF you target latest Maven 3.9.x (uses Sisu 0.9.0.M2), then:
- use max Java 17 bytecode
- use JSR330 instead of plexus annotations
- use org.eclipse.sisu.Priority annotation to override a component

IF you target Maven 3.8.x or so, similar, but use Java 11 bytecode max

Thanks
T


On Wed, May 1, 2024 at 12:42 AM Francois-Xavier Bonnet 
wrote:

> Hey there,
>
> I am writing an extension that needs to replace the
> default ProjectDependenciesResolver with a custom one.
> According to the documentation I think I should be able to do it: "The
> mechanism allows extensions to either replace default Sisu components with
> custom ones or add new components which are used at run time."
> But I could not figure out how to do it or find any example.
>
> I have tried to create a new class like this:
>
> @Component(role = ProjectDependenciesResolver.class)
> public class CustomProjectDependencyResolver implements
> ProjectDependenciesResolver {
> ...
> }
>
> This did not work.
>


How to replace a Maven core component with a custom one?

2024-04-30 Thread Francois-Xavier Bonnet
Hey there,

I am writing an extension that needs to replace the
default ProjectDependenciesResolver with a custom one.
According to the documentation I think I should be able to do it: "The
mechanism allows extensions to either replace default Sisu components with
custom ones or add new components which are used at run time."
But I could not figure out how to do it or find any example.

I have tried to create a new class like this:

@Component(role = ProjectDependenciesResolver.class)
public class CustomProjectDependencyResolver implements
ProjectDependenciesResolver {
...
}

This did not work.


A book on Maven

2024-04-30 Thread Arbol One

Anyone here can recommend a book on maven for a truly nubby?
Thanks!!

--
*/ArbolOne.ca/* Using Fire Fox and Thunderbird. ArbolOne is composed of 
students and volunteers dedicated to providing free services to 
charitable organizations. ArbolOne on Java Development is in progress [ í ]