From: <jo...@us...> - 2004-11-16 18:32:48
|
joehni 04/11/16 10:32:40 Added: javaapp/src/main/net/sourceforge/mavenplugins/javaapp JavaAppArtifactTypeHandler.java javaapp/src/test/net/sourceforge/mavenplugins/javaapp JavaAppArtifactTypeHandlerTest.java Log: Added missing Java sources. Revision Changes Path 1.1 maven-plugins/javaapp/src/main/net/sourceforge/mavenplugins/javaapp/JavaAppArtifactTypeHandler.java Index: JavaAppArtifactTypeHandler.java =================================================================== package net.sourceforge.mavenplugins.javaapp; /* ==================================================================== * Copyright 2001-2004 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. * ==================================================================== */ import org.apache.maven.project.Project; import org.apache.maven.repository.DefaultArtifactTypeHandler; /** * Handler for the type extension. * * @author <a href="mailto:jo...@sf...">Jörg Schaible</a> * @since 1.3 */ public class JavaAppArtifactTypeHandler extends DefaultArtifactTypeHandler { final private boolean keepExtension; /** * Constructs a type handler, that does not keep the extension in * the repository. */ public JavaAppArtifactTypeHandler() { this(false); } /** * Constructs a type handler. * @param keepExtension Flag to keep the type as extension in the * repository. */ public JavaAppArtifactTypeHandler(final boolean keepExtension) { this.keepExtension = keepExtension; } /** * Map an artifact to a repository path. * * @param project the project for the artifact * @param type The type of the artifact * @param version The version of the artifact (may be a snapshot) * @return the path */ public String constructRepositoryFullPath(String type, Project project, String version) { StringBuffer path = new StringBuffer(constructRepositoryDirectoryPath(type, project)); path.append(project.getArtifactId()); path.append("-"); path.append(version); path.append("."); path.append(keepExtension ? type : "jar"); return path.toString(); } } 1.1 maven-plugins/javaapp/src/test/net/sourceforge/mavenplugins/javaapp/JavaAppArtifactTypeHandlerTest.java Index: JavaAppArtifactTypeHandlerTest.java =================================================================== package net.sourceforge.mavenplugins.javaapp; /* ==================================================================== * Copyright 2001-2004 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. * ==================================================================== */ import org.apache.maven.MavenException; import org.apache.maven.project.Project; import org.apache.maven.repository.ArtifactTypeHandler; import junit.framework.TestCase; /** * @author <a href="mailto:jo...@sf...">Jörg Schaible</a> */ public class JavaAppArtifactTypeHandlerTest extends TestCase { private Project project; protected void setUp() throws Exception { super.setUp(); project = new Project(); project.setArtifactId("artifact-id"); project.setGroupId("group-id"); } public void testTypeHandlerWithDefaultExtension() throws MavenException { ArtifactTypeHandler typeHandler = new JavaAppArtifactTypeHandler(); String path = typeHandler.constructRepositoryFullPath("app", project, "version"); assertEquals("group-id/apps/artifact-id-version.jar", path); } public void testTypeHandlerKeepingTheExtension() throws MavenException { ArtifactTypeHandler typeHandler = new JavaAppArtifactTypeHandler(true); String path = typeHandler.constructRepositoryFullPath("app", project, "version"); assertEquals("group-id/apps/artifact-id-version.app", path); } } |