PR: MNG-453

Submitted by: Andreas Hoheneder
Reviewed by:  Brett Porter
Add support for generic artifact types, mapping the type to an extension


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@188806 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-06-07 16:06:14 +00:00
parent 8772f0f23e
commit 7523cdb03a
2 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,47 @@
package org.apache.maven.artifact.handler;
/*
* Copyright 2001-2005 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.
*/
/**
* @author Andreas Hoheneder (ahoh/at/inode.at)
* @version $Id$
*/
public class GenericHandler
extends AbstractArtifactHandler
{
private String type;
public GenericHandler( String atype )
{
type = atype;
}
public String extension()
{
return type;
}
public String directory()
{
return type + "s";
}
public String packageGoal()
{
return null;
}
}

View File

@ -17,6 +17,7 @@
*/
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.GenericHandler;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import java.util.Map;
@ -39,6 +40,13 @@ public ArtifactHandler getArtifactHandler( String type )
{
ArtifactHandler handler = (ArtifactHandler) artifactHandlers.get( type );
if ( handler == null )
{
handler = new GenericHandler( type );
}
// this should only happen if GenericHandler decides that the given type is unworthy to be handled
// TODO: can probably remove this
if ( handler == null )
{
throw new ArtifactHandlerNotFoundException( "Artifact handler for type '" + type + "' cannot be found." );