5252import org .eclipse .sisu .space .SpaceModule ;
5353import org .eclipse .sisu .wire .WireModule ;
5454
55+ import org .codehaus .plexus .logging .LogEnabled ;
56+
5557import org .apache .maven .RepositoryUtils ;
5658import org .apache .maven .archetype .catalog .Archetype ;
5759import org .apache .maven .archetype .common .ArchetypeArtifactManager ;
6264import org .apache .maven .archetype .source .InternalCatalogArchetypeDataSource ;
6365import org .apache .maven .archetype .source .LocalCatalogArchetypeDataSource ;
6466import org .apache .maven .archetype .source .RemoteCatalogArchetypeDataSource ;
67+ import org .apache .maven .cli .logging .Slf4jLogger ;
6568
6669import org .eclipse .m2e .core .embedder .IMaven ;
6770import org .eclipse .m2e .core .embedder .IMavenExecutionContext ;
8083@ Component (service = ArchetypePlugin .class )
8184public class ArchetypePlugin {
8285
83- private static final InternalCatalogArchetypeDataSource INTERNAL_CATALOG_ARCHETYPE_DATA_SOURCE = new InternalCatalogArchetypeDataSource ();
86+ /**
87+ *
88+ */
89+ private static final RemoteCatalogArchetypeDataSource REMOTE_CATALOG = new RemoteCatalogArchetypeDataSource ();
90+
91+ private static final InternalCatalogArchetypeDataSource INTERNAL_CATALOG = new InternalCatalogArchetypeDataSource ();
8492
8593 private static final LocalCatalogArchetypeDataSource LOCAL_CATALOG = new LocalCatalogArchetypeDataSource ();
8694
@@ -114,6 +122,10 @@ protected void configure() {
114122 bind (ILoggerFactory .class ).toInstance (LoggerFactory .getILoggerFactory ());
115123 }
116124 };
125+ Slf4jLogger logger = new Slf4jLogger (LoggerFactory .getILoggerFactory ().getLogger ("catalog" ));
126+ REMOTE_CATALOG .enableLogging (logger );
127+ INTERNAL_CATALOG .enableLogging (logger );
128+ LOCAL_CATALOG .enableLogging (logger );
117129 ClassSpace space = new BundleClassSpace (FrameworkUtil .getBundle (ArchetypeArtifactManager .class ));
118130 final Module repositorySystemModule = new AbstractModule () {
119131 @ Override
@@ -128,8 +140,11 @@ protected void configure() {
128140 Injector injector = Guice .createInjector (
129141 new WireModule (logginModule , repositorySystemModule , new SpaceModule (space , BeanScanning .INDEX )));
130142 archetypeArtifactManager = injector .getInstance (ArchetypeArtifactManager .class );
143+ if (archetypeArtifactManager instanceof LogEnabled le ) {
144+ le .enableLogging (logger );
145+ }
131146 addArchetypeCatalogFactory (
132- new ArchetypeCatalogFactory .InternalCatalogFactory (INTERNAL_CATALOG_ARCHETYPE_DATA_SOURCE ));
147+ new ArchetypeCatalogFactory .InternalCatalogFactory (INTERNAL_CATALOG ));
133148 addArchetypeCatalogFactory (new ArchetypeCatalogFactory .DefaultLocalCatalogFactory (maven , LOCAL_CATALOG ));
134149 for (ArchetypeCatalogFactory archetypeCatalogFactory : ExtensionReader .readArchetypeExtensions (this )) {
135150 addArchetypeCatalogFactory (archetypeCatalogFactory );
@@ -153,7 +168,7 @@ public LocalCatalogFactory newLocalCatalogFactory(String path, String descriptio
153168
154169 public RemoteCatalogFactory newRemoteCatalogFactory (String url , String description , boolean editable ,
155170 boolean enabled ) {
156- return new RemoteCatalogFactory (url , description , editable , enabled , maven , new RemoteCatalogArchetypeDataSource () );
171+ return new RemoteCatalogFactory (url , description , editable , enabled , maven , REMOTE_CATALOG );
157172 }
158173
159174 public ArchetypeGenerator getGenerator () {
0 commit comments