package org.jboss.maven.extension.dependency;

import org.apache.maven.model.building.DefaultModelBuilder;
import org.apache.maven.model.building.ModelBuilder;
import org.apache.maven.model.building.ModelBuildingException;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelBuildingResult;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;

@Component(role = DefaultModelBuilder.class)
public class ExtDepMgmtModelBuilder implements ModelBuilder {

    // Seems that having this requirement may cause issues, since jars in lib/ext/ are loaded before the main jars
    // Need to see this works if we add this as a build extension in the pom (the other way of using an extension)
    // See http://maven.apache.org/examples/maven-3-lifecycle-extensions.html
    // It's also possible that we could insert this jar after the main jars are loaded? This isn't documented though.
    // See /usr/share/maven/bin/m2.conf 's [plexus.core] section
    
    //@Requirement(hint = "model-builder-internal")
    //private DefaultModelBuilder modelBuilderDelegate;

    public ModelBuildingResult build(ModelBuildingRequest request) throws ModelBuildingException {
        System.out.println(">>>> build 1 called <<<<");
        return null;
    }

    public ModelBuildingResult build(ModelBuildingRequest request, ModelBuildingResult result) throws ModelBuildingException {
        System.out.println(">>>> build 2 called <<<<");
        return null;
    }
}

@@ -400,70 +400,8 @@
 ent;
-%0Aimport org.codehaus.plexus.component.annotations.Requirement;
 %0A%0A@C
@@ -483,639 +483,76 @@
 der 
-implements ModelBuilder %7B%0A%0A    // Seems that having this requirement may cause issues, since jars in lib/ext/ are loaded before the main jars%0A    // Need to see this works if we add this as a build extension in the pom (the other way of using an extension)%0A    // See http://maven.apache.org/examples/maven-3-lifecycle-extensions.html%0A    // It's also possible that we could insert this jar after the main jars are loaded? This isn't documented though.%0A    // See /usr/share/maven/bin/m2.conf 's %5Bplexus.core%5D section%0A    %0A    //@Requirement(hint = %22model-builder-internal%22)%0A    //private DefaultModelBuilder modelBuilderDelegate;%0A
+extends DefaultModelBuilder implements ModelBuilder %7B%0A%0A    @Override
 %0A   
@@ -689,53 +689,117 @@
 uild
- 1 called %3C%3C%3C%3C%22);%0A        return null;%0A    %7D%0A
+(ModelBuildingRequest) called: %5B%22 + request + %22%5D%22);%0A        return super.build(request);%0A    %7D%0A%0A    @Override
 %0A   
@@ -964,45 +964,141 @@
 uild
- 2 called %3C%3C%3C%3C%22);%0A        return null
+(ModelBuildingRequest, ModelBuildingResult) called: %5B%22 + request + %22%5D %5B%22 + result + %22%5D%22);%0A        return super.build(request, result)
 ;%0A  

Modify ModelBuilder override to something that doesn't crash maven.