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/23 15:04:29 UTC
cvs commit: maven-plugins/artifact/xdocs changes.xml
brett 2004/06/23 06:04:29
Modified: artifact plugin.jelly project.xml
artifact/src/main/org/apache/maven/artifact/deployer
ArtifactDeployer.java DefaultArtifactDeployer.java
DeployBean.java
artifact/xdocs changes.xml
Log:
add a custom type handler
Revision Changes Path
1.7 +2 -1 maven-plugins/artifact/plugin.jelly
Index: plugin.jelly
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/plugin.jelly,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- plugin.jelly 14 Jun 2004 14:41:13 -0000 1.6
+++ plugin.jelly 23 Jun 2004 13:04:28 -0000 1.7
@@ -76,6 +76,7 @@
project="${project}"
type="${type}"
artifact="${artifact}"
+ typeHandler="${typeHandler}"
/>
</j:otherwise>
</j:choose>
@@ -87,7 +88,6 @@
<j:choose>
<j:when test="${legacy}">
<!-- TODO: what about -snapshot-versioa, SNAPSHOT symlink? -->
-<!-- TODO: make artifact a relative path -->
<maven:makeRelativePath basedir="${basedir}" var="artifact" path="${artifact}" separator="/" />
<util:file var="f" name="${artifact}" />
<deploy:artifact
@@ -102,6 +102,7 @@
project="${project}"
type="${type}"
artifact="${artifact}"
+ typeHandler="${typeHandler}"
/>
</j:otherwise>
</j:choose>
1.27 +1 -1 maven-plugins/artifact/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/project.xml,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- project.xml 14 Jun 2004 13:36:47 -0000 1.26
+++ project.xml 23 Jun 2004 13:04:28 -0000 1.27
@@ -51,7 +51,7 @@
<dependency>
<groupId>maven</groupId>
<artifactId>maven</artifactId>
- <version>1.0-rc2</version>
+ <version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
1.5 +15 -19 maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/ArtifactDeployer.java
Index: ArtifactDeployer.java
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/ArtifactDeployer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ArtifactDeployer.java 2 May 2004 15:04:34 -0000 1.4
+++ ArtifactDeployer.java 23 Jun 2004 13:04:28 -0000 1.5
@@ -19,6 +19,7 @@
import org.apache.maven.MavenException;
import org.apache.maven.project.Project;
+import org.apache.maven.repository.ArtifactTypeHandler;
/**
*
@@ -38,61 +39,56 @@
*/
public interface ArtifactDeployer
{
-
/**
- * Deploy given artifact to remote repository
+ * Deploy given artifact to remote repository.
*
* @param artifact Artifact filename
* @param type The type of the artifact
* (like <code>war</code>, <code>jar</code>)
* @param project The project which is a producer of the artifact
- * POM conatains a bunch of varaiables which are used
- * to control the deployment process (e.g
- * <ul>
- * <li>artifactId<li>
- * <li>groupId</li>
- * <li>list of remote repositories</li>
- * </ul>
+ * @param handler the type handler for the artifact
*
* @throws MavenException
*/
- public void deploy(String artifact, String type, Project project)
+ public void deploy(String artifact, String type, Project project, ArtifactTypeHandler handler)
throws MavenException;
/**
- * Deploy given artifact as a snapshot to remote repository
+ * Deploy given artifact as a snapshot to remote repository.
* @param artifact
* @param type The type of the artifact
* (like <code>war</code>, <code>jar</code>)
* @param project The project which is a producer of the artifact
+ * @param handler the type handler for the artifact
* @see ArtifactDeployer#deploy(String, String, Project)
*
* @throws MavenException
*/
- public void deploySnapshot(String artifact, String type, Project project)
+ public void deploySnapshot(String artifact, String type, Project project, ArtifactTypeHandler handler)
throws MavenException;
/**
- * Install given artifact in local repository
+ * Install given artifact in local repository.
* @param artifact file name of the artifact
* @param type The type of the artifact
* (like <code>war</code>, <code>jar</code>)
* @param project The project which is a producer of the artifact
+ * @param handler the type handler for the artifact
* @throws MavenException
*/
- public void install(String artifact, String type, Project project)
+ public void install(String artifact, String type, Project project, ArtifactTypeHandler handler)
throws MavenException;
/**
- * Install given artifact as snapshot in local repository
+ * Install given artifact as snapshot in local repository.
* @param artifact
* @param type The type of the artifact
* (like <code>war</code>, <code>jar</code>)
* @param project The project which is a producer of the artifact
+ * @param handler the type handler for the artifact
* @throws MavenException
*/
- public void installSnapshot(String artifact, String type, Project project)
+ public void installSnapshot(String artifact, String type, Project project, ArtifactTypeHandler handler)
throws MavenException;
-
-
}
+
1.20 +42 -109 maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
Index: DefaultArtifactDeployer.java
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DefaultArtifactDeployer.java 14 Jun 2004 13:36:47 -0000 1.19
+++ DefaultArtifactDeployer.java 23 Jun 2004 13:04:28 -0000 1.20
@@ -35,6 +35,8 @@
import org.apache.maven.deploy.DeployTool;
import org.apache.maven.deploy.RepositoryInfo;
import org.apache.maven.project.Project;
+import org.apache.maven.repository.ArtifactTypeHandler;
+import org.apache.maven.repository.DefaultArtifactTypeHandler;
import org.apache.maven.util.MD5Sum;
/**
@@ -48,6 +50,8 @@
public class DefaultArtifactDeployer implements ArtifactDeployer
{
+ private static final String POM_TYPE = "pom";
+
/**
* Indicate if POM of given artifact should be also deployed
* to remote repository*/
@@ -69,6 +73,8 @@
* in local repository*/
public static final boolean INSTALL_POM_SNAPSHOT = true;
+ private static final ArtifactTypeHandler POM_ARTIFACT_TYPE_HANDLER = new DefaultArtifactTypeHandler();
+
/**
* Date/time stamp which is appended to snapshot filenames
*/
@@ -82,22 +88,13 @@
private static final Log LOG = LogFactory.getLog(DefaultArtifactDeployer.class);
/**
- * @see ArtifactDeployer#deploy(String, String, Project)
- *
- * This is "5 files" version.
- * It deploys (example):
- * foo-20030620.124616.jar,
- * foo-20030620.124616.jar.md5 ,
- * foo-SNAPSHOT.jar
- * foo-SNAPSHOT.jar.md5
- * foo-snapshot-version
- *
+ * @see ArtifactDeployer#deploy(String, String, Project, ArtifactTypeHandler)
*/
- public void deploy(String artifact, String type, Project project)
+ public void deploy(String artifact, String type, Project project, ArtifactTypeHandler handler)
throws MavenException
{
File file;
- if("pom".equals(type))
+ if(POM_TYPE.equals(type))
{
file = project.getFile();
}
@@ -107,7 +104,7 @@
}
File md5File = createMD5Checksum(file);
String repositoryPath =
- getRepositoryFullPath(type, project, project.getCurrentVersion());
+ handler.constructRepositoryFullPath(type, project, project.getCurrentVersion());
List srcFiles = new ArrayList();
srcFiles.add(file.getAbsolutePath());
@@ -118,9 +115,9 @@
destFiles.add(repositoryPath + ".md5");
//do not deploy POM twice
- if (DEPLOY_POM && !"pom".equals(type))
+ if (DEPLOY_POM && !POM_TYPE.equals(type))
{
- deploy(artifact, "pom", project);
+ deploy(artifact, POM_TYPE, project, POM_ARTIFACT_TYPE_HANDLER);
}
doDeploy(srcFiles, destFiles, project);
//Delete md5 file
@@ -128,15 +125,15 @@
}
/**
- * @see DefaultArtifactDeployer#deploySnapshot(String, String, Project)
+ * @see DefaultArtifactDeployer#deploySnapshot(String, String, Project, ArtifactTypeHandler)
*/
- public void deploySnapshot(String artifact, String type, Project project)
+ public void deploySnapshot(String artifact, String type, Project project, ArtifactTypeHandler handler)
throws MavenException
{
String snapshotSignature = getSnapshotSignature();
File file;
- if("pom".equals(type))
+ if(POM_TYPE.equals(type))
{
file = project.getFile();
}
@@ -156,14 +153,14 @@
srcFiles.add(snapshotVersionFile.getAbsolutePath());
String snapshotFilename =
- getRepositoryFullPath(
+ handler.constructRepositoryFullPath(
type,
project,
MavenConstants.SNAPSHOT_SIGNIFIER);
String timestampedFilename =
- getRepositoryFullPath(type, project, snapshotSignature);
+ handler.constructRepositoryFullPath(type, project, snapshotSignature);
String snapshotVersionsFilename =
- getRepositoryDirectoryPath(type, project)
+ handler.constructRepositoryDirectoryPath(type, project)
+ project.getArtifactId()
+ "-snapshot-version";
@@ -175,9 +172,9 @@
destFiles.add(snapshotVersionsFilename);
// do not deploy POM twice
- if (DEPLOY_POM_SNAPSHOT && !"pom".equals(type))
+ if (DEPLOY_POM_SNAPSHOT && !POM_TYPE.equals(type))
{
- deploySnapshot(artifact, "pom", project);
+ deploySnapshot(artifact, POM_TYPE, project, POM_ARTIFACT_TYPE_HANDLER);
}
doDeploy(srcFiles, destFiles, project);
@@ -186,13 +183,13 @@
};
/**
- * @see ArtifactDeployer#install(String, String, Project)
+ * @see ArtifactDeployer#install(String, String, Project, ArtifactTypeHandler)
*/
- public void install(String artifact, String type, Project project)
+ public void install(String artifact, String type, Project project, ArtifactTypeHandler handler)
throws MavenException
{
File file;
- if("pom".equals(type))
+ if(POM_TYPE.equals(type))
{
file = project.getFile();
}
@@ -200,26 +197,27 @@
{
file = getFileForArtifact(artifact);
}
- doInstall(file, type, project, project.getCurrentVersion());
+ doInstall(file, type, project, project.getCurrentVersion(), handler);
// do not install twice
- if (INSTALL_POM && !"pom".equals(type))
+ if (INSTALL_POM && !POM_TYPE.equals(type))
{
doInstall(
project.getFile(),
- "pom",
+ POM_TYPE,
project,
- project.getCurrentVersion());
+ project.getCurrentVersion(),
+ POM_ARTIFACT_TYPE_HANDLER);
}
}
/**
- * @see ArtifactDeployer#installSnapshot(String, String, Project)
+ * @see ArtifactDeployer#installSnapshot(String, String, Project, ArtifactTypeHandler)
*/
- public void installSnapshot(String artifact, String type, Project project)
+ public void installSnapshot(String artifact, String type, Project project, ArtifactTypeHandler handler)
throws MavenException
{
File file;
- if("pom".equals(type))
+ if(POM_TYPE.equals(type))
{
file = project.getFile();
}
@@ -229,17 +227,18 @@
}
String snapshotSignature = getSnapshotSignature();
System.out.println("Installing snapshot of:'" + artifact + "''");
- doInstall(file, type, project, MavenConstants.SNAPSHOT_SIGNIFIER);
- doInstall(file, type, project, snapshotSignature);
- if (INSTALL_POM_SNAPSHOT && !"pom".equals(type))
+ doInstall(file, type, project, MavenConstants.SNAPSHOT_SIGNIFIER, handler);
+ doInstall(file, type, project, snapshotSignature, handler);
+ if (INSTALL_POM_SNAPSHOT && !POM_TYPE.equals(type))
{
File projectFile = project.getFile();
doInstall(
projectFile,
- "pom",
+ POM_TYPE,
project,
- MavenConstants.SNAPSHOT_SIGNIFIER);
- doInstall(projectFile, "pom", project, snapshotSignature);
+ MavenConstants.SNAPSHOT_SIGNIFIER,
+ POM_ARTIFACT_TYPE_HANDLER);
+ doInstall(projectFile, POM_TYPE, project, snapshotSignature, POM_ARTIFACT_TYPE_HANDLER);
}
}
@@ -255,7 +254,8 @@
File file,
String type,
Project project,
- String version)
+ String version,
+ ArtifactTypeHandler handler)
throws MavenException
{
try
@@ -263,7 +263,7 @@
File destFile =
new File(
getLocalRepository(project),
- getRepositoryFullPath(type, project, version));
+ handler.constructRepositoryFullPath(type, project, version));
if (!destFile.getParentFile().exists())
{
destFile.getParentFile().mkdirs();
@@ -406,52 +406,6 @@
}
/**
- * Return relative path from repositorry root
- * for given parameters
- * @param type Artifact type
- * @param project
- * @param snapshot
- * @return
- * @todo replace this with RepoistoryLayout Service
- */
- private String getRepositoryFullPath(
- String type,
- Project project,
- String version)
- {
- StringBuffer path = new StringBuffer();
- path.append(project.getArtifactDirectory());
- path.append("/");
- path.append(type + "s");
- path.append("/");
- path.append(project.getArtifactId());
- path.append("-");
- path.append(version);
- path.append(".");
- path.append(extensionForType(type));
- return path.toString();
- }
-
- /**
- * Return relative path from repositorry root to a directory where
- * given artifact will be stored
- * @param type Artifact type
- * @param project
- * @param snapshot
- * @return
- * @todo replace this with RepoistoryLayout Service
- */
- private String getRepositoryDirectoryPath(String type, Project project)
- {
- StringBuffer path = new StringBuffer();
- path.append(project.getArtifactDirectory());
- path.append("/");
- path.append(type + "s");
- path.append("/");
- return path.toString();
- }
-
- /**
*
* @return
*/
@@ -559,25 +513,4 @@
return md5ChecksumFile;
}
- /**
- * Return file extension for given type
- * @todo Dirty hack Repository Layout Service from maven-new should be used
- * @return extension for given type
- */
- private String extensionForType(String type)
- {
- if (type.equals("ejb"))
- {
- return "jar";
- }
- else if (type.equals("plugin"))
- {
- return "jar";
- }
- else if (type.equals("uberjar"))
- {
- return "jar";
- }
- return type;
- }
}
1.6 +28 -5 maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java
Index: DeployBean.java
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DeployBean.java 2 May 2004 15:04:34 -0000 1.5
+++ DeployBean.java 23 Jun 2004 13:04:28 -0000 1.6
@@ -21,6 +21,8 @@
import org.apache.maven.artifact.deployer.ArtifactDeployer;
import org.apache.maven.artifact.deployer.DefaultArtifactDeployer;
import org.apache.maven.project.Project;
+import org.apache.maven.repository.ArtifactTypeHandler;
+import org.apache.maven.repository.DefaultArtifactTypeHandler;
/**
*
@@ -37,6 +39,7 @@
private Project project = null;
private String artifact = null;
private String type = null;
+ private ArtifactTypeHandler typeHandler = null;
public DeployBean()
{
@@ -46,6 +49,22 @@
/**
* @return
*/
+ public ArtifactTypeHandler getTypeHandler()
+ {
+ return typeHandler;
+ }
+
+ /**
+ * @param typeHandler
+ */
+ public void setTypeHandler(ArtifactTypeHandler typeHandler)
+ {
+ this.typeHandler = typeHandler;
+ }
+
+ /**
+ * @return
+ */
public String getArtifact()
{
return artifact;
@@ -110,6 +129,10 @@
{
throw new MavenException("attribute 'type' is required");
}
+ if (typeHandler == null)
+ {
+ typeHandler = new DefaultArtifactTypeHandler();
+ }
}
/**
@@ -118,7 +141,7 @@
public void deploy() throws MavenException
{
checkAttributes();
- artifactDeployer.deploy(artifact, type, project);
+ artifactDeployer.deploy(artifact, type, project, typeHandler);
}
/**
@@ -127,7 +150,7 @@
public void deploySnapshot() throws MavenException
{
checkAttributes();
- artifactDeployer.deploySnapshot(artifact, type, project);
+ artifactDeployer.deploySnapshot(artifact, type, project, typeHandler);
}
/**
@@ -136,7 +159,7 @@
public void install() throws MavenException
{
checkAttributes();
- artifactDeployer.install(artifact, type, project);
+ artifactDeployer.install(artifact, type, project, typeHandler);
}
/**
@@ -145,7 +168,7 @@
public void installSnapshot() throws MavenException
{
checkAttributes();
- artifactDeployer.installSnapshot(artifact, type, project);
+ artifactDeployer.installSnapshot(artifact, type, project, typeHandler);
}
}
1.18 +2 -0 maven-plugins/artifact/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/maven-plugins/artifact/xdocs/changes.xml,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- changes.xml 14 Jun 2004 13:36:48 -0000 1.17
+++ changes.xml 23 Jun 2004 13:04:29 -0000 1.18
@@ -26,6 +26,8 @@
</properties>
<body>
<release version="1.3" date="In CVS">
+ <action dev="brett" type="add">Add typeHandler parameter to tags to specify a custom handler</action>
+ <action dev="brett" type="add">Switch between modern and legacy mode based on properties defined</action>
<action dev="brett" type="add">Absorb the deploy plugin to give one point of migration</action>
<action dev="brett" type="fix">Build and run against the installed version of Maven</action>
<action dev="evenisse" type="fix" due-to="Martin van den Bemt" issue="MPJAR-29">Replace Apache Jakarta Maven by Apache Maven in Manifest</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org