You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2004/06/25 15:48:54 UTC
cvs commit: maven-plugins/dist/src/test/org/apache/maven/dist DistributionArtifactTypeHandlerTest.java
brett 2004/06/25 06:48:54
Modified: dist plugin.jelly
Added: dist/src/main/org/apache/maven/dist
DistributionArtifactTypeHandler.java
dist/src/test/org/apache/maven/dist
DistributionArtifactTypeHandlerTest.java
Log:
add missing classes and check for artifact 1.3+
Revision Changes Path
1.17 +19 -0 maven-plugins/dist/plugin.jelly
Index: plugin.jelly
===================================================================
RCS file: /home/cvs/maven-plugins/dist/plugin.jelly,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- plugin.jelly 23 Jun 2004 13:29:35 -0000 1.16
+++ plugin.jelly 25 Jun 2004 13:48:53 -0000 1.17
@@ -23,7 +23,26 @@
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:artifact="artifact"
+ xmlns:deploy="deploy"
xmlns:util="jelly:util">
+
+ <!-- Poor mans version check - plugin dependencies still suck for multiple versions -->
+ <maven:get plugin="maven-artifact-plugin" property="plugin" var="artifactPlugin" />
+ <j:if test="${artifactPlugin.currentVersion.compareTo('1.3') lt 0}">
+ <ant:fail>
+ Must have artifact plugin v1.3 installed to use this version of the dist plugin.
+ Try: maven plugin:download -DgroupId=maven -DartifactId=maven-artifact-plugin -Dversion=1.3
+ </ant:fail>
+ </j:if>
+ <!-- Can remove deploy dependency above when this is gone -->
+ <maven:get plugin="maven-deploy-plugin" property="plugin" var="deployPlugin" />
+ <j:if test="${deployPlugin != null}">
+ <ant:fail>
+ Must remove the deploy plugin to use this version of the dist plugin.
+ Please delete ${deployPlugin.artifactId}-${deployPlugin.currentVersion}.jar from
+ ${maven.plugin.dir} and ${maven.plugin.unpacked.dir} (if it exists)
+ </ant:fail>
+ </j:if>
<j:new var="distTypeHandler" className="org.apache.maven.dist.DistributionArtifactTypeHandler" />
1.1 maven-plugins/dist/src/main/org/apache/maven/dist/DistributionArtifactTypeHandler.java
Index: DistributionArtifactTypeHandler.java
===================================================================
package org.apache.maven.dist;
/* ====================================================================
* 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;
/**
* This will do until wagon debuts.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: DistributionArtifactTypeHandler.java,v 1.1 2004/06/25 13:48:53 brett Exp $
*/
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
* @return the path
*/
public String constructRepositoryDirectoryPath(String type, Project project) throws MavenException
{
StringBuffer path = new StringBuffer();
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 version The version of the artifact (may be a snapshot)
* @return the path
*/
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);
}
if (subtype.equals("-targz")) {
path.append(".tar.gz");
}
else if (subtype.equals("-tarbz2")) {
path.append(".tar.bz2");
}
else if (subtype.equals("-zip")) {
path.append(".zip");
}
else {
throw new MavenException("Unrecognised distribution type (is " + type + ")");
}
return path.toString();
}
}
1.1 maven-plugins/dist/src/test/org/apache/maven/dist/DistributionArtifactTypeHandlerTest.java
Index: DistributionArtifactTypeHandlerTest.java
===================================================================
package org.apache.maven.dist;
/* ====================================================================
* 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;
/**
* This will do until wagon debuts.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: DistributionArtifactTypeHandlerTest.java,v 1.1 2004/06/25 13:48:54 brett Exp $
*/
public class DistributionArtifactTypeHandlerTest extends TestCase
{
private Project project;
private ArtifactTypeHandler handler;
private static final String VERSION = "VERSION";
public void setUp() throws Exception
{
project = new Project();
project.setGroupId("groupId");
project.setArtifactId("artifactId");
handler = new DistributionArtifactTypeHandler();
}
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));
}
public void testConstructRepositoryFullPath() throws Exception
{
try {
handler.constructRepositoryFullPath("foo", project, VERSION);
fail("expected exception");
}
catch (MavenException expected) {
assertTrue("expected exception", true);
}
try {
handler.constructRepositoryFullPath("distribution", project, VERSION);
fail("expected exception");
}
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));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org