From 5456b9fee0c6cf7ce585e344e3cc150ed0981bad Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Thu, 18 Jun 2020 23:01:26 +0200 Subject: [PATCH] Removing sisu bridge from maven projects --- .../archiva-maven-indexer/pom.xml | 5 +++ .../archiva-maven-repository/pom.xml | 30 ++++++++++++----- .../tree/Maven3DependencyTreeBuilder.java | 32 +++++++++++++++---- .../resources/META-INF/spring-context.xml | 2 +- .../tree/DependencyTreeBuilderTestMaven3.java | 4 --- .../webdav/ArchivaDavResourceFactory.java | 2 -- .../webdav/ArchivaDavResourceFactoryTest.java | 10 ++---- .../UnauthenticatedDavResourceFactory.java | 5 +-- pom.xml | 18 +++++++++++ 9 files changed, 74 insertions(+), 34 deletions(-) diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/pom.xml b/archiva-modules/archiva-maven/archiva-maven-indexer/pom.xml index 0ff32437c..29d22e62a 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/pom.xml +++ b/archiva-modules/archiva-maven/archiva-maven-indexer/pom.xml @@ -130,6 +130,11 @@ + + org.eclipse.sisu + org.eclipse.sisu.plexus + + javax.inject diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml b/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml index 383cb9519..03f3589a6 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml +++ b/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml @@ -162,6 +162,25 @@ org.apache.maven.resolver maven-resolver-spi + + org.apache.maven.indexer + indexer-core + shaded-lucene + + + org.apache.lucene + lucene-queryparser + + + org.apache.lucene + lucene-analyzers-common + + + + + org.eclipse.sisu + org.eclipse.sisu.plexus + org.apache.maven.resolver @@ -190,12 +209,12 @@ httpclient - + org.apache.archiva @@ -251,12 +270,7 @@ archiva-components-spring-quartz test - - org.apache.maven.indexer - indexer-core - shaded-lucene - test - + org.xmlunit xmlunit-core diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/dependency/tree/Maven3DependencyTreeBuilder.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/dependency/tree/Maven3DependencyTreeBuilder.java index 3b4f51daf..a83c3e13d 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/dependency/tree/Maven3DependencyTreeBuilder.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/dependency/tree/Maven3DependencyTreeBuilder.java @@ -23,8 +23,6 @@ import org.apache.archiva.admin.model.beans.NetworkProxy; import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.maven2.model.TreeEntry; import org.apache.archiva.metadata.maven.MavenMetadataReader; @@ -38,7 +36,11 @@ import org.apache.archiva.repository.metadata.RepositoryMetadataException; import org.apache.archiva.repository.metadata.base.MetadataTools; import org.apache.archiva.repository.storage.StorageAsset; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.bridge.MavenRepositorySystem; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -70,9 +72,6 @@ public class Maven3DependencyTreeBuilder { private Logger log = LoggerFactory.getLogger( Maven3DependencyTreeBuilder.class ); - @Inject - private PlexusSisuBridge plexusSisuBridge; - private MavenRepositorySystem mavenRepositorySystem; @Inject @@ -98,9 +97,28 @@ public class Maven3DependencyTreeBuilder @PostConstruct public void initialize() - throws PlexusSisuBridgeException + throws RuntimeException + { + try + { + mavenRepositorySystem = initMaven( ); + } + catch ( IllegalAccessException e ) + { + throw new RuntimeException( "Could not initialize maven" ); + } + } + + MavenRepositorySystem initMaven() throws IllegalAccessException { - mavenRepositorySystem = plexusSisuBridge.lookup(MavenRepositorySystem.class); + MavenRepositorySystem system = new MavenRepositorySystem( ); + DefaultArtifactHandlerManager afm = new DefaultArtifactHandlerManager( ); + DefaultRepositoryLayout layout = new DefaultRepositoryLayout( ); + FieldUtils.writeField( system, "artifactHandlerManager", afm, true); + Map map = new HashMap<>( ); + map.put( "defaultRepositoryLayout", layout ); + FieldUtils.writeField( system, "layouts", map, true); + return system; } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/resources/META-INF/spring-context.xml index 3b9fb1788..a01350626 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/resources/META-INF/spring-context.xml @@ -29,7 +29,7 @@ + org.apache.archiva.repository.maven.content,org.apache.maven.index"/> diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/dependency/tree/DependencyTreeBuilderTestMaven3.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/dependency/tree/DependencyTreeBuilderTestMaven3.java index c65cfb218..c4fa8db2d 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/dependency/tree/DependencyTreeBuilderTestMaven3.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/dependency/tree/DependencyTreeBuilderTestMaven3.java @@ -19,7 +19,6 @@ package org.apache.archiva.repository.maven.dependency.tree; */ import junit.framework.TestCase; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; @@ -49,9 +48,6 @@ public class DependencyTreeBuilderTestMaven3 @Named( "dependencyTreeBuilder#maven3" ) private Maven3DependencyTreeBuilder builder; - @Inject - private PlexusSisuBridge plexusSisuBridge; - private static final String TEST_REPO_ID = "test"; private static final String TEST_VERSION = "1.2.1"; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index 3c10dcdd6..f3e8737e8 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -27,7 +27,6 @@ import org.apache.archiva.checksum.ChecksumUtil; import org.apache.archiva.checksum.StreamingChecksum; import org.apache.archiva.common.filelock.DefaultFileLockManager; import org.apache.archiva.common.filelock.FileLockManager; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.common.utils.PathUtil; import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.configuration.ArchivaConfiguration; @@ -189,7 +188,6 @@ public class ArchivaDavResourceFactory @Inject public ArchivaDavResourceFactory( ApplicationContext applicationContext, ArchivaConfiguration archivaConfiguration ) - throws PlexusSisuBridgeException { this.archivaConfiguration = archivaConfiguration; this.applicationContext = applicationContext; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java index a1e30da1f..450a3b92e 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java @@ -28,8 +28,6 @@ import org.apache.archiva.admin.repository.DefaultRepositoryCommonValidator; import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin; import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin; import org.apache.archiva.common.filelock.FileLockManager; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.FileTypes; @@ -128,9 +126,6 @@ public class ArchivaDavResourceFactoryTest @Inject ApplicationContext applicationContext; - @Inject - PlexusSisuBridge plexusSisuBridge; - @Inject DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin; @@ -239,7 +234,7 @@ public class ArchivaDavResourceFactoryTest repoRequest = repoRequestControl.createMock( MavenRepositoryRequestInfo.class ); resourceFactory = - new OverridingArchivaDavResourceFactory( applicationContext, plexusSisuBridge, archivaConfiguration ); + new OverridingArchivaDavResourceFactory( applicationContext, archivaConfiguration ); resourceFactory.setArchivaConfiguration( archivaConfiguration ); proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).clear(); proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).add(new OverridingRepositoryProxyHandler(this)); @@ -728,9 +723,8 @@ public class ArchivaDavResourceFactoryTest extends ArchivaDavResourceFactory { - OverridingArchivaDavResourceFactory( ApplicationContext applicationContext, PlexusSisuBridge plexusSisuBridge, + OverridingArchivaDavResourceFactory( ApplicationContext applicationContext, ArchivaConfiguration archivaConfiguration ) - throws PlexusSisuBridgeException { super( applicationContext, archivaConfiguration ); } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/UnauthenticatedDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/UnauthenticatedDavResourceFactory.java index 0390913a8..5aadd4653 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/UnauthenticatedDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/UnauthenticatedDavResourceFactory.java @@ -19,8 +19,6 @@ package org.apache.archiva.webdav; * under the License. */ -import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.jackrabbit.webdav.DavException; import org.apache.jackrabbit.webdav.DavServletRequest; @@ -39,9 +37,8 @@ public class UnauthenticatedDavResourceFactory { @Inject - public UnauthenticatedDavResourceFactory( ApplicationContext applicationContext, PlexusSisuBridge plexusSisuBridge, + public UnauthenticatedDavResourceFactory( ApplicationContext applicationContext, ArchivaConfiguration archivaConfiguration ) - throws PlexusSisuBridgeException { super( applicationContext, archivaConfiguration ); } diff --git a/pom.xml b/pom.xml index 7719c8fbb..7fd3a9327 100644 --- a/pom.xml +++ b/pom.xml @@ -933,6 +933,24 @@ org.apache.maven maven-core ${maven3x.version} + + + com.google.inject + guice + + + org.eclipse.sisu + org.eclipse.sisu.plexus + + + org.eclipse.sisu + org.eclipse.sisu.inject + + + com.google.guava + guava + + -- 2.39.5