* limitations under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
import org.apache.maven.archiva.indexer.lucene.LuceneQuery;
import org.apache.maven.archiva.indexer.record.StandardArtifactIndexRecord;
+import org.apache.maven.archiva.proxy.ProxyException;
import org.apache.maven.archiva.web.util.VersionMerger;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactCollector;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.shared.dependency.tree.DependencyTree;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.commons.lang.StringUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
* @plexus.requirement
*/
private ArtifactCollector collector;
-
+
/**
* @plexus.requirement
*/
private DependencyTreeBuilder dependencyTreeBuilder;
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactResolver artifactResolver;
+
private String groupId;
private String artifactId;
private Model model;
private Collection dependencies;
-
+
private List dependencyTree;
+ private String repositoryId;
+
+ private String artifactPath;
+
public String artifact()
- throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException
+ throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException,
+ ResourceDoesNotExistException, ProxyException, ArtifactResolutionException
{
if ( !checkParameters() )
{
model = project.getModel();
+ Configuration configuration = configurationStore.getConfigurationFromStore();
+ List repositories = repositoryFactory.createRepositories( configuration );
+
+ Artifact artifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
+ project.getVersion(), project.getPackaging() );
+
+ for ( Iterator i = repositories.iterator(); i.hasNext(); )
+ {
+ ArtifactRepository repository = (ArtifactRepository) i.next();
+
+ String path = repository.pathOf( artifact );
+ File f = new File( repository.getBasedir(), path );
+ if ( f.exists() )
+ {
+ repositoryId = repository.getId();
+
+ artifactPath = path;
+ }
+ }
+
return SUCCESS;
}
model = project.getModel();
// TODO: should this be the whole set of artifacts, and be more like the maven dependencies report?
- this.dependencies = VersionMerger.wrap(project.getModel().getDependencies());
+ this.dependencies = VersionMerger.wrap( project.getModel().getDependencies() );
return SUCCESS;
}
String id = createId( groupId, artifactId, version );
List records = index.search( new LuceneQuery( new TermQuery( new Term( "dependencies", id ) ) ) );
- dependencies = VersionMerger.merge(records);
+ dependencies = VersionMerger.merge( records );
return SUCCESS;
}
getLogger().debug( " processing : " + groupId + ":" + artifactId + ":" + version );
- DependencyTree dependencies =
- collectDependencies( project, artifact, localRepository, repositories );
-
+ DependencyTree dependencies = collectDependencies( project, artifact, localRepository, repositories );
+
this.dependencyTree = new ArrayList();
-
+
populateFlatTreeList( dependencies.getRootNode(), dependencyTree );
return SUCCESS;
}
private DependencyTree collectDependencies( MavenProject project, Artifact artifact,
- ArtifactRepository localRepository, List repositories )
+ ArtifactRepository localRepository, List repositories )
throws ArtifactResolutionException, ProjectBuildingException, InvalidDependencyVersionException,
ConfigurationStoreException
{
{
return dependencyTree;
}
-
+
public String getVersion()
{
return version;
this.version = version;
}
+ public String getArtifactPath()
+ {
+ return artifactPath;
+ }
+
public static class DependencyWrapper
{
private final String groupId;
}
}
+ public String getRepositoryId()
+ {
+ return repositoryId;
+ }
}