michal 2003/07/27 14:57:19
Modified: src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers
ExternalDeployer.java
src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer
DefaultArtifactDeployer.java
src/plugins-build/artifact/src/main/org/apache/maven/deploy
DeployTool.java
Log:
POM is deployed/installed together with artifact (hope that fetch will do the same
soon:) )
snapshotSignature (timestamp) is now relative to GMT timezone
Revision Changes Path
1.3 +12 -13
maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers/ExternalDeployer.java
Index: ExternalDeployer.java
===================================================================
RCS file:
/home/cvs/maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/deployers/ExternalDeployer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExternalDeployer.java 17 Jul 2003 11:13:17 -0000 1.2
+++ ExternalDeployer.java 27 Jul 2003 21:57:19 -0000 1.3
@@ -80,38 +80,37 @@
/* (non-Javadoc)
* @see
org.apache.maven.deploy.deployers.Deployer#init(org.apache.maven.deploy.HostInfo)
*/
- public void init(RepositoryInfo repoInfo)
- throws AuthenticationException
+ public void init(RepositoryInfo repoInfo) throws AuthenticationException
{
cmd = repoInfo.getHost();
}
- /* (non-Javadoc)
+ /**
* @see org.apache.maven.deploy.deployers.Deployer#release()
*/
public void release()
{
- // TODO Auto-generated method stub
+
}
- /* (non-Javadoc)
+ /**
* @see
org.apache.maven.deploy.deployers.Deployer#deploy(org.apache.maven.deploy.DeployRequest)
*/
public void deploy(DeployRequest request) throws TransferFailedException
{
- String[] params =
- {
- request.getSrcFile(),
- request.getDestFile(),
- };
+ String[] params = { request.getSrcFile(), request.getDestFile(), };
try
{
- System.out.println("Staring external process: '" + cmd + "'");
+ System.out.println(
+ "Staring external process: '"
+ + cmd
+ + "' to deploy:'"
+ + request.getDestFile());
Process process = Runtime.getRuntime().exec(cmd, params);
process.waitFor();
System.out.println("External process finished");
@@ -119,7 +118,7 @@
catch (Exception e)
{
throw new TransferFailedException(
- "Failed to deploy with extrnal program",
+ "Failed to deploy with external program",
e);
}
1.13 +167 -47
maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
Index: DefaultArtifactDeployer.java
===================================================================
RCS file:
/home/cvs/maven/src/plugins-build/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DefaultArtifactDeployer.java 17 Jul 2003 11:13:17 -0000 1.12
+++ DefaultArtifactDeployer.java 27 Jul 2003 21:57:19 -0000 1.13
@@ -62,6 +62,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.TimeZone;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
@@ -84,12 +85,37 @@
public class DefaultArtifactDeployer implements ArtifactDeployer
{
+ /**
+ * Indicate if POM of given artifact should be also deployed
+ * to remote repository*/
+ public static final boolean DEPLOY_POM = true;
+
+ /**
+ * Indicate if POM of given artifact should be also deployed
+ * in local repository*/
+ public static final boolean INSTALL_POM = true;
+
+ /**
+ * Indicate if snapshot versio of
+ * POM of given artifact should be also deployed
+ * to remote repository*/
+ public static final boolean DEPLOY_POM_SNAPSHOT = true;
+
+ /**
+ * Indicate if POM of given artifact should be also installed
+ * in local repository*/
+ public static final boolean INSTALL_POM_SNAPSHOT = true;
+
/**
* Date/time stamp which is appended to snapshot filenames
*/
- public final static DateFormat SNAPSHOT_MARKER =
+ public final static DateFormat SNAPSHOT_SIGNATURE_FMT =
new SimpleDateFormat("yyyyMMdd.HHmmss");
+ static {
+ SNAPSHOT_SIGNATURE_FMT.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+
/**
* @see ArtifactDeployer#deploy(String, String, Project)
*
@@ -106,11 +132,10 @@
throws MavenException
{
- project.getFile();
File file = getFileForArtifact(artifact);
File md5File = createMD5Checksum(file);
String repositoryPath =
- getRepositoryPath(type, project, project.getCurrentVersion());
+ getRepositoryFullPath(type, project, project.getCurrentVersion());
List srcFiles = new ArrayList();
srcFiles.add(file.getAbsolutePath());
@@ -119,7 +144,31 @@
List destFiles = new ArrayList();
destFiles.add(repositoryPath);
destFiles.add(repositoryPath + ".md5");
+
+ //do not deploy POM twice
+ File projectMd5 = null;
+ if (DEPLOY_POM && !"pom".equals(type))
+ {
+ File projectFile = project.getFile();
+ projectMd5 = createMD5Checksum(projectFile);
+ String pomRepositoryPath =
+ getRepositoryFullPath(
+ "pom",
+ project,
+ project.getCurrentVersion());
+ srcFiles.add(projectFile.getAbsolutePath());
+ srcFiles.add(projectMd5.getAbsolutePath());
+ destFiles.add(pomRepositoryPath);
+ destFiles.add(pomRepositoryPath + ".md5");
+
+ }
doDeploy(srcFiles, destFiles, project);
+ //Delete md5 files
+ md5File.delete();
+ if (DEPLOY_POM_SNAPSHOT && !"pom".equals(type))
+ {
+ projectMd5.delete();
+ }
}
/**
@@ -129,32 +178,78 @@
throws MavenException
{
- String snapshotVersion = getSnapshotVersion();
+ String snapshotSignature = getSnapshotSignature();
File file = getFileForArtifact(artifact);
File md5File = createMD5Checksum(file);
File snapshotVersionFile =
- createSnapshotVersionFile(file, snapshotVersion, project, type);
+ createSnapshotVersionFile(file, snapshotSignature, project, type);
String repositoryPath =
- getRepositoryPath(type, project, MavenConstants.SNAPSHOT_SIGNIFIER);
+ getRepositoryFullPath(
+ type,
+ project,
+ MavenConstants.SNAPSHOT_SIGNIFIER);
List srcFiles = new ArrayList();
+
srcFiles.add(file.getAbsolutePath());
srcFiles.add(file.getAbsolutePath());
srcFiles.add(md5File.getAbsolutePath());
srcFiles.add(md5File.getAbsolutePath());
srcFiles.add(snapshotVersionFile.getAbsolutePath());
- String out1 =
- getRepositoryPath(type, project, MavenConstants.SNAPSHOT_SIGNIFIER);
- String out2 = getRepositoryPath(type, project, snapshotVersion);
+ String snapshotFilename =
+ getRepositoryFullPath(
+ type,
+ project,
+ MavenConstants.SNAPSHOT_SIGNIFIER);
+ String timestampedFilename =
+ getRepositoryFullPath(type, project, snapshotSignature);
List destFiles = new ArrayList();
- destFiles.add(out1);
- destFiles.add(out1 + ".md5");
- destFiles.add(out2);
- destFiles.add(out2 + ".md5");
- destFiles.add(project.getArtifactId() + "-snapshot-version");
+ destFiles.add(snapshotFilename);
+ destFiles.add(snapshotFilename + ".md5");
+ destFiles.add(timestampedFilename);
+ destFiles.add(timestampedFilename + ".md5");
+ destFiles.add(
+ getRepositoryDirectoryPath(type, project)
+ + project.getArtifactId()
+ + "-snapshot-version");
+
+ // do not deploy POM twice
+ File projectMd5 = null;
+ if (DEPLOY_POM_SNAPSHOT && !"pom".equals(type))
+ {
+ File projectFile = project.getFile();
+ projectMd5 = createMD5Checksum(projectFile);
+ String pomRepositoryPath =
+ getRepositoryFullPath(
+ "pom",
+ project,
+ project.getCurrentVersion());
+ srcFiles.add(projectFile.getAbsolutePath());
+ srcFiles.add(projectFile.getAbsolutePath());
+
+ srcFiles.add(projectMd5.getAbsolutePath());
+ srcFiles.add(projectMd5.getAbsolutePath());
+ srcFiles.add(snapshotVersionFile.getAbsolutePath());
+
+ destFiles.add(pomRepositoryPath);
+ destFiles.add(pomRepositoryPath);
+ destFiles.add(pomRepositoryPath + ".md5");
+ destFiles.add(pomRepositoryPath + ".md5");
+ destFiles.add(
+ getRepositoryDirectoryPath("pom", project)
+ + project.getArtifactId()
+ + "-snapshot-version");
+ }
+
doDeploy(srcFiles, destFiles, project);
+ // Delete md5 files
+ md5File.delete();
+ if (DEPLOY_POM_SNAPSHOT && !"pom".equals(type))
+ {
+ projectMd5.delete();
+ }
};
@@ -166,6 +261,15 @@
{
File file = getFileForArtifact(artifact);
doInstall(file, type, project, project.getCurrentVersion());
+ // do not install twice
+ if (INSTALL_POM && !"pom".equals(type))
+ {
+ doInstall(
+ project.getFile(),
+ "pom",
+ project,
+ project.getCurrentVersion());
+ }
}
/**
@@ -175,23 +279,21 @@
throws MavenException
{
File file = getFileForArtifact(artifact);
+ String snapshotSignature = getSnapshotSignature();
System.out.println("Installing snapshot of:'" + artifact + "''");
- try
- {
- doInstall(file, type, project, MavenConstants.SNAPSHOT_SIGNIFIER);
- }
- catch (MavenException e)
- {
- System.out.println(e.getMessage());
- }
- try
- {
- doInstall(file, type, project, getSnapshotVersion());
- }
- catch (MavenException e)
- {
- System.out.println(e.getMessage());
+ doInstall(file, type, project, MavenConstants.SNAPSHOT_SIGNIFIER);
+ doInstall(file, type, project, snapshotSignature);
+ if (INSTALL_POM_SNAPSHOT && !"pom".equals(type))
+ {
+ File projectFile = project.getFile();
+ doInstall(
+ projectFile,
+ "pom",
+ project,
+ MavenConstants.SNAPSHOT_SIGNIFIER);
+ doInstall(projectFile, "pom", project, snapshotSignature);
}
+
}
/**
@@ -215,7 +317,7 @@
File destFile =
new File(
getLocalRepository(project),
- getRepositoryPath(type, project, version));
+ getRepositoryFullPath(type, project, version));
if (!destFile.getParentFile().exists())
{
destFile.getParentFile().mkdirs();
@@ -251,32 +353,29 @@
// trick add special values to context for default repository;
- String repos =
+ String repoStr =
(String) project.getContext().getVariable("maven.repo.list");
- if (repos == null || repos.length() == 0)
+ if (repoStr == null || repoStr.length() == 0)
{
- System.out.println(
- "No remote repository is defined for deployment");
+ System.out.println("No remote repository was defined.");
return;
}
- String[] repoArray = StringUtils.split(repos, ",");
+ String[] repos = StringUtils.split(repoStr, ",");
System.out.println(
- "Will deploy to " + repoArray.length + " repo(s): " + repos);
+ "Will deploy to " + repos.length + " repository(ies): " + repoStr);
Deployer deployer = null;
- for (int i = 0; i < repoArray.length; i++)
+ for (int i = 0; i < repos.length; i++)
{
- String repo = repoArray[i].trim();
- System.out.println("Deploying to repo: " + repo);
+ String repo = repos[i].trim();
+ System.out.println("Deploying to repository: " + repo);
RepositoryInfo repoInfo = null;
try
{
repoInfo =
- RepositoryInfoBuilder.getRepositoryInfo(
- project,
- repo);
+ RepositoryInfoBuilder.getRepositoryInfo(project, repo);
deployTool.deploy(repoInfo, srcFiles, destFiles);
}
@@ -316,7 +415,7 @@
* @return
* @todo replace this with RepoistoryLayout Service
*/
- private String getRepositoryPath(
+ private String getRepositoryFullPath(
String type,
Project project,
String version)
@@ -335,13 +434,32 @@
}
/**
+ * 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
*/
- private String getSnapshotVersion()
+ private String getSnapshotSignature()
{
- Date date = new Date();
- return SNAPSHOT_MARKER.format(date);
+ Date now = new Date();
+ return SNAPSHOT_SIGNATURE_FMT.format(now);
}
/**
@@ -373,6 +491,8 @@
}
/**
+ * Create a file which contains timestamp of the latetst snapshot
+ *
* @param snapshotVersion
* @param project
* @param type
1.8 +2 -2
maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/DeployTool.java
Index: DeployTool.java
===================================================================
RCS file:
/home/cvs/maven/src/plugins-build/artifact/src/main/org/apache/maven/deploy/DeployTool.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DeployTool.java 17 Jul 2003 11:13:18 -0000 1.7
+++ DeployTool.java 27 Jul 2003 21:57:19 -0000 1.8
@@ -169,7 +169,7 @@
String srcFile = (String) srcIterator.next();
String destFile = (String) destIterator.next();
DeployRequest request = new DeployRequest(srcFile, destFile);
- System.out.println("Deploying: " + srcFile);
+ System.out.println("Deploying: " + srcFile + "-->" + destFile);
deployer.deploy(request);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]