]> source.dussan.org Git - archiva.git/commitdiff
Fixing dependencies and adapting to new lib versions
authorMartin Stockhammer <martin_s@apache.org>
Sun, 28 Oct 2018 12:04:30 +0000 (13:04 +0100)
committerMartin Stockhammer <martin_s@apache.org>
Sun, 28 Oct 2018 12:04:30 +0000 (13:04 +0100)
31 files changed:
archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml
archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/test/resources/projects/compile/archetype.properties
archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml
archiva-modules/archiva-base/archiva-converter/pom.xml
archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/archiva/converter/artifact/LegacyRepositoryLayout.java
archiva-modules/archiva-base/archiva-converter/src/main/java/org/apache/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/RepositoryConverterTest.java
archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/artifact/LegacyToDefaultConverterTest.java
archiva-modules/archiva-base/archiva-maven2-indexer/pom.xml
archiva-modules/archiva-base/archiva-plexus-bridge/pom.xml
archiva-modules/archiva-base/archiva-plexus-bridge/src/main/java/org/apache/archiva/common/plexusbridge/PlexusSisuBridge.java
archiva-modules/archiva-base/archiva-plexus-bridge/src/main/resources/META-INF/spring-context.xml
archiva-modules/archiva-base/archiva-proxy-common/pom.xml
archiva-modules/archiva-base/archiva-proxy/pom.xml
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml
archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/pom.xml
archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml
archiva-modules/archiva-web/archiva-security/pom.xml
archiva-modules/archiva-web/archiva-web-common/pom.xml
archiva-modules/archiva-web/archiva-webapp-test/pom.xml
archiva-modules/archiva-web/archiva-webapp/pom.xml
archiva-modules/archiva-web/archiva-webdav/pom.xml
archiva-modules/plugins/maven2-repository/pom.xml
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java
archiva-modules/plugins/metadata-store-jcr/pom.xml
archiva-modules/plugins/stage-repository-merge/pom.xml
pom.xml

index 2c5f953011927e490d4e9da926a8d2cc21bf5ff0..dc457332d7b2398d6da2b6c5fc69f72933771eb0 100644 (file)
@@ -67,5 +67,8 @@
     <requiredProperty key="httpcoreVersion">
       <defaultValue>${httpclient.core.version}</defaultValue>
     </requiredProperty>
+    <requiredProperty key="asmVersion">
+      <defaultValue>${asm.version}</defaultValue>
+    </requiredProperty>
   </requiredProperties>
 </archetype-descriptor>
index cb0c3130efec272bf679492b4063f87f7c351279..5c51c737567a3a124f3f87b06eca4d43a7c625aa 100644 (file)
@@ -40,6 +40,7 @@
     <mockito.version>${mockitoVersion}</mockito.version>
     <httpclient.version>${httpclientVersion}</httpclient.version>
     <httpclient.core.version>${httpcoreVersion}</httpclient.core.version>
+    <asm.version>${asmVersion}</asm.version>
   </properties>
   <dependencies>
     <dependency>
       <version>${springockito.version}</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <!-- match up with those used by Archiva -->
         <artifactId>httpcore</artifactId>
         <version>${httpclient.core.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.ow2.asm</groupId>
+        <artifactId>asm</artifactId>
+        <version>${asm.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
index 2cbbbbed501ba63bb4a11fbd83a598bcb836eea2..001c75db706f25d5e13949237a6cdeb2deb3fa69 100644 (file)
@@ -30,4 +30,5 @@ redbackRegistryVersion=${redback.registry.version}
 springockitoVersion=${springockito.version}
 mockitoVersion=${mockito.version}
 httpclientVersion=${httpclient.version}
-httpcoreVersion=${httpclient.core.version}
\ No newline at end of file
+httpcoreVersion=${httpclient.core.version}
+asmVersion=${asm.version}
\ No newline at end of file
index e7a3ea5556865d162986e3115daeee6d60c1a67e..b0cfb03e920a9f609e253babc6fdaecdade98081 100644 (file)
       <artifactId>jaxb-api</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <pluginManagement>
index 1052ad86647eaca139404f662a2cd100fc5b7b74..8cee773b8f60e6cdf637026eb14c06830a771798 100644 (file)
       <artifactId>archiva-maven2-indexer</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
index 0e92f1b114518b18fb859c1c3adad786e68f31ed..a9a90a53bb27e9feb7f9535b579b0f24510bfc0b 100644 (file)
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-model-converter</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-compat</artifactId>
+      <version>3.0</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.sonatype.sisu</groupId>
+          <artifactId>sisu-guice</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
+    <dependency>
+      <groupId>org.sonatype.aether</groupId>
+      <artifactId>aether-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.sonatype.aether</groupId>
+      <artifactId>aether-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.sonatype.aether</groupId>
+      <artifactId>aether-util</artifactId>
+    </dependency>
+
     <dependency>
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-checksum</artifactId>
       <scope>test</scope>
     </dependency>
 
-    <!-- Needed for JDK >= 9 -->
+    <!-- START Needed for JDK >= 9 -->
     <dependency>
       <groupId>javax.annotation</groupId>
       <artifactId>javax.annotation-api</artifactId>
       <artifactId>jaxb-api</artifactId>
       <scope>test</scope>
     </dependency>
+    <!-- STOP Needed for JDK >= 9 -->
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
index 310123693d23d7251ef603996265edffb41e3e44..96b4ded2d39b1a93a5dc9e90b8dbed9e4340689c 100644 (file)
@@ -23,10 +23,12 @@ import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.codehaus.plexus.component.annotations.Component;
 
 /**
  * @author jdcasey
  */
+@Component( role = ArtifactRepositoryLayout.class, hint = "legacy")
 public class LegacyRepositoryLayout
     implements ArtifactRepositoryLayout
 {
index 8431dcb417561b8f415f3b158dbd655d58d167d1..d5a108804a9cb6505e501c395f35147f8598684c 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.archiva.repository.scanner.RepositoryScanner;
 import org.apache.archiva.repository.scanner.RepositoryScannerException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.springframework.stereotype.Service;
 
@@ -53,7 +54,7 @@ public class DefaultLegacyRepositoryConverter
     /**
      *
      */
-    private ArtifactRepositoryFactory artifactRepositoryFactory;
+    // private ArtifactRepositoryFactory artifactRepositoryFactory;
 
     /**
      *
@@ -77,7 +78,7 @@ public class DefaultLegacyRepositoryConverter
     public DefaultLegacyRepositoryConverter( PlexusSisuBridge plexusSisuBridge )
         throws PlexusSisuBridgeException
     {
-        artifactRepositoryFactory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
+        // artifactRepositoryFactory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
         defaultLayout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
     }
 
@@ -95,8 +96,8 @@ public class DefaultLegacyRepositoryConverter
             legacyRepository.setLayout( "legacy" );
 
             ArtifactRepository repository =
-                artifactRepositoryFactory.createArtifactRepository( "default", defaultRepositoryUrl, defaultLayout,
-                                                                    null, null );
+                new MavenArtifactRepository("default", defaultRepositoryUrl, defaultLayout, null, null);
+
             legacyConverterConsumer.setExcludes( fileExclusionPatterns );
             legacyConverterConsumer.setDestinationRepository( repository );
 
index fe82cd8a41ea03e1dc0bccdd03b1e014339d2ec5..2ba64381d3a33aa6f4bd9d1ec3785c25cee4188f 100644 (file)
@@ -22,11 +22,13 @@ package org.apache.archiva.converter;
 import junit.framework.TestCase;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.converter.artifact.LegacyRepositoryLayout;
 import org.apache.archiva.converter.legacy.LegacyRepositoryConverter;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.junit.Before;
 import org.junit.Test;
@@ -73,14 +75,14 @@ public class RepositoryConverterTest
     {
         super.setUp();
 
-        ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
+        // ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
             //(ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
 
-        ArtifactRepositoryLayout layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "legacy" );
+        ArtifactRepositoryLayout layout = new LegacyRepositoryLayout();
             //(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
 
         Path sourceBase = Paths.get( "src/test/source-repository" );
-        sourceRepository = factory.createArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null,
+        sourceRepository = new MavenArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null,
                                                              null );
 
         layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
index b6fdbf1407355c35b4e187cc8e7d13be5fcbbc23..6ef309f52f1b0f037fc4d82f4c695f085154523b 100644 (file)
@@ -27,7 +27,7 @@ import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
 import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
@@ -82,13 +82,13 @@ public class LegacyToDefaultConverterTest
     {
         super.setUp();
 
-        ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
+        // ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
 
-        ArtifactRepositoryLayout layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "legacy" );
+        ArtifactRepositoryLayout layout = new LegacyRepositoryLayout();
 
         Path sourceBase = getTestFile( "src/test/source-repository" );
         sourceRepository =
-            factory.createArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null, null );
+            new MavenArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null, null );
 
         layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
 
@@ -96,7 +96,7 @@ public class LegacyToDefaultConverterTest
         copyDirectoryStructure( getTestFile( "src/test/target-repository" ), targetBase );
 
         targetRepository =
-            factory.createArtifactRepository( "target", targetBase.toUri().toURL().toString(), layout, null, null );
+            new MavenArtifactRepository( "target", targetBase.toUri().toURL().toString(), layout, null, null );
 
         artifactConverter =
             applicationContext.getBean( "artifactConverter#legacy-to-default", ArtifactConverter.class );
@@ -919,10 +919,9 @@ public class LegacyToDefaultConverterTest
     {
         // test that it fails if the same
 
-        ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
 
         sourceRepository =
-            factory.createArtifactRepository( "source", targetRepository.getUrl(), targetRepository.getLayout(), null,
+            new MavenArtifactRepository( "source", targetRepository.getUrl(), targetRepository.getLayout(), null,
                                               null );
 
         Artifact artifact = createArtifact( "test", "repository-artifact", "1.0" );
@@ -1043,12 +1042,10 @@ public class LegacyToDefaultConverterTest
     private void createModernSourceRepository()
         throws Exception
     {
-        ArtifactRepositoryFactory factory = plexusSisuBridge.lookup( ArtifactRepositoryFactory.class );
-
         ArtifactRepositoryLayout layout = plexusSisuBridge.lookup( ArtifactRepositoryLayout.class, "default" );
 
         Path sourceBase = getTestFile( "src/test/source-modern-repository" );
         sourceRepository =
-            factory.createArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null, null );
+            new MavenArtifactRepository( "source", sourceBase.toUri().toURL().toString(), layout, null, null );
     }
 }
index f7234843434547fef7f6378847ae348928d04568..b68dacb8ebdc9ae9684bf51f87843981d7e429a8 100644 (file)
       <artifactId>log4j-jcl</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
index 580f4c64e30eede444e5ea60e86da8293c5bbcd7..4eb1eacf5a2afa39973fb3812cc1590ba04882d1 100644 (file)
       <artifactId>indexer-core</artifactId>
       <classifier>shaded-lucene</classifier>
     </dependency>
+
+
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+    </dependency>
     <!--
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
index 257b2168929e6720a07014b6232d08c294bff17b..b8e351ca161838ec0ccca1edd2910817f1737700 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.archiva.common.plexusbridge;
  * under the License.
  */
 
+import com.google.inject.AbstractModule;
+import org.apache.maven.bridge.MavenRepositorySystem;
 import org.codehaus.plexus.DefaultContainerConfiguration;
 import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.PlexusConstants;
@@ -26,11 +28,13 @@ import org.codehaus.plexus.PlexusContainerException;
 import org.codehaus.plexus.classworlds.ClassWorld;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.eclipse.sisu.inject.TypeArguments;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
+import javax.inject.Inject;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -48,6 +52,8 @@ import java.util.Map;
 public class PlexusSisuBridge
 {
 
+    private MavenRepositorySystem mavenRepositorySystem = new MavenRepositorySystem();
+
     private Logger log = LoggerFactory.getLogger( getClass() );
 
     private boolean containerAutoWiring = true;
@@ -62,6 +68,16 @@ public class PlexusSisuBridge
 
     private DefaultPlexusContainer plexusContainer;
 
+    class InternalBinder extends AbstractModule {
+
+        @Override
+        protected void configure( )
+        {
+            bind( MavenRepositorySystem.class ).toInstance( mavenRepositorySystem );
+            // bind(TypeArguments.implicitKey( MavenRepositorySystem.class )).to(MavenRepositorySystem.class);
+        }
+    }
+
     @PostConstruct
     public void initialize()
         throws PlexusSisuBridgeException
@@ -88,6 +104,7 @@ public class PlexusSisuBridge
             for ( URL url : urls )
             {
                 containerRealm.addURL( url );
+                log.debug("Added url {}", url);
             }
         }
 
@@ -100,11 +117,16 @@ public class PlexusSisuBridge
         try
         {
             Thread.currentThread().setContextClassLoader( containerRealm );
-            plexusContainer = new DefaultPlexusContainer( conf );
+            InternalBinder binder = new InternalBinder( );
+            plexusContainer = new DefaultPlexusContainer( conf, binder );
+
         }
         catch ( PlexusContainerException e )
         {
             throw new PlexusSisuBridgeException( e.getMessage(), e );
+        } catch (Throwable ex) {
+            log.error("PlexusSisuBridge initialization failed {}", ex.getMessage(), ex);
+            throw new PlexusSisuBridgeException( ex.getMessage(), ex );
         }
         finally
         {
index 62f12541454e8c4cee535e26913529c9a3402036..e5def38ab95464329c4572e5bc4e086d609bf540 100644 (file)
        default-lazy-init="true">
 
   <context:annotation-config/>
-  <context:component-scan base-package="org.apache.archiva.common.plexusbridge
-                                        org.apache.maven.index"/>
+  <context:component-scan base-package="org.apache.archiva.common.plexusbridge, org.apache.maven.*"/>
+
 
   <!--
-  <bean id="indexer" class="org.apache.maven.index.DefaultIndexer"/>
+  <bean id="indexer" class="org.apache.maven.bridge.MavenRepositorySystem.apache.maven.index.DefaultIndexer"/>
   <bean id="scanner" class="org.apache.maven.index.DefaultScanner"/>
   <bean id="indexerEngine" class="org.apache.maven.index.DefaultIndexerEngine"/>
   <bean id="searchEngine" class="org.apache.maven.index.DefaultSearchEngine"/>
index 42226575ffe17b08eb7046492258b7219cff3d2d..c22109ce7b82dd50e97f12e5a9942688cd66745b 100644 (file)
       <artifactId>archiva-test-utils</artifactId>
       <version>${project.version}</version>
       <scope>test</scope>
-    </dependency>    
+    </dependency>
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
index c58c0849b7d59c1628627a8d8c9d1298d1bbecab..23c0e6c3bc6a27551b13e642d1c488b5f39d836d 100644 (file)
       <scope>test</scope>
     </dependency>
 
-    <!-- Needed for JDK >= 9 -->
+    <!-- START Needed for JDK >= 9 -->
     <dependency>
       <groupId>javax.annotation</groupId>
       <artifactId>javax.annotation-api</artifactId>
       <artifactId>jaxb-api</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <!-- END Needed for JDK >= 9 -->
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
index cfcf79349258d70958557ddd3ff7450e9db5f7db..5e99f6d9b9deb772b6636f9ed6ef05699496b53e 100644 (file)
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <build>
index b7aabb5fc748fa3e117eed53271c8f07768d16d7..b55a4213cfd52c94a110cedde2f04db2bf1cbfaa 100644 (file)
       <scope>test</scope>
     </dependency>
 
-
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
index 1b72a32d970a6a9636ba64470ef33dfaf29ead9e..0d12655269124e7a693fa292029efe30dc3b9101 100644 (file)
       <artifactId>xercesImpl</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
index 6e6a1da4ced339b3dce37c2052a652afda92184f..673facf7ef7dd19e8ad86ddc8b0406ed54d3a5e8 100644 (file)
       <artifactId>archiva-maven2-indexer</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
index 7c4dbfec20a6e5c86ada8ad34460b3ca573f391d..a7765ec0d30c5d387b0674a28b82f87fd466a35e 100644 (file)
       <artifactId>jaxb-runtime</artifactId>
       <scope>test</scope>
     </dependency>
+
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <build>
index 51383b2aacb0f81922df6ef064738809510e768b..9b58ffd9f5296af6f3819f79aac70db0ce1093f4 100644 (file)
@@ -31,7 +31,8 @@
 
   <properties>
     <webappDirectory>${project.build.directory}/container/webapps/archiva</webappDirectory>
-    <container.propertiesPortFilePath>${project.build.directory}/container-port.properties</container.propertiesPortFilePath>
+    <container.propertiesPortFilePath>${project.build.directory}/container-port.properties
+    </container.propertiesPortFilePath>
     <maxWaitTimeInMs>10000</maxWaitTimeInMs>
     <selenium-server.version>3.4.0</selenium-server.version>
     <fluentlenium.version>3.2.0</fluentlenium.version>
       <artifactId>archiva-webapp</artifactId>
       <type>war</type>
     </dependency>
-<!--    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-slf4j-logging</artifactId>
-      <exclusions>
-        <exclusion>
-          <artifactId>plexus-component-api</artifactId>
+    <!--    <dependency>
           <groupId>org.codehaus.plexus</groupId>
-        </exclusion>
-      </exclusions>
-    </dependency>-->
+          <artifactId>plexus-utils</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-slf4j-logging</artifactId>
+          <exclusions>
+            <exclusion>
+              <artifactId>plexus-component-api</artifactId>
+              <groupId>org.codehaus.plexus</groupId>
+            </exclusion>
+          </exclusions>
+        </dependency>-->
 
     <!--
       jcr-oak currently needs guava 15.0 and selenium webdriver needs 22.0
     </dependency>
 
 
-
     <dependency>
       <groupId>org.seleniumhq.selenium</groupId>
       <artifactId>selenium-server</artifactId>
     </dependency>
 
 
-
-
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-slf4j-logging</artifactId>
+      <version>1.1</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
   </dependencies>
 
   <build>
                 <configuration>
                   <failOnError>false</failOnError>
                   <target>
-                    <delete file="${user.home}/.m2/archiva.xml" />
+                    <delete file="${user.home}/.m2/archiva.xml"/>
                   </target>
                 </configuration>
               </execution>
index e8d26bb5555dfcfdb976281377860fb3b76d59e0..d68c36183d1a6d9017a4d2601119859922b5f83d 100644 (file)
       <version>${spring.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-slf4j-logging</artifactId>
+      <version>1.1</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-container-default</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+
   </dependencies>
 
   <build>
index 44d50571cc9bd4e806c37203f023a5cd6e0a9517..23e52540229b3de806c85e2c008c2a35def8e052 100644 (file)
       <scope>test</scope>
     </dependency>
 
-    <!-- Needed for JDK >= 9 -->
+    <!-- START Needed for JDK >= 9 -->
     <dependency>
       <groupId>javax.annotation</groupId>
       <artifactId>javax.annotation-api</artifactId>
       <artifactId>jaxb-api</artifactId>
       <scope>test</scope>
     </dependency>
+    <!-- END Needed for JDK >= 9 -->
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
 
   </dependencies>
   <build>
index a1fc7668642287ffcb1af73aeb2a3833b7cd947e..07cfd1821e64197d348d7ca88d5361efbad06b0d 100644 (file)
@@ -99,8 +99,7 @@
 
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-aether-provider</artifactId>
-      <version>3.3.9</version>
+      <artifactId>maven-resolver-provider</artifactId>
     </dependency>
 
     <!--
     <dependency>
       <groupId>org.eclipse.aether</groupId>
       <artifactId>aether-api</artifactId>
-      <version>0.9.0.M2</version>
     </dependency>
 
     <dependency>
       <groupId>org.eclipse.aether</groupId>
       <artifactId>aether-connector-file</artifactId>
-      <version>0.9.0.M2</version>
     </dependency>
 
     <dependency>
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
   <build>
     <plugins>
index e8ff5e8f66ae658a2dca379357bb1d572335f646..b3b420f29003ef191db779258f09359259f4f77e 100644 (file)
@@ -75,6 +75,7 @@ import org.apache.maven.model.building.ModelBuildingRequest;
 import org.apache.maven.model.building.ModelProblem;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.eclipse.aether.impl.VersionRangeResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.ApplicationContext;
@@ -291,7 +292,7 @@ public class Maven2RepositoryStorage
             // MRM-1411
             req.setModelResolver(
                 new RepositoryModelResolver( managedRepository, pathTranslator, wagonFactory, remoteRepositories,
-                                             networkProxies, managedRepository ) );
+                                             networkProxies, managedRepository ));
 
             Model model;
             try
index b2fd1220f8b5606ae48b7a47277d09e005a56693..e5aea4ce302cd5efc29a74379cfae625a3e1d096 100644 (file)
@@ -21,6 +21,8 @@ package org.apache.archiva.metadata.repository.storage.maven2;
 
 import org.apache.archiva.admin.model.beans.NetworkProxy;
 import org.apache.archiva.common.utils.VersionUtil;
+import org.apache.archiva.dependency.tree.maven2.ArchivaRepositoryConnectorFactory;
+import org.apache.archiva.indexer.UnsupportedBaseContextException;
 import org.apache.archiva.maven2.metadata.MavenMetadataReader;
 import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
 import org.apache.archiva.model.ArchivaRepositoryMetadata;
@@ -34,6 +36,7 @@ import org.apache.archiva.repository.RepositoryCredentials;
 import org.apache.archiva.xml.XMLException;
 import org.apache.commons.lang.StringUtils;
 import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.Repository;
@@ -42,6 +45,10 @@ import org.apache.maven.model.building.ModelSource;
 import org.apache.maven.model.resolution.InvalidRepositoryException;
 import org.apache.maven.model.resolution.ModelResolver;
 import org.apache.maven.model.resolution.UnresolvableModelException;
+import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
+import org.apache.maven.repository.internal.DefaultVersionRangeResolver;
+import org.apache.maven.repository.internal.DefaultVersionResolver;
+import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
 import org.apache.maven.wagon.ConnectionException;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
@@ -50,6 +57,26 @@ import org.apache.maven.wagon.authentication.AuthenticationException;
 import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.authorization.AuthorizationException;
 import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.impl.ArtifactDescriptorReader;
+import org.eclipse.aether.impl.DefaultServiceLocator;
+import org.eclipse.aether.impl.VersionRangeResolver;
+import org.eclipse.aether.impl.VersionResolver;
+import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
+import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
+import org.eclipse.aether.resolution.VersionRangeRequest;
+import org.eclipse.aether.resolution.VersionRangeResolutionException;
+import org.eclipse.aether.resolution.VersionRangeResult;
+import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
+import org.eclipse.aether.util.graph.selector.AndDependencySelector;
+import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -63,6 +90,10 @@ import java.util.Map;
 public class RepositoryModelResolver
     implements ModelResolver
 {
+
+    private RepositorySystemSession session;
+    private VersionRangeResolver versionRangeResolver;
+
     private Path basedir;
 
     private RepositoryPathTranslator pathTranslator;
@@ -77,6 +108,8 @@ public class RepositoryModelResolver
 
     private static final String METADATA_FILENAME = "maven-metadata.xml";
 
+    private DefaultServiceLocator locator;
+
     // key/value: remote repo ID/network proxy
     Map<String, NetworkProxy> networkProxyMap;
 
@@ -91,7 +124,7 @@ public class RepositoryModelResolver
 
     public RepositoryModelResolver( ManagedRepository managedRepository, RepositoryPathTranslator pathTranslator,
                                     WagonFactory wagonFactory, List<RemoteRepository> remoteRepositories,
-                                    Map<String, NetworkProxy> networkProxiesMap, ManagedRepository targetRepository )
+                                    Map<String, NetworkProxy> networkProxiesMap, ManagedRepository targetRepository)
     {
         this( Paths.get( managedRepository.getLocation() ), pathTranslator );
 
@@ -104,6 +137,45 @@ public class RepositoryModelResolver
         this.networkProxyMap = networkProxiesMap;
 
         this.targetRepository = targetRepository;
+
+        this.locator =  MavenRepositorySystemUtils.newServiceLocator( );
+
+        locator.addService( RepositoryConnectorFactory.class,
+            ArchivaRepositoryConnectorFactory.class );// FileRepositoryConnectorFactory.class );
+        locator.addService( VersionResolver.class, DefaultVersionResolver.class );
+        locator.addService( VersionRangeResolver.class, DefaultVersionRangeResolver.class );
+        locator.addService( ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class );
+
+        this.session = newRepositorySystemSession( newRepositorySystem(), managedRepository.getLocalPath().toString() );
+
+        this.versionRangeResolver = locator.getService(VersionRangeResolver.class);
+    }
+
+    private RepositorySystem newRepositorySystem()
+    {
+        return locator.getService( RepositorySystem.class );
+    }
+
+    private RepositorySystemSession newRepositorySystemSession( RepositorySystem system, String localRepoDir )
+    {
+        DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession( );
+
+        LocalRepository repo = new LocalRepository( localRepoDir );
+
+        DependencySelector depFilter = new AndDependencySelector( new ExclusionDependencySelector() );
+        session.setDependencySelector( depFilter );
+        SimpleLocalRepositoryManagerFactory repFactory = new SimpleLocalRepositoryManagerFactory( );
+        try
+        {
+            LocalRepositoryManager manager = repFactory.newInstance( session, repo );
+            session.setLocalRepositoryManager(manager);
+        }
+        catch ( NoLocalRepositoryManagerException e )
+        {
+            e.printStackTrace( );
+        }
+
+        return session;
     }
 
     @Override
@@ -163,18 +235,41 @@ public class RepositoryModelResolver
         return new FileModelSource( model.toFile() );
     }
 
-    // TODO: v3.0.0 Implement this method
-    @Override
-    public ModelSource resolveModel( Parent parent ) throws UnresolvableModelException
-    {
-        return null;
+    public ModelSource resolveModel(Parent parent) throws UnresolvableModelException {
+        try {
+            Artifact artifact = new DefaultArtifact(parent.getGroupId(), parent.getArtifactId(), "", "pom", parent.getVersion());
+            VersionRangeRequest versionRangeRequest;
+            versionRangeRequest = new VersionRangeRequest(artifact, null, null);
+            VersionRangeResult versionRangeResult = this.versionRangeResolver.resolveVersionRange(this.session, versionRangeRequest);
+            if (versionRangeResult.getHighestVersion() == null) {
+                throw new UnresolvableModelException(String.format("No versions matched the requested parent version range '%s'", parent.getVersion()), parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
+            } else if (versionRangeResult.getVersionConstraint() != null && versionRangeResult.getVersionConstraint().getRange() != null && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null) {
+                throw new UnresolvableModelException(String.format("The requested parent version range '%s' does not specify an upper bound", parent.getVersion()), parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
+            } else {
+                parent.setVersion(versionRangeResult.getHighestVersion().toString());
+                return this.resolveModel(parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
+            }
+        } catch ( VersionRangeResolutionException var5) {
+            throw new UnresolvableModelException(var5.getMessage(), parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), var5);
+        }
     }
 
-    // TODO: v3.0.0 Implement this method
-    @Override
-    public ModelSource resolveModel( Dependency dependency ) throws UnresolvableModelException
-    {
-        return null;
+    public ModelSource resolveModel(Dependency dependency) throws UnresolvableModelException {
+        try {
+            Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), "", "pom", dependency.getVersion());
+            VersionRangeRequest versionRangeRequest = new VersionRangeRequest(artifact, null, null);
+            VersionRangeResult versionRangeResult = this.versionRangeResolver.resolveVersionRange(this.session, versionRangeRequest);
+            if (versionRangeResult.getHighestVersion() == null) {
+                throw new UnresolvableModelException(String.format("No versions matched the requested dependency version range '%s'", dependency.getVersion()), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
+            } else if (versionRangeResult.getVersionConstraint() != null && versionRangeResult.getVersionConstraint().getRange() != null && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null) {
+                throw new UnresolvableModelException(String.format("The requested dependency version range '%s' does not specify an upper bound", dependency.getVersion()), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
+            } else {
+                dependency.setVersion(versionRangeResult.getHighestVersion().toString());
+                return this.resolveModel(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
+            }
+        } catch (VersionRangeResolutionException var5) {
+            throw new UnresolvableModelException(var5.getMessage(), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), var5);
+        }
     }
 
     protected Path findTimeStampedSnapshotPom( String groupId, String artifactId, String version,
@@ -237,7 +332,7 @@ public class RepositoryModelResolver
     public ModelResolver newCopy()
     {
         return new RepositoryModelResolver( managedRepository,  pathTranslator, wagonFactory, remoteRepositories, 
-                                            networkProxyMap, targetRepository );
+                                            networkProxyMap, targetRepository);
     }
 
     // FIXME: we need to do some refactoring, we cannot re-use the proxy components of archiva-proxy in maven2-repository
index 299a29ac8fbccefec4531301e3dc525a298d7331..c53149a93bbe47db06a93c767021eca52dcd2f9f 100644 (file)
       <artifactId>metrics-core</artifactId>
       <version>3.1.0</version>
     </dependency>
-  </dependencies>
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+</dependencies>
   <build>
     <testResources>
       <testResource>
index 4023b24a175f1a00f2f37cd53d1a017c4ce5687b..d8719f8e67a4587f9a2864a502a0f4466fa427c6 100644 (file)
       <artifactId>xercesImpl</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
   <build>
     <plugins>
diff --git a/pom.xml b/pom.xml
index 360ff45ec214bd447c068520feab7d2ddc32cd58..2ab77a10f7ac4a7c75ac22921517e1d395acda6e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -55,8 +55,9 @@
     <commons-lang.version>2.6</commons-lang.version>
 
     <maven3x.version>3.5.4</maven3x.version>
-    <maven.version>2.0.8</maven.version>
-    <aether.version>1.13.1</aether.version>
+    <maven.artifact-manager.version>2.2.1</maven.artifact-manager.version>
+    <sonatype.aether.version>1.13.1</sonatype.aether.version>
+    <eclipse.aether.version>0.9.0.M2</eclipse.aether.version>
 
     <maven-model-converter.version>2.1</maven-model-converter.version>
     <maven.indexer.version>6.0.0</maven.indexer.version>
     <guava.version>15.0</guava.version>
     <openjpaVersion>2.4.1</openjpaVersion>
 
+    <asm.version>5.0.4</asm.version>
+
     <!-- restore when we will be able to use a derby in memory database -->
     <redbackTestJdbcUrl>jdbc:derby:memory:users-test;create=true</redbackTestJdbcUrl>
     <redbackTestJdbcDriver>org.apache.derby.jdbc.EmbeddedDriver</redbackTestJdbcDriver>
+
     <sisu-inject-plexus.version>0.3.3</sisu-inject-plexus.version>
     <plexus-digest.version>1.1</plexus-digest.version>
     <plexus-expression-evaluator.version>2.1</plexus-expression-evaluator.version>
         <artifactId>mail</artifactId>
         <version>${javaxMailVersion}</version>
       </dependency>
+
+
+      <!-- Maven related dependencies -->
       <dependency>
         <groupId>org.apache.maven</groupId>
         <artifactId>maven-model</artifactId>
       <dependency>
         <groupId>org.apache.maven</groupId>
         <artifactId>maven-artifact</artifactId>
-        <version>${maven.version}</version>
+        <version>${maven3x.version}</version>
       </dependency>
       <dependency>
         <groupId>org.apache.maven</groupId>
         <artifactId>maven-artifact-manager</artifactId>
-        <version>${maven.version}</version>
+        <version>${maven.artifact-manager.version}</version>
         <exclusions>
           <exclusion>
             <groupId>org.codehaus.plexus</groupId>
         </exclusions>
       </dependency>
 
+
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-repository-metadata</artifactId>
+        <version>${maven3x.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-resolver-provider</artifactId>
+        <version>${maven3x.version}</version>
+      </dependency>
+
+      <!-- Eclipse aether -->
+      <dependency>
+        <groupId>org.eclipse.aether</groupId>
+        <artifactId>aether-api</artifactId>
+        <version>${eclipse.aether.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.eclipse.aether</groupId>
+        <artifactId>aether-connector-file</artifactId>
+        <version>${eclipse.aether.version}</version>
+      </dependency>
+
+      <!-- Sonatype aether -->
       <dependency>
         <groupId>org.sonatype.aether</groupId>
         <artifactId>aether-api</artifactId>
-        <version>${aether.version}</version>
+        <version>${sonatype.aether.version}</version>
       </dependency>
       <dependency>
         <groupId>org.sonatype.aether</groupId>
         <artifactId>aether-impl</artifactId>
-        <version>${aether.version}</version>
+        <version>${sonatype.aether.version}</version>
       </dependency>
       <dependency>
         <groupId>org.sonatype.aether</groupId>
         <artifactId>aether-util</artifactId>
-        <version>${aether.version}</version>
+        <version>${sonatype.aether.version}</version>
       </dependency>
       <dependency>
         <groupId>org.sonatype.aether</groupId>
         <artifactId>aether-connector-file</artifactId>
-        <version>${aether.version}</version>
+        <version>${sonatype.aether.version}</version>
       </dependency>
 
-      <dependency>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>maven-repository-metadata</artifactId>
-        <version>${maven3x.version}</version>
-      </dependency>
       <!--
       <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <version>2.3.0</version>
       </dependency>
 
+      <dependency>
+        <groupId>org.ow2.asm</groupId>
+        <artifactId>asm</artifactId>
+        <version>${asm.version}</version>
+      </dependency>
+
+
+
+
     </dependencies>
   </dependencyManagement>