POM is deployed/installed together with artifact (hope that fetch will do the same soon:) )
snapshotSignature (timestamp) is now relative to GMT timezone git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113729 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
9480f0b357
commit
844c0078fc
3 files changed
+180
-61
No files matched your search
+166
-46
@@ -62,6 +62,7 @@ import java.text.SimpleDateFormat;
|
||||
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;
|
||||
@@ -79,17 +80,42 @@ import org.apache.maven.util.MD5Sum;
|
||||
*
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DefaultArtifactDeployer.java,v 1.12 2003/07/17 11:13:17 michal Exp $
|
||||
* @version $Id: DefaultArtifactDeployer.java,v 1.13 2003/07/27 21:57:19 michal Exp $
|
||||
*/
|
||||
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 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
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 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
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 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
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 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
{
|
||||
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 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
throws MavenException
|
||||
{
|
||||
File file = getFileForArtifact(artifact);
|
||||
String snapshotSignature = getSnapshotSignature();
|
||||
System.out.println("Installing snapshot of:'" + artifact + "''");
|
||||
try
|
||||
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);
|
||||
}
|
||||
catch (MavenException e)
|
||||
{
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
try
|
||||
{
|
||||
doInstall(file, type, project, getSnapshotVersion());
|
||||
}
|
||||
catch (MavenException e)
|
||||
{
|
||||
System.out.println(e.getMessage());
|
||||
File projectFile = project.getFile();
|
||||
doInstall(
|
||||
projectFile,
|
||||
"pom",
|
||||
project,
|
||||
MavenConstants.SNAPSHOT_SIGNIFIER);
|
||||
doInstall(projectFile, "pom", project, snapshotSignature);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +317,7 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
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 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
|
||||
// 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 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
* @return
|
||||
* @todo replace this with RepoistoryLayout Service
|
||||
*/
|
||||
private String getRepositoryPath(
|
||||
private String getRepositoryFullPath(
|
||||
String type,
|
||||
Project project,
|
||||
String version)
|
||||
@@ -334,14 +433,33 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
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
|
||||
*/
|
||||
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 @@ public class DefaultArtifactDeployer implements ArtifactDeployer
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file which contains timestamp of the latetst snapshot
|
||||
*
|
||||
* @param snapshotVersion
|
||||
* @param project
|
||||
* @param type
|
||||
|
||||
@@ -74,7 +74,7 @@ import org.apache.maven.deploy.exceptions.UnsupportedProtocolException;
|
||||
* Utility class
|
||||
*
|
||||
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
|
||||
* @version $Id: DeployTool.java,v 1.7 2003/07/17 11:13:18 michal Exp $
|
||||
* @version $Id: DeployTool.java,v 1.8 2003/07/27 21:57:19 michal Exp $
|
||||
*/
|
||||
public class DeployTool
|
||||
{
|
||||
@@ -169,7 +169,7 @@ public class DeployTool
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
|
||||
* Deployers which for every deployment request
|
||||
* starts a new external process (e.g batch file, shell script)
|
||||
*
|
||||
* @version $Id: ExternalDeployer.java,v 1.2 2003/07/17 11:13:17 michal Exp $
|
||||
* @version $Id: ExternalDeployer.java,v 1.3 2003/07/27 21:57:19 michal Exp $
|
||||
* @todo still have to account for differing setups for people deploying to
|
||||
* their own sites and to the central repository.
|
||||
* @todo finich
|
||||
@@ -80,38 +80,37 @@ public class ExternalDeployer extends AbstractDeployer
|
||||
/* (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 @@ public class ExternalDeployer extends AbstractDeployer
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new TransferFailedException(
|
||||
"Failed to deploy with extrnal program",
|
||||
"Failed to deploy with external program",
|
||||
e);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user