From: Brett Porter Date: Fri, 28 Nov 2008 16:29:00 +0000 (+0000) Subject: [MRM-1025] consolidate dependency graphing classes into one module X-Git-Tag: archiva-1.2~184 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6f2d5bad731ccbe5c8d01e67d58c016a08970014;p=archiva.git [MRM-1025] consolidate dependency graphing classes into one module git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@721529 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-dependency-graph/pom.xml b/archiva-modules/archiva-base/archiva-dependency-graph/pom.xml index 9e629bd28..a03cebe34 100644 --- a/archiva-modules/archiva-base/archiva-dependency-graph/pom.xml +++ b/archiva-modules/archiva-base/archiva-dependency-graph/pom.xml @@ -41,6 +41,10 @@ org.apache.archiva archiva-model + + org.apache.archiva + archiva-repository-layer + diff --git a/archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/ProjectModelBasedGraphBuilder.java b/archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/ProjectModelBasedGraphBuilder.java new file mode 100644 index 000000000..c08b6c4f1 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-dependency-graph/src/main/java/org/apache/maven/archiva/dependency/graph/ProjectModelBasedGraphBuilder.java @@ -0,0 +1,111 @@ +package org.apache.maven.archiva.dependency.graph; + +/* + * 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.maven.archiva.model.ArchivaProjectModel; +import org.apache.maven.archiva.model.ArtifactReference; +import org.apache.maven.archiva.model.VersionedReference; +import org.apache.maven.archiva.repository.project.ProjectModelException; +import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory; +import org.apache.maven.archiva.repository.project.filters.EffectiveProjectModelFilter; + +/** + * ProjectModelBasedGraphBuilder + * + * @version $Id$ + * + * @plexus.component + * role="org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder" + * role-hint="project-model" + */ +public class ProjectModelBasedGraphBuilder + implements DependencyGraphBuilder +{ + /** + * @plexus.requirement + */ + private ProjectModelResolverFactory resolverFactory; + + /** + * @plexus.requirement + * role="org.apache.maven.archiva.repository.project.ProjectModelFilter" + * role-hint="effective" + */ + private EffectiveProjectModelFilter effectiveFilter = new EffectiveProjectModelFilter(); + + public DependencyGraph createGraph( VersionedReference versionedProjectReference ) + { + String groupId = versionedProjectReference.getGroupId(); + String artifactId = versionedProjectReference.getArtifactId(); + String version = versionedProjectReference.getVersion(); + + DependencyGraph graph = new DependencyGraph( groupId, artifactId, version ); + return graph; + } + + public void resolveNode( DependencyGraph graph, DependencyGraphNode fromNode, + VersionedReference versionedProjectReference ) + { + ArchivaProjectModel model = resolveModel( fromNode.getArtifact() ); + + DependencyGraphUtils.addNodeFromModel( model, graph, fromNode ); + } + + private ArchivaProjectModel resolveModel( ArtifactReference reference ) + { + VersionedReference projectRef = new VersionedReference(); + + projectRef.setGroupId( reference.getGroupId() ); + projectRef.setArtifactId( reference.getArtifactId() ); + projectRef.setVersion( reference.getVersion() ); + + ArchivaProjectModel model = resolverFactory.getCurrentResolverStack().findProject( projectRef ); + + if ( model == null ) + { + return createDefaultModel( reference ); + } + + try + { + ArchivaProjectModel processedModel = effectiveFilter.filter( model ); + + return processedModel; + } + catch ( ProjectModelException e ) + { + e.printStackTrace( System.err ); + return createDefaultModel( reference ); + } + } + + private ArchivaProjectModel createDefaultModel( ArtifactReference reference ) + { + ArchivaProjectModel model = new ArchivaProjectModel(); + + // Create default (dummy) model + model = new ArchivaProjectModel(); + model.setGroupId( reference.getGroupId() ); + model.setArtifactId( reference.getArtifactId() ); + model.setVersion( reference.getVersion() ); + model.setPackaging( reference.getType() ); + return model; + } +} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml index 15411bd4c..de93e0429 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml @@ -40,10 +40,6 @@ org.apache.archiva archiva-consumer-api - - org.apache.archiva - archiva-dependency-graph - org.apache.archiva archiva-checksum diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/dependencies/ProjectModelBasedGraphBuilder.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/dependencies/ProjectModelBasedGraphBuilder.java deleted file mode 100644 index cc47e1aa6..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/dependencies/ProjectModelBasedGraphBuilder.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.apache.maven.archiva.repository.project.dependencies; - -/* - * 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.maven.archiva.dependency.graph.DependencyGraph; -import org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder; -import org.apache.maven.archiva.dependency.graph.DependencyGraphNode; -import org.apache.maven.archiva.dependency.graph.DependencyGraphUtils; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory; -import org.apache.maven.archiva.repository.project.filters.EffectiveProjectModelFilter; - -/** - * ProjectModelBasedGraphBuilder - * - * @version $Id$ - * - * @plexus.component - * role="org.apache.maven.archiva.dependency.graph.DependencyGraphBuilder" - * role-hint="project-model" - */ -public class ProjectModelBasedGraphBuilder - implements DependencyGraphBuilder -{ - /** - * @plexus.requirement - */ - private ProjectModelResolverFactory resolverFactory; - - /** - * @plexus.requirement - * role="org.apache.maven.archiva.repository.project.ProjectModelFilter" - * role-hint="effective" - */ - private EffectiveProjectModelFilter effectiveFilter = new EffectiveProjectModelFilter(); - - public DependencyGraph createGraph( VersionedReference versionedProjectReference ) - { - String groupId = versionedProjectReference.getGroupId(); - String artifactId = versionedProjectReference.getArtifactId(); - String version = versionedProjectReference.getVersion(); - - DependencyGraph graph = new DependencyGraph( groupId, artifactId, version ); - return graph; - } - - public void resolveNode( DependencyGraph graph, DependencyGraphNode fromNode, - VersionedReference versionedProjectReference ) - { - ArchivaProjectModel model = resolveModel( fromNode.getArtifact() ); - - DependencyGraphUtils.addNodeFromModel( model, graph, fromNode ); - } - - private ArchivaProjectModel resolveModel( ArtifactReference reference ) - { - VersionedReference projectRef = new VersionedReference(); - - projectRef.setGroupId( reference.getGroupId() ); - projectRef.setArtifactId( reference.getArtifactId() ); - projectRef.setVersion( reference.getVersion() ); - - ArchivaProjectModel model = resolverFactory.getCurrentResolverStack().findProject( projectRef ); - - if ( model == null ) - { - return createDefaultModel( reference ); - } - - try - { - ArchivaProjectModel processedModel = effectiveFilter.filter( model ); - - return processedModel; - } - catch ( ProjectModelException e ) - { - e.printStackTrace( System.err ); - return createDefaultModel( reference ); - } - } - - private ArchivaProjectModel createDefaultModel( ArtifactReference reference ) - { - ArchivaProjectModel model = new ArchivaProjectModel(); - - // Create default (dummy) model - model = new ArchivaProjectModel(); - model.setGroupId( reference.getGroupId() ); - model.setArtifactId( reference.getArtifactId() ); - model.setVersion( reference.getVersion() ); - model.setPackaging( reference.getType() ); - return model; - } -}