From b2a440a8d97c82950e90b8de652a9b10fbf180eb Mon Sep 17 00:00:00 2001 From: ltheussl Date: Tue, 13 Jun 2006 17:01:12 +0000 Subject: [PATCH] Checkstyle fixes: code reformatting, package.html, javadocs. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@413935 13f79535-47bb-0310-9956-ffa450edef68 --- .../dist/DistributionArtifactTypeHandler.java | 80 +++++++----- .../main/org/apache/maven/dist/package.html | 11 ++ .../DistributionArtifactTypeHandlerTest.java | 122 +++++++++++------- .../test/org/apache/maven/dist/package.html | 11 ++ 4 files changed, 148 insertions(+), 76 deletions(-) create mode 100644 dist/src/main/org/apache/maven/dist/package.html create mode 100644 dist/src/test/org/apache/maven/dist/package.html diff --git a/dist/src/main/org/apache/maven/dist/DistributionArtifactTypeHandler.java b/dist/src/main/org/apache/maven/dist/DistributionArtifactTypeHandler.java index 66e58ad2..4c8663fa 100644 --- a/dist/src/main/org/apache/maven/dist/DistributionArtifactTypeHandler.java +++ b/dist/src/main/org/apache/maven/dist/DistributionArtifactTypeHandler.java @@ -23,64 +23,82 @@ import org.apache.maven.repository.ArtifactTypeHandler; /** * This will do until wagon debuts. - * - * @author Brett Porter + * + * @author Brett Porter * @version $Id$ */ public class DistributionArtifactTypeHandler implements ArtifactTypeHandler { /** * Map an artifact to a repository directory path. - * + * * @param project the project for the artifact - * @param type The type of the artifact + * @param type The type of the artifact * @return the path + * @throws MavenException MavenException */ - public String constructRepositoryDirectoryPath(String type, Project project) throws MavenException + public String constructRepositoryDirectoryPath( String type, Project project ) + throws MavenException { StringBuffer path = new StringBuffer(); - path.append(project.getArtifactDirectory()); - path.append("/distributions/"); + + path.append( project.getArtifactDirectory() ); + path.append( "/distributions/" ); + return path.toString(); } /** * Map an artifact to a repository path. - * + * * @param project the project for the artifact - * @param type The type of the artifact + * @param type The type of the artifact * @param version The version of the artifact (may be a snapshot) * @return the path + * @throws MavenException MavenException */ - public String constructRepositoryFullPath(String type, Project project, String version) throws MavenException + public String constructRepositoryFullPath( String type, Project project, + String version ) throws MavenException { - StringBuffer path = new StringBuffer(constructRepositoryDirectoryPath(type, project)); - path.append(project.getArtifactId()); - path.append("-"); - path.append(version); - if (!type.startsWith("distribution")) { - throw new MavenException("Type is not a distribution (is " + type + ")"); - } - String subtype = type.substring(12); - if (subtype.startsWith("-src")) { - path.append("-src"); - subtype = subtype.substring(4); + StringBuffer path = + new StringBuffer( constructRepositoryDirectoryPath( type, project ) ); + + path.append( project.getArtifactId() ); + path.append( "-" ); + path.append( version ); + + if ( !type.startsWith( "distribution" ) ) + { + throw new MavenException( "Type is not a distribution (is " + type + + ")" ); } - if (subtype.equals("-targz")) { - path.append(".tar.gz"); + String subtype = type.substring( 12 ); + + if ( subtype.startsWith( "-src" ) ) + { + path.append( "-src" ); + subtype = subtype.substring( 4 ); } - else if (subtype.equals("-tarbz2")) { - path.append(".tar.bz2"); + + if ( subtype.equals( "-targz" ) ) + { + path.append( ".tar.gz" ); } - else if (subtype.equals("-zip")) { - path.append(".zip"); + else if ( subtype.equals( "-tarbz2" ) ) + { + path.append( ".tar.bz2" ); } - else { - throw new MavenException("Unrecognised distribution type (is " + type + ")"); + else if ( subtype.equals( "-zip" ) ) + { + path.append( ".zip" ); } - + else + { + throw new MavenException( "Unrecognised distribution type (is " + + type + ")" ); + } + return path.toString(); } } - diff --git a/dist/src/main/org/apache/maven/dist/package.html b/dist/src/main/org/apache/maven/dist/package.html new file mode 100644 index 00000000..ea4e47ba --- /dev/null +++ b/dist/src/main/org/apache/maven/dist/package.html @@ -0,0 +1,11 @@ + + + + org.apache.maven.dist + + +

+ Contains utility classes for the dist plugin. +

+ + diff --git a/dist/src/test/org/apache/maven/dist/DistributionArtifactTypeHandlerTest.java b/dist/src/test/org/apache/maven/dist/DistributionArtifactTypeHandlerTest.java index d1858fef..87c9c026 100644 --- a/dist/src/test/org/apache/maven/dist/DistributionArtifactTypeHandlerTest.java +++ b/dist/src/test/org/apache/maven/dist/DistributionArtifactTypeHandlerTest.java @@ -17,78 +17,110 @@ package org.apache.maven.dist; * ==================================================================== */ +import junit.framework.TestCase; + import org.apache.maven.MavenException; import org.apache.maven.project.Project; import org.apache.maven.repository.ArtifactTypeHandler; -import junit.framework.TestCase; - /** * This will do until wagon debuts. - * - * @author Brett Porter + * + * @author Brett Porter * @version $Id$ */ public class DistributionArtifactTypeHandlerTest extends TestCase { - private Project project; - private ArtifactTypeHandler handler; + /** A test version string. */ private static final String VERSION = "VERSION"; + /** A test project. */ + private Project project; + + /** A test ArtifactTypeHandler. */ + private ArtifactTypeHandler handler; + + /** JUnit setup: initialize project and handler. */ public void setUp() throws Exception { project = new Project(); - project.setGroupId("groupId"); - project.setArtifactId("artifactId"); + project.setGroupId( "groupId" ); + project.setArtifactId( "artifactId" ); handler = new DistributionArtifactTypeHandler(); } - public void testConstructRepositoryDirectoryPath() throws Exception + /** Test constructRepositoryDirectoryPath. */ + public void testConstructRepositoryDirectoryPath() + throws Exception { - assertEquals("check artifact directory", "groupId/distributions/", - handler.constructRepositoryDirectoryPath("distribution-targz", project)); - assertEquals("check artifact directory", "groupId/distributions/", - handler.constructRepositoryDirectoryPath("distribution-tarbz2", project)); - assertEquals("check artifact directory", "groupId/distributions/", - handler.constructRepositoryDirectoryPath("distribution-zip", project)); - assertEquals("check artifact directory", "groupId/distributions/", - handler.constructRepositoryDirectoryPath("distribution-src-targz", project)); - assertEquals("check artifact directory", "groupId/distributions/", - handler.constructRepositoryDirectoryPath("distribution-src-tarbz2", project)); - assertEquals("check artifact directory", "groupId/distributions/", - handler.constructRepositoryDirectoryPath("distribution-src-zip", project)); + assertEquals( "check artifact directory", "groupId/distributions/", + handler.constructRepositoryDirectoryPath( "distribution-targz", + project ) ); + assertEquals( "check artifact directory", "groupId/distributions/", + handler.constructRepositoryDirectoryPath( "distribution-tarbz2", + project ) ); + assertEquals( "check artifact directory", "groupId/distributions/", + handler.constructRepositoryDirectoryPath( "distribution-zip", + project ) ); + assertEquals( "check artifact directory", "groupId/distributions/", + handler.constructRepositoryDirectoryPath( + "distribution-src-targz", project ) ); + assertEquals( "check artifact directory", "groupId/distributions/", + handler.constructRepositoryDirectoryPath( + "distribution-src-tarbz2", project ) ); + assertEquals( "check artifact directory", "groupId/distributions/", + handler.constructRepositoryDirectoryPath( "distribution-src-zip", + project ) ); } - public void testConstructRepositoryFullPath() throws Exception + /** Test constructRepositoryFullPath. */ + public void testConstructRepositoryFullPath() + throws Exception { - try { - handler.constructRepositoryFullPath("foo", project, VERSION); - fail("expected exception"); + try + { + handler.constructRepositoryFullPath( "foo", project, VERSION ); + fail( "expected exception" ); } - catch (MavenException expected) { - assertTrue("expected exception", true); + catch ( MavenException expected ) + { + assertTrue( "expected exception", true ); } - try { - handler.constructRepositoryFullPath("distribution", project, VERSION); - fail("expected exception"); + try + { + handler.constructRepositoryFullPath( "distribution", project, + VERSION ); + fail( "expected exception" ); } - catch (MavenException expected) { - assertTrue("expected exception", true); + catch ( MavenException expected ) + { + assertTrue( "expected exception", true ); } - assertEquals("check artifact path", "groupId/distributions/artifactId-VERSION.tar.gz", - handler.constructRepositoryFullPath("distribution-targz", project, VERSION)); - assertEquals("check artifact path", "groupId/distributions/artifactId-VERSION.tar.bz2", - handler.constructRepositoryFullPath("distribution-tarbz2", project, VERSION)); - assertEquals("check artifact path", "groupId/distributions/artifactId-VERSION.zip", - handler.constructRepositoryFullPath("distribution-zip", project, VERSION)); - assertEquals("check artifact path", "groupId/distributions/artifactId-VERSION-src.tar.gz", - handler.constructRepositoryFullPath("distribution-src-targz", project, VERSION)); - assertEquals("check artifact path", "groupId/distributions/artifactId-VERSION-src.tar.bz2", - handler.constructRepositoryFullPath("distribution-src-tarbz2", project, VERSION)); - assertEquals("check artifact path", "groupId/distributions/artifactId-VERSION-src.zip", - handler.constructRepositoryFullPath("distribution-src-zip", project, VERSION)); + assertEquals( "check artifact path", + "groupId/distributions/artifactId-VERSION.tar.gz", + handler.constructRepositoryFullPath( "distribution-targz", project, + VERSION ) ); + assertEquals( "check artifact path", + "groupId/distributions/artifactId-VERSION.tar.bz2", + handler.constructRepositoryFullPath( "distribution-tarbz2", + project, VERSION ) ); + assertEquals( "check artifact path", + "groupId/distributions/artifactId-VERSION.zip", + handler.constructRepositoryFullPath( "distribution-zip", project, + VERSION ) ); + assertEquals( "check artifact path", + "groupId/distributions/artifactId-VERSION-src.tar.gz", + handler.constructRepositoryFullPath( "distribution-src-targz", + project, VERSION ) ); + assertEquals( "check artifact path", + "groupId/distributions/artifactId-VERSION-src.tar.bz2", + handler.constructRepositoryFullPath( "distribution-src-tarbz2", + project, VERSION ) ); + assertEquals( "check artifact path", + "groupId/distributions/artifactId-VERSION-src.zip", + handler.constructRepositoryFullPath( "distribution-src-zip", + project, VERSION ) ); } } - diff --git a/dist/src/test/org/apache/maven/dist/package.html b/dist/src/test/org/apache/maven/dist/package.html new file mode 100644 index 00000000..6f290263 --- /dev/null +++ b/dist/src/test/org/apache/maven/dist/package.html @@ -0,0 +1,11 @@ + + + + org.apache.maven.dist + + +

+ Test classes for org.apache.maven.test. +

+ +