aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java1
-rw-r--r--archiva-modules/archiva-base/archiva-maven2-metadata/pom.xml49
-rw-r--r--archiva-modules/archiva-base/archiva-maven2-metadata/src/main/java/org/apache/archiva/maven2/metadata/MavenMetadataReader.java114
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java1
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/pom.xml4
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataException.java5
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataReader.java56
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java29
-rw-r--r--archiva-modules/archiva-base/pom.xml4
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/UploadAction.java1
-rw-r--r--archiva-modules/plugins/maven2-repository/pom.xml4
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java4
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java8
-rw-r--r--archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java47
-rw-r--r--archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java1
-rw-r--r--pom.xml5
16 files changed, 250 insertions, 83 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
index 45d62658e..6c42176b9 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
@@ -27,7 +27,6 @@ import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.repository.events.RepositoryListener;
import org.apache.archiva.common.utils.VersionComparator;
import org.apache.archiva.common.utils.VersionUtil;
-import org.apache.archiva.model.ArchivaArtifact;
import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
diff --git a/archiva-modules/archiva-base/archiva-maven2-metadata/pom.xml b/archiva-modules/archiva-base/archiva-maven2-metadata/pom.xml
new file mode 100644
index 000000000..14da7c7ff
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-maven2-metadata/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>archiva-base</artifactId>
+ <groupId>org.apache.archiva</groupId>
+ <version>1.4-M3-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>archiva-maven2-metadata</artifactId>
+ <version>1.4-M3-SNAPSHOT</version>
+
+ <name>archiva-maven2-metadata</name>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-model</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-xml-tools</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/archiva-modules/archiva-base/archiva-maven2-metadata/src/main/java/org/apache/archiva/maven2/metadata/MavenMetadataReader.java b/archiva-modules/archiva-base/archiva-maven2-metadata/src/main/java/org/apache/archiva/maven2/metadata/MavenMetadataReader.java
new file mode 100644
index 000000000..ade5a1fc0
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-maven2-metadata/src/main/java/org/apache/archiva/maven2/metadata/MavenMetadataReader.java
@@ -0,0 +1,114 @@
+package org.apache.archiva.maven2.metadata;
+/*
+ * 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.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.archiva.model.Plugin;
+import org.apache.archiva.model.SnapshotVersion;
+import org.apache.archiva.xml.XMLException;
+import org.apache.archiva.xml.XMLReader;
+import org.apache.commons.lang.math.NumberUtils;
+import org.dom4j.Element;
+
+import java.io.File;
+import java.util.Date;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+public class MavenMetadataReader
+{
+ /*
+ <?xml version="1.0" encoding="UTF-8"?>
+ <metadata modelVersion="1.1.0">
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva</artifactId>
+ <version>1.4-M3-SNAPSHOT</version>
+ <versioning>
+ <snapshot>
+ <timestamp>20120310.230917</timestamp>
+ <buildNumber>2</buildNumber>
+ </snapshot>
+ <lastUpdated>20120310230917</lastUpdated>
+ <snapshotVersions>
+ <snapshotVersion>
+ <extension>pom</extension>
+ <value>1.4-M3-20120310.230917-2</value>
+ <updated>20120310230917</updated>
+ </snapshotVersion>
+ </snapshotVersions>
+ </versioning>
+ </metadata>
+ */
+
+ /**
+ * Read and return the {@link org.apache.archiva.model.ArchivaRepositoryMetadata} object from the provided xml file.
+ *
+ * @param metadataFile the maven-metadata.xml file to read.
+ * @return the archiva repository metadata object that represents the provided file contents.
+ * @throws XMLException
+ */
+ public static ArchivaRepositoryMetadata read( File metadataFile )
+ throws XMLException
+ {
+
+ XMLReader xml = new XMLReader( "metadata", metadataFile );
+ // invoke this to remove namespaces, see MRM-1136
+ xml.removeNamespaces();
+
+ ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
+
+ metadata.setGroupId( xml.getElementText( "//metadata/groupId" ) );
+ metadata.setArtifactId( xml.getElementText( "//metadata/artifactId" ) );
+ metadata.setVersion( xml.getElementText( "//metadata/version" ) );
+ metadata.setFileLastModified( new Date( metadataFile.lastModified() ) );
+ metadata.setFileSize( metadataFile.length() );
+
+ metadata.setLastUpdated( xml.getElementText( "//metadata/versioning/lastUpdated" ) );
+ metadata.setLatestVersion( xml.getElementText( "//metadata/versioning/latest" ) );
+ metadata.setReleasedVersion( xml.getElementText( "//metadata/versioning/release" ) );
+ metadata.setAvailableVersions( xml.getElementListText( "//metadata/versioning/versions/version" ) );
+
+ Element snapshotElem = xml.getElement( "//metadata/versioning/snapshot" );
+ if ( snapshotElem != null )
+ {
+ SnapshotVersion snapshot = new SnapshotVersion();
+ snapshot.setTimestamp( snapshotElem.elementTextTrim( "timestamp" ) );
+ String tmp = snapshotElem.elementTextTrim( "buildNumber" );
+ if ( NumberUtils.isNumber( tmp ) )
+ {
+ snapshot.setBuildNumber( NumberUtils.toInt( tmp ) );
+ }
+ metadata.setSnapshotVersion( snapshot );
+ }
+
+ for ( Element plugin : xml.getElementList( "//metadata/plugins/plugin" ) )
+ {
+ Plugin p = new Plugin();
+ p.setPrefix( plugin.elementTextTrim( "prefix" ) );
+ p.setArtifactId( plugin.elementTextTrim( "artifactId" ) );
+ p.setName( plugin.elementTextTrim( "name" ) );
+ metadata.addPlugin( p );
+ }
+
+ return metadata;
+
+ }
+}
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java
index 928b669e1..b2f289953 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/proxy/MetadataTransferTest.java
@@ -38,7 +38,6 @@ import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
import org.apache.maven.wagon.TransferFailedException;
import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.Diff;
-import org.junit.Before;
import org.junit.Test;
import java.io.File;
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml
index ed65056c5..518647ea1 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml
+++ b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml
@@ -54,6 +54,10 @@
<artifactId>archiva-xml-tools</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-maven2-metadata</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataException.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataException.java
index f364bb1fd..d20da9fd2 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataException.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataException.java
@@ -22,11 +22,12 @@ package org.apache.archiva.repository.metadata;
import org.apache.archiva.repository.RepositoryException;
/**
- * RepositoryMetadataException
+ * RepositoryMetadataException
*
* @version $Id$
*/
-public class RepositoryMetadataException extends RepositoryException
+public class RepositoryMetadataException
+ extends RepositoryException
{
public RepositoryMetadataException()
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataReader.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataReader.java
index e8a5eaa88..160afc1a8 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataReader.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataReader.java
@@ -19,27 +19,24 @@ package org.apache.archiva.repository.metadata;
* under the License.
*/
-import java.io.File;
-import java.util.Date;
-
-import org.apache.commons.lang.math.NumberUtils;
+import org.apache.archiva.maven2.metadata.MavenMetadataReader;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
-import org.apache.archiva.model.Plugin;
-import org.apache.archiva.model.SnapshotVersion;
import org.apache.archiva.xml.XMLException;
-import org.apache.archiva.xml.XMLReader;
-import org.dom4j.Element;
+
+import java.io.File;
/**
* RepositoryMetadataReader - read maven-metadata.xml files.
*
* @version $Id$
+ * @deprecated use {@link MavenMetadataReader}
*/
public class RepositoryMetadataReader
{
+
/**
* Read and return the {@link ArchivaRepositoryMetadata} object from the provided xml file.
- *
+ *
* @param metadataFile the maven-metadata.xml file to read.
* @return the archiva repository metadata object that represents the provided file contents.
* @throws RepositoryMetadataException
@@ -49,46 +46,7 @@ public class RepositoryMetadataReader
{
try
{
- XMLReader xml = new XMLReader( "metadata", metadataFile );
- // invoke this to remove namespaces, see MRM-1136
- xml.removeNamespaces();
-
- ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
-
- metadata.setGroupId( xml.getElementText( "//metadata/groupId" ) );
- metadata.setArtifactId( xml.getElementText( "//metadata/artifactId" ) );
- metadata.setVersion( xml.getElementText( "//metadata/version" ) );
- metadata.setFileLastModified( new Date( metadataFile.lastModified() ) );
- metadata.setFileSize( metadataFile.length() );
-
- metadata.setLastUpdated( xml.getElementText( "//metadata/versioning/lastUpdated" ) );
- metadata.setLatestVersion( xml.getElementText( "//metadata/versioning/latest" ) );
- metadata.setReleasedVersion( xml.getElementText( "//metadata/versioning/release" ) );
- metadata.setAvailableVersions( xml.getElementListText( "//metadata/versioning/versions/version" ) );
-
- Element snapshotElem = xml.getElement( "//metadata/versioning/snapshot" );
- if ( snapshotElem != null )
- {
- SnapshotVersion snapshot = new SnapshotVersion();
- snapshot.setTimestamp( snapshotElem.elementTextTrim( "timestamp" ) );
- String tmp = snapshotElem.elementTextTrim( "buildNumber" );
- if( NumberUtils.isNumber( tmp ))
- {
- snapshot.setBuildNumber( NumberUtils.toInt( tmp ) );
- }
- metadata.setSnapshotVersion( snapshot );
- }
-
- for ( Element plugin : xml.getElementList( "//metadata/plugins/plugin" ) )
- {
- Plugin p = new Plugin();
- p.setPrefix( plugin.elementTextTrim( "prefix" ) );
- p.setArtifactId( plugin.elementTextTrim( "artifactId" ) );
- p.setName( plugin.elementTextTrim( "name" ) );
- metadata.addPlugin( p );
- }
-
- return metadata;
+ return MavenMetadataReader.read( metadataFile );
}
catch ( XMLException e )
{
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java
index 38146b6c7..2ab57b942 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/RepositoryMetadataWriter.java
@@ -19,13 +19,14 @@ package org.apache.archiva.repository.metadata;
* under the License.
*/
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.model.Plugin;
import org.apache.archiva.xml.XMLException;
import org.apache.archiva.xml.XMLWriter;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
@@ -36,10 +37,9 @@ import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import java.util.List;
-import org.apache.commons.io.FileUtils;
/**
- * RepositoryMetadataWriter
+ * RepositoryMetadataWriter
*
* @version $Id$
*/
@@ -59,15 +59,15 @@ public class RepositoryMetadataWriter
catch ( IOException e )
{
thrown = true;
- throw new RepositoryMetadataException( "Unable to write metadata file: " + outputFile.getAbsolutePath()
- + " - " + e.getMessage(), e );
+ throw new RepositoryMetadataException(
+ "Unable to write metadata file: " + outputFile.getAbsolutePath() + " - " + e.getMessage(), e );
}
finally
{
IOUtils.closeQuietly( writer );
- if (thrown)
+ if ( thrown )
{
- FileUtils.deleteQuietly(outputFile);
+ FileUtils.deleteQuietly( outputFile );
}
}
}
@@ -80,14 +80,14 @@ public class RepositoryMetadataWriter
Element root = DocumentHelper.createElement( "metadata" );
doc.setRootElement( root );
- addOptionalElementText( root, "groupId", metadata.getGroupId());
+ addOptionalElementText( root, "groupId", metadata.getGroupId() );
addOptionalElementText( root, "artifactId", metadata.getArtifactId() );
addOptionalElementText( root, "version", metadata.getVersion() );
if ( CollectionUtils.isNotEmpty( metadata.getPlugins() ) )
{
Element plugins = root.addElement( "plugins" );
- for ( Plugin plugin : (List<Plugin>)metadata.getPlugins() )
+ for ( Plugin plugin : (List<Plugin>) metadata.getPlugins() )
{
Element p = plugins.addElement( "plugin" );
p.addElement( "prefix" ).setText( plugin.getPrefix() );
@@ -96,9 +96,8 @@ public class RepositoryMetadataWriter
}
}
- if ( CollectionUtils.isNotEmpty( metadata.getAvailableVersions() )
- || StringUtils.isNotBlank( metadata.getReleasedVersion() )
- || StringUtils.isNotBlank( metadata.getLatestVersion() )
+ if ( CollectionUtils.isNotEmpty( metadata.getAvailableVersions() ) || StringUtils.isNotBlank(
+ metadata.getReleasedVersion() ) || StringUtils.isNotBlank( metadata.getLatestVersion() )
|| StringUtils.isNotBlank( metadata.getLastUpdated() ) || ( metadata.getSnapshotVersion() != null ) )
{
Element versioning = root.addElement( "versioning" );
@@ -113,7 +112,7 @@ public class RepositoryMetadataWriter
addOptionalElementText( snapshot, "buildNumber", bnum );
addOptionalElementText( snapshot, "timestamp", metadata.getSnapshotVersion().getTimestamp() );
}
-
+
if ( CollectionUtils.isNotEmpty( metadata.getAvailableVersions() ) )
{
Element versions = versioning.addElement( "versions" );
diff --git a/archiva-modules/archiva-base/pom.xml b/archiva-modules/archiva-base/pom.xml
index 46be8536c..1431d932a 100644
--- a/archiva-modules/archiva-base/pom.xml
+++ b/archiva-modules/archiva-base/pom.xml
@@ -16,8 +16,7 @@
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ --><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.archiva</groupId>
@@ -48,5 +47,6 @@
<module>archiva-repository-scanner</module>
<module>archiva-repository-admin</module>
<module>archiva-security-common</module>
+ <module>archiva-maven2-metadata</module>
</modules>
</project> \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/UploadAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/UploadAction.java
index 0e7464caa..d19aab8c5 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/UploadAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/UploadAction.java
@@ -53,7 +53,6 @@ import org.apache.archiva.repository.metadata.RepositoryMetadataReader;
import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-import org.apache.taglibs.standard.tlv.JstlBaseTLV;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.codehaus.plexus.util.IOUtil;
import org.springframework.context.annotation.Scope;
diff --git a/archiva-modules/plugins/maven2-repository/pom.xml b/archiva-modules/plugins/maven2-repository/pom.xml
index e91e0936d..05bc995d7 100644
--- a/archiva-modules/plugins/maven2-repository/pom.xml
+++ b/archiva-modules/plugins/maven2-repository/pom.xml
@@ -38,6 +38,10 @@
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-maven2-metadata</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
<artifactId>problem-reports</artifactId>
</dependency>
<dependency>
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java
index 1ba491b4e..417788f59 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java
@@ -186,8 +186,6 @@ public class DefaultDependencyTreeBuilder
return;
}
- File basedir = new File( repository.getLocation() );
-
try
{
// MRM-1411
@@ -216,7 +214,7 @@ public class DefaultDependencyTreeBuilder
}
Model model = buildProject(
- new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories, networkProxies,
+ new RepositoryModelResolver( repository, pathTranslator, wagonFactory, remoteRepositories, networkProxies,
repository ), groupId, artifactId, version );
Map managedVersions = createManagedVersionMap( model );
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
index 4e70d48f5..5d9a21016 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java
@@ -148,11 +148,11 @@ public class Maven2RepositoryStorage
{
try
{
- ManagedRepository repositoryConfiguration = managedRepositoryAdmin.getManagedRepository( repoId );
+ ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repoId );
String artifactVersion = projectVersion;
- File basedir = new File( repositoryConfiguration.getLocation() );
+ File basedir = new File( managedRepository.getLocation() );
if ( VersionUtil.isSnapshot( projectVersion ) )
{
File metadataFile =
@@ -234,8 +234,8 @@ public class Maven2RepositoryStorage
// MRM-1411
req.setModelResolver(
- new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories, networkProxies,
- repositoryConfiguration ) );
+ new RepositoryModelResolver( managedRepository, pathTranslator, wagonFactory, remoteRepositories, networkProxies,
+ managedRepository ) );
Model model;
try
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java
index 2bbde57c1..d62512f86 100644
--- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java
+++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/RepositoryModelResolver.java
@@ -23,8 +23,10 @@ import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.archiva.admin.model.beans.NetworkProxy;
import org.apache.archiva.admin.model.beans.RemoteRepository;
import org.apache.archiva.common.utils.VersionUtil;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.archiva.maven2.metadata.MavenMetadataReader;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
+import org.apache.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.archiva.model.SnapshotVersion;
import org.apache.archiva.proxy.common.WagonFactory;
import org.apache.archiva.proxy.common.WagonFactoryException;
import org.apache.archiva.xml.XMLException;
@@ -72,6 +74,8 @@ public class RepositoryModelResolver
// key/value: remote repo ID/network proxy
Map<String, NetworkProxy> networkProxyMap;
+ private ManagedRepository managedRepository;
+
public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator )
{
this.basedir = basedir;
@@ -79,11 +83,11 @@ public class RepositoryModelResolver
this.pathTranslator = pathTranslator;
}
- public RepositoryModelResolver( File basedir, RepositoryPathTranslator pathTranslator, WagonFactory wagonFactory,
- List<RemoteRepository> remoteRepositories,
+ public RepositoryModelResolver( ManagedRepository managedRepository, RepositoryPathTranslator pathTranslator,
+ WagonFactory wagonFactory, List<RemoteRepository> remoteRepositories,
Map<String, NetworkProxy> networkProxiesMap, ManagedRepository targetRepository )
{
- this( basedir, pathTranslator );
+ this( new File( managedRepository.getLocation() ), pathTranslator );
this.wagonFactory = wagonFactory;
@@ -104,6 +108,41 @@ public class RepositoryModelResolver
if ( !model.exists() )
{
+
+ // is a SNAPSHOT ?
+ if ( StringUtils.contains( version, "SNAPSHOT" ) )
+ {
+ // reading metadata if there
+ File mavenMetadata = new File( model.getParent(), METADATA_FILENAME );
+ if ( mavenMetadata.exists() )
+ {
+ try
+ {
+ ArchivaRepositoryMetadata archivaRepositoryMetadata = MavenMetadataReader.read( mavenMetadata );
+ SnapshotVersion snapshotVersion = archivaRepositoryMetadata.getSnapshotVersion();
+ if ( snapshotVersion != null )
+ {
+ String lastVersion = snapshotVersion.getTimestamp();
+ int buildNumber = snapshotVersion.getBuildNumber();
+ String snapshotPath =
+ StringUtils.replaceChars( groupId, '.', '/' ) + '/' + artifactId + '/' + version + '/'
+ + artifactId + '-' + StringUtils.remove( version, "-SNAPSHOT" ) + '-' + lastVersion
+ + '-' + buildNumber + ".pom";
+ model = new File( basedir, snapshotPath );
+ //model = pathTranslator.toFile( basedir, groupId, artifactId, lastVersion, filename );
+ if ( model.exists() )
+ {
+ return new FileModelSource( model );
+ }
+ }
+ }
+ catch ( XMLException e )
+ {
+ log.warn( "fail to read {}, {}", mavenMetadata.getAbsolutePath(), e.getCause() );
+ }
+ }
+ }
+
for ( RemoteRepository remoteRepository : remoteRepositories )
{
try
diff --git a/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java b/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java
index 77931fe89..779626ef4 100644
--- a/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java
+++ b/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/Maven2RepositoryMerger.java
@@ -35,7 +35,6 @@ import org.apache.archiva.repository.metadata.RepositoryMetadataException;
import org.apache.archiva.repository.metadata.RepositoryMetadataReader;
import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
diff --git a/pom.xml b/pom.xml
index efaa2c7e7..d62ed8784 100644
--- a/pom.xml
+++ b/pom.xml
@@ -153,6 +153,11 @@
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-maven2-metadata</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-admin-api</artifactId>
<version>${project.version}</version>
</dependency>