1 package org.apache.archiva.common.plexusbridge;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.index.context.IndexCreator;
23 import org.apache.maven.index.creator.JarFileContentsIndexCreator;
24 import org.apache.maven.index.creator.MavenArchetypeArtifactInfoIndexCreator;
25 import org.apache.maven.index.creator.MavenPluginArtifactInfoIndexCreator;
26 import org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator;
27 import org.apache.maven.index.creator.OsgiArtifactIndexCreator;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30 import org.springframework.stereotype.Service;
31
32 import javax.inject.Inject;
33 import java.util.ArrayList;
34 import java.util.Arrays;
35 import java.util.List;
36
37
38
39
40
41 @Service( "mavenIndexerUtils" )
42 public class MavenIndexerUtils
43 {
44
45 private Logger log = LoggerFactory.getLogger( getClass() );
46
47 private List<? extends IndexCreator> allIndexCreators;
48
49 @Inject
50 public MavenIndexerUtils( PlexusSisuBridge plexusSisuBridge )
51 throws PlexusSisuBridgeException
52 {
53 allIndexCreators = new ArrayList( plexusSisuBridge.lookupList( IndexCreator.class ) );
54
55 if ( allIndexCreators == null || allIndexCreators.isEmpty() )
56 {
57
58
59 log.warn( "using lookupList from sisu plexus failed so build indexCreator manually" );
60
61 allIndexCreators =
62 Arrays.asList( plexusSisuBridge.lookup( IndexCreator.class, OsgiArtifactIndexCreator.ID ),
63 plexusSisuBridge.lookup( IndexCreator.class, MavenArchetypeArtifactInfoIndexCreator.ID ),
64 plexusSisuBridge.lookup( IndexCreator.class, MinimalArtifactInfoIndexCreator.ID ),
65 plexusSisuBridge.lookup( IndexCreator.class, JarFileContentsIndexCreator.ID ),
66 plexusSisuBridge.lookup( IndexCreator.class, MavenPluginArtifactInfoIndexCreator.ID ) );
67
68 }
69
70 if ( allIndexCreators == null || allIndexCreators.isEmpty() )
71 {
72 throw new PlexusSisuBridgeException( "no way to initiliaze IndexCreator" );
73 }
74
75 log.debug( "allIndexCreators {}", allIndexCreators );
76 }
77
78 public List<? extends IndexCreator> getAllIndexCreators()
79 {
80 return allIndexCreators;
81 }
82
83 public void setAllIndexCreators( List<IndexCreator> allIndexCreators )
84 {
85 this.allIndexCreators = allIndexCreators;
86 }
87 }