<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<!-- Plexus Security Dependencies -->
<dependency>
<groupId>org.codehaus.plexus.security</groupId>
<artifactId>plexus-security-authorization-rbac-authorizer</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-jdo2</artifactId>
<version>1.0-alpha-7-SNAPSHOT</version>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.2</version>
- </dependency>
- <dependency>
+ </dependency>
+ <dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.1.2.1</version>
import org.apache.maven.archiva.indexer.record.StandardArtifactIndexRecord;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
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.versioning.DefaultArtifactVersion;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.apache.maven.report.projectinfo.dependencies.Dependencies;
+import org.apache.maven.report.projectinfo.dependencies.ReportResolutionListener;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
*/
private RepositoryArtifactIndexFactory factory;
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactMetadataSource artifactMetadataSource;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArtifactCollector collector;
+
private String groupId;
private String artifactId;
private Collection dependencies;
+ private List dependencyTree;
+
public String artifact()
throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException
{
return SUCCESS;
}
+ public String dependencyTree()
+ throws ConfigurationStoreException, ProjectBuildingException, InvalidDependencyVersionException,
+ ArtifactResolutionException
+ {
+ if ( !checkParameters() )
+ {
+ return ERROR;
+ }
+
+ Configuration configuration = configurationStore.getConfigurationFromStore();
+ List repositories = repositoryFactory.createRepositories( configuration );
+
+ Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version );
+ // TODO: maybe we can decouple the assembly parts of the project builder from the repository handling to get rid of the temp repo
+ ArtifactRepository localRepository = repositoryFactory.createLocalRepository( configuration );
+ MavenProject project = projectBuilder.buildFromRepository( artifact, repositories, localRepository );
+
+ model = project.getModel();
+
+ getLogger().debug( " processing : " + groupId + ":" + artifactId + ":" + version );
+
+ Dependencies dependencies =
+ collectDependencies( project, artifact, localRepository, repositories );
+
+ dependencyTree = new LinkedList();
+ populateFlatTreeList( dependencies.getResolvedRoot(), dependencyTree );
+
+ return SUCCESS;
+ }
+
+ private void populateFlatTreeList( ReportResolutionListener.Node currentNode, List dependencyList )
+ {
+ ReportResolutionListener.Node childNode;
+
+ for ( Iterator iterator = currentNode.getChildren().iterator(); iterator.hasNext(); )
+ {
+ childNode = (ReportResolutionListener.Node) iterator.next();
+ dependencyList.add( childNode );
+ populateFlatTreeList( childNode, dependencyList );
+ }
+ }
+
+ private Dependencies collectDependencies( MavenProject project, Artifact artifact,
+ ArtifactRepository localRepository, List repositories )
+ throws ArtifactResolutionException, ProjectBuildingException, InvalidDependencyVersionException,
+ ConfigurationStoreException
+ {
+ Map managedDependencyMap = Dependencies.getManagedVersionMap( project, artifactFactory );
+
+ ReportResolutionListener listener = new ReportResolutionListener();
+
+ project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
+
+ collector.collect( project.getDependencyArtifacts(), artifact, managedDependencyMap, localRepository,
+ repositories, artifactMetadataSource, null, Collections.singletonList( listener ) );
+
+ return new Dependencies( project, listener, null );
+ }
+
private static String createId( String groupId, String artifactId, String version )
{
return groupId + ":" + artifactId + ":" + version;
return dependencies;
}
+ public List getDependencyTree()
+ {
+ return dependencyTree;
+ }
+
public String getGroupId()
{
return groupId;
return classifier;
}
- private static class Ver
- {
- private int buildNumber;
-
- private int major;
-
- private int minor;
-
- private int incremental;
-
- private String qualifier;
-
-
- }
-
public void addVersion( String version )
{
// We use DefaultArtifactVersion to get the correct sorting order later, however it does not have
--- /dev/null
+<%--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ --%>
+
+<%@ taglib prefix="ww" uri="/webwork" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
+
+
+<ul>
+ <c:set var="prevDepth" value="1"/>
+ <ww:set name="dependencyTree" value="dependencyTree"/>
+ <c:forEach items="${dependencyTree}" var="node">
+ <c:choose>
+ <c:when test="${node.depth < prevDepth}">
+ </ul>
+ <li>
+ </c:when>
+ <c:when test="${node.depth > prevDepth}">
+ <ul>
+ <li>
+ </c:when>
+ <c:otherwise>
+ <li>
+ </c:otherwise>
+ </c:choose>
+ <c:set var="url">
+ <ww:url action="showArtifact" namespace="/">
+ <ww:param name="groupId" value="%{'${node.artifact.groupId}'}"/>
+ <ww:param name="artifactId" value="%{'${node.artifact.artifactId}'}"/>
+ <ww:param name="version" value="%{'${node.artifact.version}'}"/>
+ </ww:url>
+ </c:set>
+ <a href="${url}">
+ <%-- TODO! show this like the other dependencies: g / g1 / g2 / artifactId / version --%>
+ <c:out value="${node.artifact.dependencyConflictId}"/>
+ </a>
+ </li>
+ <c:set var="prevDepth" value="${node.depth}" />
+ </c:forEach>
+</ul>
+
\ No newline at end of file