From 80a96f560c65a8fe3b8584842f54f6fd9dc6d8c1 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 8 Apr 2008 04:34:36 +0000 Subject: [PATCH] guard against incorrect generation git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@645761 13f79535-47bb-0310-9956-ffa450edef68 --- .../DependencyTreeGeneratorConsumer.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java index f748cb36d..6102c333d 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-dependency-tree-consumer/src/main/java/org/apache/archiva/consumers/dependencytree/DependencyTreeGeneratorConsumer.java @@ -103,6 +103,8 @@ public class DependencyTreeGeneratorConsumer private Field processedProjectCacheField; + private List includes = Collections.singletonList( "**/*.pom" ); + public String getDescription() { return "Generate dependency tree metadata for tracking changes across algorithms"; @@ -163,7 +165,7 @@ public class DependencyTreeGeneratorConsumer public List getIncludes() { - return Collections.singletonList( "**/*.pom" ); + return includes; } public void processFile( String path ) @@ -220,7 +222,13 @@ public class DependencyTreeGeneratorConsumer artifactFactory.createProjectArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion() ); - File generatedFile = new File( generatedRepositoryLocation, layout.pathOf( artifact ) + ".xml" ); + String p = layout.pathOf( artifact ); + if ( !p.equals( path ) ) + { + throw new ConsumerException( "Bad path: " + p + "; should be: " + path ); + } + + File generatedFile = new File( generatedRepositoryLocation, p + ".xml" ); generatedFile.getParentFile().mkdirs(); writer = new FileWriter( generatedFile ); OutputFormat format = OutputFormat.createPrettyPrint(); @@ -315,4 +323,9 @@ public class DependencyTreeGeneratorConsumer return true; } } + + public void setIncludes( List includes ) + { + this.includes = includes; + } }