Index: build-bootstrap.xml =================================================================== RCS file: /home/cvspublic/maven/build-bootstrap.xml,v retrieving revision 1.212 diff -u -r1.212 build-bootstrap.xml --- build-bootstrap.xml 25 Nov 2003 05:36:50 -0000 1.212 +++ build-bootstrap.xml 22 Jan 2004 21:41:17 -0000 @@ -112,6 +112,9 @@ + + + @@ -132,6 +135,8 @@ + + Index: project.properties =================================================================== RCS file: /home/cvspublic/maven/project.properties,v retrieving revision 1.56 diff -u -r1.56 project.properties --- project.properties 14 Jan 2004 18:09:25 -0000 1.56 +++ project.properties 22 Jan 2004 21:41:17 -0000 @@ -2,6 +2,9 @@ # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- +maven.junit.fork=true +maven.junit.usefile=${basedir}/target/junit.log + maven.final.name = maven maven.build.dir = ${basedir}/target maven.gen.docs = ${maven.build.dir}/generated-xdocs Index: project.xml =================================================================== RCS file: /home/cvspublic/maven/project.xml,v retrieving revision 1.327 diff -u -r1.327 project.xml --- project.xml 28 Dec 2003 23:04:13 -0000 1.327 +++ project.xml 22 Jan 2004 21:41:17 -0000 @@ -563,8 +563,22 @@ **/RepositoryTest.java **/JAXPTest.java + + + src/java + + META-INF/artifactTypes/* + + + + + src/java + + META-INF/artifactTypes/* + + src/conf Index: src/java/org/apache/maven/project/ArtifactType.java =================================================================== RCS file: /home/cvspublic/maven/src/java/org/apache/maven/project/ArtifactType.java,v retrieving revision 1.5 diff -u -r1.5 ArtifactType.java --- src/java/org/apache/maven/project/ArtifactType.java 21 Sep 2003 21:22:52 -0000 1.5 +++ src/java/org/apache/maven/project/ArtifactType.java 22 Jan 2004 21:41:19 -0000 @@ -56,96 +56,20 @@ * ==================================================================== */ -/** - * Provides mapping between artifact types and an extension associated - * with these types. +/** Represents a means for working with a particular type of artifact. * - * @author Vincent Massol - * @version $Id: ArtifactType.java,v 1.5 2003/09/21 21:22:52 vmassol Exp $ + * @author John Casey */ -public class ArtifactType -{ - /** - * EJB artifact mapping. - */ - public static final ArtifactType EJB = new ArtifactType("ejb", "jar"); - - /** - * Plugin artifact mapping. - */ - public static final ArtifactType PLUGIN = new ArtifactType("plugin", "jar"); - - /** - * Reusable AspectJ aspect mapping. - */ - public static final ArtifactType ASPECT = new ArtifactType("aspect", "jar"); - - /** - * Artifact type. - */ - private String type; - - /** - * Artifact file extension. - */ - private String extension; - - /** - * @param type the artifact type - * @param extension the artifact extension - */ - private ArtifactType(String type, String extension) - { - this.type = type; - this.extension = extension; - } - - /** - * @return the artifact type - */ - public String getType() - { - return this.type; - } - - /** - * @return the artifact extension - */ - public String getExtension() - { - return this.extension; - } - - /** - * Factory to return the correct {@link ArtifactType} object. - * - * @param type the artifact type - * @return the artifact mapping - */ - public static ArtifactType findType(String type) - { - ArtifactType result; - - if (type == null) - { - result = null; - } - else if (type.equalsIgnoreCase("ejb")) - { - result = EJB; - } - else if (type.equalsIgnoreCase("plugin")) - { - result = PLUGIN; - } - else if (type.equalsIgnoreCase("aspect")) - { - result = ASPECT; - } - else - { - result = new ArtifactType(type, type); - } - return result; - } -} +public interface ArtifactType { + + /** Return the type name of the artifact type implementation. + * + * @return the artifact type + */ + public abstract String getType(); + + /** Return the artifact's file extension for this type of artifact. + * @return the artifact extension + */ + public abstract String getExtension(); +} \ No newline at end of file Index: src/java/org/apache/maven/project/ArtifactTypeFactory.java =================================================================== RCS file: src/java/org/apache/maven/project/ArtifactTypeFactory.java diff -N src/java/org/apache/maven/project/ArtifactTypeFactory.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/maven/project/ArtifactTypeFactory.java 22 Jan 2004 21:41:19 -0000 @@ -0,0 +1,163 @@ +package org.apache.maven.project; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.apache.maven.MavenException; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +/** + * Provides mapping between artifact types and an extension associated + * with these types. + * + * @author Vincent Massol + * @version $Id: ArtifactTypeFactory.java,v 1.5 2003/09/21 21:22:52 vmassol Exp $ + */ +public class ArtifactTypeFactory +{ + /** + * Factory to return the correct {@link ArtifactTypeFactory} object. + * + * @param type the artifact type + * @return the artifact mapping + */ + public static ArtifactType findType(String type) + { + String resource = "META-INF/artifactTypes/" + type; + ClassLoader cloader = Thread.currentThread().getContextClassLoader(); + if(cloader == null){cloader = ArtifactTypeFactory.class.getClassLoader();} + + InputStream inStream = cloader.getResourceAsStream(resource); + + if(inStream == null){ + return new WildcardArtifactType(type); + } + + BufferedReader in = new BufferedReader(new InputStreamReader(inStream)); + String implName = null; + try { + implName = in.readLine(); + Class implClass = cloader.loadClass(implName); + Class[] paramsTypes = {}; + Object[] params = {}; + + Method singletonMethod = implClass.getMethod("getInstance", paramsTypes); + return (ArtifactType)singletonMethod.invoke(null, params); + } + catch (IOException e) { + return new WildcardArtifactType(type); + } + catch (ClassNotFoundException e) { + return new WildcardArtifactType(type); + } + catch (SecurityException e) { + return new WildcardArtifactType(type); + } + catch (NoSuchMethodException e) { + return new WildcardArtifactType(type); + } + catch (IllegalArgumentException e) { + return new WildcardArtifactType(type); + } + catch (IllegalAccessException e) { + return new WildcardArtifactType(type); + } + catch (InvocationTargetException e) { + return new WildcardArtifactType(type); + } + finally{ + if(in != null){ + try{in.close();} + catch(IOException e){/* we're not interested... */} + } + } + } + + private static final class WildcardArtifactType implements ArtifactType{ + + private String typename; + + WildcardArtifactType(String typename){ + this.typename = typename; + } + + /** Return what was given to us... + * + * @return the typename given to this instance + * + * @see org.apache.maven.project.ArtifactType#getType() + */ + public String getType() { + return typename; + } + + /** Return the jar file extension...when in doubt... + * + * @return "jar" + * + * @see org.apache.maven.project.ArtifactType#getExtension() + */ + public String getExtension() { + return "jar"; + } + } +} Index: src/java/org/apache/maven/project/AspectArtifactType.java =================================================================== RCS file: src/java/org/apache/maven/project/AspectArtifactType.java diff -N src/java/org/apache/maven/project/AspectArtifactType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/maven/project/AspectArtifactType.java 22 Jan 2004 21:41:19 -0000 @@ -0,0 +1,104 @@ +/* + * Created on Jan 22, 2004 + * + */ +package org.apache.maven.project; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +/** Implementation of ArtifactType which is geared toward aspect artifacts. + * + * @author John Casey + * + */ +public final class AspectArtifactType implements ArtifactType { + + private static final AspectArtifactType INSTANCE = new AspectArtifactType(); + + /** Construct singleton instance. + */ + private AspectArtifactType() { + } + + /** Get the singleton instance. + * @return the singleton + */ + public static ArtifactType getInstance(){ + return INSTANCE; + } + + /** Return the type name for this artifact type. + * + * @return the type name + * + * @see org.apache.maven.project.ArtifactType#getType() + */ + public String getType() { + return "aspect"; + } + + /** Return the artifact file extension for this artifact type. + * + * @return the file extension + * + * @see org.apache.maven.project.ArtifactType#getExtension() + */ + public String getExtension() { + return "jar"; + } + +} Index: src/java/org/apache/maven/project/Dependency.java =================================================================== RCS file: /home/cvspublic/maven/src/java/org/apache/maven/project/Dependency.java,v retrieving revision 1.42 diff -u -r1.42 Dependency.java --- src/java/org/apache/maven/project/Dependency.java 17 Oct 2003 05:58:03 -0000 1.42 +++ src/java/org/apache/maven/project/Dependency.java 22 Jan 2004 21:41:19 -0000 @@ -56,6 +56,7 @@ * ==================================================================== */ +import org.apache.maven.MavenException; import org.apache.maven.util.StringTool; /** @@ -339,7 +340,7 @@ */ public void setType( String type ) { - this.type = ArtifactType.findType(StringTool.trim(type)); + this.type = ArtifactTypeFactory.findType(StringTool.trim(type)); } /** Index: src/java/org/apache/maven/project/EarArtifactType.java =================================================================== RCS file: src/java/org/apache/maven/project/EarArtifactType.java diff -N src/java/org/apache/maven/project/EarArtifactType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/maven/project/EarArtifactType.java 22 Jan 2004 21:41:19 -0000 @@ -0,0 +1,104 @@ +/* + * Created on Jan 22, 2004 + * + */ +package org.apache.maven.project; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +/** Implementation of ArtifactType which is geared toward ear files. + * + * @author John Casey + * + */ +public final class EarArtifactType implements ArtifactType { + + private static final EarArtifactType INSTANCE = new EarArtifactType(); + + /** Construct singleton instance. + */ + private EarArtifactType() { + } + + /** Get the singleton instance. + * @return the singleton + */ + public static ArtifactType getInstance(){ + return INSTANCE; + } + + /** Return the type name for this artifact type. + * + * @return the type name + * + * @see org.apache.maven.project.ArtifactType#getType() + */ + public String getType() { + return "ear"; + } + + /** Return the artifact file extension for this artifact type. + * + * @return the file extension + * + * @see org.apache.maven.project.ArtifactType#getExtension() + */ + public String getExtension() { + return "ear"; + } + +} Index: src/java/org/apache/maven/project/EjbArtifactType.java =================================================================== RCS file: src/java/org/apache/maven/project/EjbArtifactType.java diff -N src/java/org/apache/maven/project/EjbArtifactType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/maven/project/EjbArtifactType.java 22 Jan 2004 21:41:19 -0000 @@ -0,0 +1,104 @@ +/* + * Created on Jan 22, 2004 + * + */ +package org.apache.maven.project; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +/** Implementation of ArtifactType which is geared toward EJB-jar files (not EJB-client jars!). + * + * @author John Casey + * + */ +public final class EjbArtifactType implements ArtifactType { + + private static final EjbArtifactType INSTANCE = new EjbArtifactType(); + + /** Construct singleton instance. + */ + private EjbArtifactType() { + } + + /** Get the singleton instance. + * @return the singleton + */ + public static ArtifactType getInstance(){ + return INSTANCE; + } + + /** Return the type name for this artifact type. + * + * @return the type name + * + * @see org.apache.maven.project.ArtifactType#getType() + */ + public String getType() { + return "ejb"; + } + + /** Return the artifact file extension for this artifact type. + * + * @return the file extension + * + * @see org.apache.maven.project.ArtifactType#getExtension() + */ + public String getExtension() { + return "jar"; + } + +} Index: src/java/org/apache/maven/project/JarArtifactType.java =================================================================== RCS file: src/java/org/apache/maven/project/JarArtifactType.java diff -N src/java/org/apache/maven/project/JarArtifactType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/maven/project/JarArtifactType.java 22 Jan 2004 21:41:20 -0000 @@ -0,0 +1,104 @@ +/* + * Created on Jan 22, 2004 + * + */ +package org.apache.maven.project; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +/** Implementation of ArtifactType which is geared toward POJO jar files. + * + * @author John Casey + * + */ +public final class JarArtifactType implements ArtifactType { + + private static final JarArtifactType INSTANCE = new JarArtifactType(); + + /** Construct singleton instance. + */ + private JarArtifactType() { + } + + /** Get the singleton instance. + * @return the singleton + */ + public static ArtifactType getInstance(){ + return INSTANCE; + } + + /** Return the type name for this artifact type. + * + * @return the type name + * + * @see org.apache.maven.project.ArtifactType#getType() + */ + public String getType() { + return "jar"; + } + + /** Return the artifact file extension for this artifact type. + * + * @return the file extension + * + * @see org.apache.maven.project.ArtifactType#getExtension() + */ + public String getExtension() { + return "jar"; + } + +} Index: src/java/org/apache/maven/project/PluginArtifactType.java =================================================================== RCS file: src/java/org/apache/maven/project/PluginArtifactType.java diff -N src/java/org/apache/maven/project/PluginArtifactType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/maven/project/PluginArtifactType.java 22 Jan 2004 21:41:20 -0000 @@ -0,0 +1,104 @@ +/* + * Created on Jan 22, 2004 + * + */ +package org.apache.maven.project; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +/** Implementation of ArtifactType which is geared toward plugin artifacts. + * + * @author John Casey + * + */ +public final class PluginArtifactType implements ArtifactType { + + private static final PluginArtifactType INSTANCE = new PluginArtifactType(); + + /** Construct singleton instance. + */ + private PluginArtifactType() { + } + + /** Get the singleton instance. + * @return the singleton + */ + public static ArtifactType getInstance(){ + return INSTANCE; + } + + /** Return the type name for this artifact type. + * + * @return the type name + * + * @see org.apache.maven.project.ArtifactType#getType() + */ + public String getType() { + return "plugin"; + } + + /** Return the artifact file extension for this artifact type. + * + * @return the file extension + * + * @see org.apache.maven.project.ArtifactType#getExtension() + */ + public String getExtension() { + return "jar"; + } + +} Index: src/java/org/apache/maven/project/PomArtifactType.java =================================================================== RCS file: src/java/org/apache/maven/project/PomArtifactType.java diff -N src/java/org/apache/maven/project/PomArtifactType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/maven/project/PomArtifactType.java 22 Jan 2004 21:41:20 -0000 @@ -0,0 +1,104 @@ +/* + * Created on Jan 22, 2004 + * + */ +package org.apache.maven.project; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +/** Implementation of ArtifactType which is geared toward POM files. + * + * @author John Casey + * + */ +public final class PomArtifactType implements ArtifactType { + + private static final PomArtifactType INSTANCE = new PomArtifactType(); + + /** Construct singleton instance. + */ + private PomArtifactType() { + } + + /** Get the singleton instance. + * @return the singleton + */ + public static ArtifactType getInstance(){ + return INSTANCE; + } + + /** Return the type name for this artifact type. + * + * @return the type name + * + * @see org.apache.maven.project.ArtifactType#getType() + */ + public String getType() { + return "pom"; + } + + /** Return the artifact file extension for this artifact type. + * + * @return the file extension + * + * @see org.apache.maven.project.ArtifactType#getExtension() + */ + public String getExtension() { + return "pom"; + } + +} Index: src/java/org/apache/maven/project/WarArtifactType.java =================================================================== RCS file: src/java/org/apache/maven/project/WarArtifactType.java diff -N src/java/org/apache/maven/project/WarArtifactType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/maven/project/WarArtifactType.java 22 Jan 2004 21:41:20 -0000 @@ -0,0 +1,104 @@ +/* + * Created on Jan 22, 2004 + * + */ +package org.apache.maven.project; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +/** Implementation of ArtifactType which is geared toward war files. + * + * @author John Casey + * + */ +public final class WarArtifactType implements ArtifactType { + + private static final WarArtifactType INSTANCE = new WarArtifactType(); + + /** Construct singleton instance. + */ + private WarArtifactType() { + } + + /** Get the singleton instance. + * @return the singleton + */ + public static ArtifactType getInstance(){ + return INSTANCE; + } + + /** Return the type name for this artifact type. + * + * @return the type name + * + * @see org.apache.maven.project.ArtifactType#getType() + */ + public String getType() { + return "war"; + } + + /** Return the artifact file extension for this artifact type. + * + * @return the file extension + * + * @see org.apache.maven.project.ArtifactType#getExtension() + */ + public String getExtension() { + return "war"; + } + +} Index: src/test/java/org/apache/maven/project/ArtifactTypeFactoryTest.java =================================================================== RCS file: src/test/java/org/apache/maven/project/ArtifactTypeFactoryTest.java diff -N src/test/java/org/apache/maven/project/ArtifactTypeFactoryTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/test/java/org/apache/maven/project/ArtifactTypeFactoryTest.java 22 Jan 2004 21:41:20 -0000 @@ -0,0 +1,84 @@ +/* + * Created on Jan 22, 2004 + * + */ +package org.apache.maven.project; + +import junit.framework.TestCase; + +/** Test the four "native" artifact types to make sure the factory is correctly functioning. + * + * @author John Casey + * + */ +public class ArtifactTypeFactoryTest extends TestCase { + + public ArtifactTypeFactoryTest(String arg0) { + super(arg0); + } + + public static void main(String[] args) { + junit.textui.TestRunner.run(ArtifactTypeFactoryTest.class); + } + + public void testEjbType(){ + ArtifactType type = ArtifactTypeFactory.findType("ejb"); + assertEquals("EJB artifact type should have a type name of \'ejb\'", "ejb", type.getType()); + assertEquals("EJB artifact type should have an extension of \'jar\'", "jar", type.getExtension()); + } + + public void testJarType(){ + ArtifactType type = ArtifactTypeFactory.findType("jar"); + assertEquals("JAR artifact type should have a type name of \'jar\'", "jar", type.getType()); + assertEquals("JAR artifact type should have an extension of \'jar\'", "jar", type.getExtension()); + } + + public void testPluginType(){ + ArtifactType type = ArtifactTypeFactory.findType("plugin"); + assertEquals("PLUGIN artifact type should have a type name of \'plugin\'", "plugin", type.getType()); + assertEquals("PLUGIN artifact type should have an extension of \'jar\'", "jar", type.getExtension()); + } + + public void testAspectType(){ + ArtifactType type = ArtifactTypeFactory.findType("aspect"); + assertEquals("ASPECT artifact type should have a type name of \'aspect\'", "aspect", type.getType()); + assertEquals("ASPECT artifact type should have an extension of \'jar\'", "jar", type.getExtension()); + } + + public void testPomType(){ + ArtifactType type = ArtifactTypeFactory.findType("pom"); + assertEquals("POM artifact type should have a type name of \'pom\'", "pom", type.getType()); + assertEquals("POM artifact type should have an extension of \'pom\'", "pom", type.getExtension()); + } + + public void testWarType(){ + ArtifactType type = ArtifactTypeFactory.findType("war"); + assertEquals("WAR artifact type should have a type name of \'war\'", "war", type.getType()); + assertEquals("WAR artifact type should have an extension of \'war\'", "war", type.getExtension()); + } + + public void testEarType(){ + ArtifactType type = ArtifactTypeFactory.findType("ear"); + assertEquals("EAR artifact type should have a type name of \'ear\'", "ear", type.getType()); + assertEquals("EAR artifact type should have an extension of \'ear\'", "ear", type.getExtension()); + } + + public void testWildcardType(){ + ArtifactType type = ArtifactTypeFactory.findType("$$$"); + assertEquals("WILDCARD artifact type should have a type name of \'$$$\'", "$$$", type.getType()); + assertEquals("WILDCARD artifact type should have an extension of \'jar\'", "jar", type.getExtension()); + } + + public void testEmptyWildcardType(){ + ArtifactType type = ArtifactTypeFactory.findType(""); + assertEquals("WILDCARD artifact type should have a type name of \'\'", "", type.getType()); + assertEquals("WILDCARD artifact type should have an extension of \'jar\'", "jar", type.getExtension()); + } + + public void testNullWildcardType(){ + ArtifactType type = ArtifactTypeFactory.findType(null); + assertNull("WILDCARD artifact type should have a null type name", type.getType()); + assertEquals("WILDCARD artifact type should have an extension of \'jar\'", "jar", type.getExtension()); + } + +}