1package org.apache.archiva.common.plexusbridge;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.apache.maven.index.context.IndexCreator;
23import org.apache.maven.index.creator.JarFileContentsIndexCreator;
24import org.apache.maven.index.creator.MavenArchetypeArtifactInfoIndexCreator;
25import org.apache.maven.index.creator.MavenPluginArtifactInfoIndexCreator;
26import org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator;
27import org.apache.maven.index.creator.OsgiArtifactIndexCreator;
28import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
30import org.springframework.stereotype.Service;
3132import javax.inject.Inject;
33import java.util.ArrayList;
34import java.util.Arrays;
35import java.util.List;
3637/**38 * @author Olivier Lamy39 * @since 1.4-M140 */41 @Service( "mavenIndexerUtils" )
42publicclassMavenIndexerUtils43 {
4445private Logger log = LoggerFactory.getLogger( getClass() );
4647private List<? extends IndexCreator> allIndexCreators;
4849 @Inject
50publicMavenIndexerUtils( PlexusSisuBridge plexusSisuBridge )
51throwsPlexusSisuBridgeException52 {
53 allIndexCreators = new ArrayList( plexusSisuBridge.lookupList( IndexCreator.class ) );
5455if ( allIndexCreators == null || allIndexCreators.isEmpty() )
56 {
57// olamy when the TCL is not a URLClassLoader lookupList fail !58// when using tomcat maven plugin so adding a simple hack59 log.warn( "using lookupList from sisu plexus failed so build indexCreator manually" );
6061 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 ) );
6768 }
6970if ( allIndexCreators == null || allIndexCreators.isEmpty() )
71 {
72thrownewPlexusSisuBridgeException( "no way to initiliaze IndexCreator" );
73 }
7475 log.debug( "allIndexCreators {}", allIndexCreators );
76 }
7778public List<? extends IndexCreator> getAllIndexCreators()
79 {
80return allIndexCreators;
81 }
8283publicvoid setAllIndexCreators( List<IndexCreator> allIndexCreators )
84 {
85this.allIndexCreators = allIndexCreators;
86 }
87 }