1 package org.apache.maven.archiva.plugins.dev;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.plugins.dev.testgen.DependencyGraphTestCreator;
23 import org.apache.maven.archiva.plugins.dev.testgen.MemoryRepositoryCreator;
24 import org.apache.maven.archiva.plugins.dev.utils.VariableNames;
25 import org.apache.maven.artifact.factory.ArtifactFactory;
26 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
27 import org.apache.maven.artifact.repository.ArtifactRepository;
28 import org.apache.maven.artifact.resolver.ArtifactCollector;
29 import org.apache.maven.plugin.AbstractMojo;
30 import org.apache.maven.plugin.MojoExecutionException;
31 import org.apache.maven.plugin.MojoFailureException;
32 import org.apache.maven.project.MavenProject;
33 import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
38 * CreateArchivaDependencyResolutionTestCaseMojo
40 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
43 * @goal generate-dependency-tests
45 public class CreateArchivaDependencyResolutionTestCaseMojo
49 * The project of the current build.
51 * @parameter default-value="${project}"
55 private MavenProject project;
58 * The artifact respository to use.
60 * @parameter expression="${localRepository}"
64 private ArtifactRepository localRepository;
67 * The destination directory to generate the test files.
69 * @parameter expression="${archivadev.outputdir}" default-value="${project.build.directory}"
75 * The artifact factory to use.
79 private ArtifactFactory artifactFactory;
84 private DependencyTreeBuilder dependencyTreeBuilder;
89 protected ArtifactMetadataSource artifactMetadataSource;
94 private ArtifactCollector collector;
97 throws MojoExecutionException, MojoFailureException
99 String classPrefix = VariableNames.toClassName( project.getArtifactId() );
101 getLog().info( "Generating into " + destDir );
103 createMemoryRepository( classPrefix );
104 createDependencyGraphTest( classPrefix );
107 private void createDependencyGraphTest( String classPrefix ) throws MojoExecutionException
109 DependencyGraphTestCreator creator = new DependencyGraphTestCreator();
110 creator.setLog( getLog() );
111 creator.setOutputDir( destDir );
112 creator.setProject( project );
113 creator.setArtifactFactory( artifactFactory );
114 creator.setLocalRepository( localRepository );
115 creator.setDependencyTreeBuilder( dependencyTreeBuilder );
116 creator.setArtifactMetadataSource( artifactMetadataSource );
117 creator.setCollector( collector );
119 creator.create( classPrefix );
122 private void createMemoryRepository( String classPrefix ) throws MojoExecutionException
124 MemoryRepositoryCreator creator = new MemoryRepositoryCreator();
125 creator.setLog( getLog() );
126 creator.setOutputDir( destDir );
127 creator.setProject( project );
128 creator.setArtifactFactory( artifactFactory );
129 creator.setLocalRepository( localRepository );
131 creator.create( classPrefix );