aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-plexus-bridge
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-08-16 13:50:45 +0000
committerOlivier Lamy <olamy@apache.org>2011-08-16 13:50:45 +0000
commitc7607a63e569a4bbe271fdcf8744d5ba909652a5 (patch)
tree32f02dc3eb37a2b6d5ca6f6110305cd0d5ff4c4e /archiva-modules/archiva-base/archiva-plexus-bridge
parent5c5c959a14ddfe946368026858b06223bcad5230 (diff)
downloadarchiva-c7607a63e569a4bbe271fdcf8744d5ba909652a5.tar.gz
archiva-c7607a63e569a4bbe271fdcf8744d5ba909652a5.zip
a little hackhish but fix use with tomcat maven plugin, sisu need a URLClassLoader as TCL to be able to use lookupList
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1158272 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-plexus-bridge')
-rw-r--r--archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml4
-rw-r--r--archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/MavenIndexerUtils.java80
-rw-r--r--archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridgeException.java6
3 files changed, 90 insertions, 0 deletions
diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml
index 8f4fe3a4d..0da840e23 100644
--- a/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml
+++ b/archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml
@@ -49,5 +49,9 @@
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.indexer</groupId>
+ <artifactId>indexer-core</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/MavenIndexerUtils.java b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/MavenIndexerUtils.java
new file mode 100644
index 000000000..4992dcf02
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/MavenIndexerUtils.java
@@ -0,0 +1,80 @@
+package org.apache.archiva.common.plexusbridge;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.index.context.IndexCreator;
+import org.apache.maven.index.creator.JarFileContentsIndexCreator;
+import org.apache.maven.index.creator.MavenArchetypeArtifactInfoIndexCreator;
+import org.apache.maven.index.creator.MavenPluginArtifactInfoIndexCreator;
+import org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator;
+import org.apache.maven.index.creator.OSGIArtifactIndexCreator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@Service("mavenIndexerUtils")
+public class MavenIndexerUtils
+{
+
+ private Logger log = LoggerFactory.getLogger( getClass() );
+
+ private List<? extends IndexCreator> allIndexCreators;
+
+ @Inject
+ public MavenIndexerUtils( PlexusSisuBridge plexusSisuBridge )
+ throws PlexusSisuBridgeException
+ {
+ allIndexCreators = new ArrayList( plexusSisuBridge.lookupList( IndexCreator.class ) );
+
+ if ( allIndexCreators == null || allIndexCreators.isEmpty() )
+ {
+ // olamy when the TCL is not a URLClassLoader lookupList fail !
+ // when using tomcat maven plugin so adding a simple hack
+ log.warn( "using lookList from sisu plexus failed so build indexCreator manually" );
+
+ allIndexCreators =
+ Arrays.asList( new OSGIArtifactIndexCreator(), new MavenArchetypeArtifactInfoIndexCreator(),
+ new MinimalArtifactInfoIndexCreator(), new JarFileContentsIndexCreator(),
+ new MavenPluginArtifactInfoIndexCreator() );
+
+ }
+
+ log.debug( "allIndexCreators {}", allIndexCreators );
+ }
+
+ public List<? extends IndexCreator> getAllIndexCreators()
+ {
+ return allIndexCreators;
+ }
+
+ public void setAllIndexCreators( List<IndexCreator> allIndexCreators )
+ {
+ this.allIndexCreators = allIndexCreators;
+ }
+}
diff --git a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridgeException.java b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridgeException.java
index 7b67fdf6a..c963b609f 100644
--- a/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridgeException.java
+++ b/archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridgeException.java
@@ -25,6 +25,12 @@ package org.apache.archiva.common.plexusbridge;
public class PlexusSisuBridgeException
extends Exception
{
+
+ public PlexusSisuBridgeException( String message )
+ {
+ super( message );
+ }
+
public PlexusSisuBridgeException( String message, Throwable throwable )
{
super( message, throwable );