1 package org.apache.maven.archiva.converter.legacy;
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.configuration.ManagedRepositoryConfiguration;
23 import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
24 import org.apache.maven.archiva.consumers.ConsumerException;
25 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
26 import org.apache.maven.archiva.converter.artifact.ArtifactConversionException;
27 import org.apache.maven.archiva.converter.artifact.ArtifactConverter;
28 import org.apache.maven.archiva.model.ArtifactReference;
29 import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
30 import org.apache.maven.archiva.repository.layout.LayoutException;
31 import org.apache.maven.artifact.Artifact;
32 import org.apache.maven.artifact.factory.ArtifactFactory;
33 import org.apache.maven.artifact.repository.ArtifactRepository;
35 import java.util.ArrayList;
36 import java.util.List;
39 * LegacyConverterArtifactConsumer - convert artifacts as they are found
40 * into the destination repository.
42 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
45 * @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer"
46 * role-hint="artifact-legacy-to-default-converter"
47 * instantiation-strategy="per-lookup"
49 public class LegacyConverterArtifactConsumer
50 extends AbstractMonitoredConsumer
51 implements KnownRepositoryContentConsumer
54 * @plexus.requirement role-hint="legacy-to-default"
56 private ArtifactConverter artifactConverter;
61 private ArtifactFactory artifactFactory;
64 * @plexus.requirement role-hint="legacy"
66 private BidirectionalRepositoryLayout bidirectionalLayout;
68 private ArtifactRepository destinationRepository;
70 private List includes;
72 private List excludes;
74 public LegacyConverterArtifactConsumer()
76 includes = new ArrayList();
77 includes.add( "**/*.jar" );
78 includes.add( "**/*.ear" );
79 includes.add( "**/*.war" );
82 public void beginScan( ManagedRepositoryConfiguration repository )
83 throws ConsumerException
88 public void completeScan()
93 public List getExcludes()
98 public List getIncludes()
103 public void processFile( String path )
104 throws ConsumerException
108 ArtifactReference reference = bidirectionalLayout.toArtifactReference( path );
109 Artifact artifact = artifactFactory.createArtifact( reference.getGroupId(), reference.getArtifactId(),
110 reference.getVersion(), reference.getClassifier(),
111 reference.getType() );
112 artifactConverter.convert( artifact, destinationRepository );
114 catch ( LayoutException e )
116 getLogger().warn( "Unable to convert artifact: " + path + " : " + e.getMessage(), e );
118 catch ( ArtifactConversionException e )
120 getLogger().warn( "Unable to convert artifact: " + path + " : " + e.getMessage(), e );
124 public String getDescription()
126 return "Legacy Artifact to Default Artifact Converter";
129 public String getId()
131 return "artifact-legacy-to-default-converter";
134 public boolean isPermanent()
139 public void setExcludes( List excludes )
141 this.excludes = excludes;
144 public void setIncludes( List includes )
146 this.includes = includes;
149 public ArtifactRepository getDestinationRepository()
151 return destinationRepository;
154 public void setDestinationRepository( ArtifactRepository destinationRepository )
156 this.destinationRepository = destinationRepository;