From ac6c7f95eebbf9a4fe656bd58697aa5e3aac4dac Mon Sep 17 00:00:00 2001 From: michal Date: Fri, 5 Sep 2003 14:53:53 +0000 Subject: [PATCH] Applied a patch from Rafal Krzewski git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113961 13f79535-47bb-0310-9956-ffa450edef68 --- .../deployer/DefaultArtifactDeployer.java | 124 +++++++----------- .../maven/deploy/deployers/FileDeployer.java | 4 +- 2 files changed, 50 insertions(+), 78 deletions(-) diff --git a/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java b/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java index c57a59e3..28aa379c 100644 --- a/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java +++ b/artifact/src/main/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java @@ -68,9 +68,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.maven.MavenConstants; import org.apache.maven.MavenException; -import org.apache.maven.deploy.RepositoryInfo; import org.apache.maven.deploy.DeployTool; -import org.apache.maven.deploy.deployers.Deployer; +import org.apache.maven.deploy.RepositoryInfo; import org.apache.maven.project.Project; import org.apache.maven.util.MD5Sum; @@ -80,7 +79,7 @@ import org.apache.maven.util.MD5Sum; * * * @author Michal Maczka - * @version $Id: DefaultArtifactDeployer.java,v 1.13 2003/07/27 21:57:19 michal Exp $ + * @version $Id: DefaultArtifactDeployer.java,v 1.14 2003/09/05 14:53:52 michal Exp $ */ public class DefaultArtifactDeployer implements ArtifactDeployer { @@ -131,8 +130,15 @@ public class DefaultArtifactDeployer implements ArtifactDeployer public void deploy(String artifact, String type, Project project) throws MavenException { - - File file = getFileForArtifact(artifact); + File file; + if("pom".equals(type)) + { + file = project.getFile(); + } + else + { + file = getFileForArtifact(artifact); + } File md5File = createMD5Checksum(file); String repositoryPath = getRepositoryFullPath(type, project, project.getCurrentVersion()); @@ -146,29 +152,13 @@ public class DefaultArtifactDeployer implements ArtifactDeployer 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"); - + deploy(artifact, "pom", project); } doDeploy(srcFiles, destFiles, project); - //Delete md5 files + //Delete md5 file md5File.delete(); - if (DEPLOY_POM_SNAPSHOT && !"pom".equals(type)) - { - projectMd5.delete(); - } } /** @@ -179,21 +169,23 @@ public class DefaultArtifactDeployer implements ArtifactDeployer { String snapshotSignature = getSnapshotSignature(); - File file = getFileForArtifact(artifact); + File file; + if("pom".equals(type)) + { + file = project.getFile(); + } + else + { + file = getFileForArtifact(artifact); + } File md5File = createMD5Checksum(file); File snapshotVersionFile = createSnapshotVersionFile(file, snapshotSignature, project, type); - String repositoryPath = - getRepositoryFullPath( - type, - project, - MavenConstants.SNAPSHOT_SIGNIFIER); List srcFiles = new ArrayList(); - - srcFiles.add(file.getAbsolutePath()); srcFiles.add(file.getAbsolutePath()); srcFiles.add(md5File.getAbsolutePath()); + srcFiles.add(file.getAbsolutePath()); srcFiles.add(md5File.getAbsolutePath()); srcFiles.add(snapshotVersionFile.getAbsolutePath()); @@ -204,53 +196,27 @@ public class DefaultArtifactDeployer implements ArtifactDeployer MavenConstants.SNAPSHOT_SIGNIFIER); String timestampedFilename = getRepositoryFullPath(type, project, snapshotSignature); + String snapshotVersionsFilename = + getRepositoryDirectoryPath(type, project) + + project.getArtifactId() + + "-snapshot-version"; List destFiles = new ArrayList(); destFiles.add(snapshotFilename); destFiles.add(snapshotFilename + ".md5"); destFiles.add(timestampedFilename); destFiles.add(timestampedFilename + ".md5"); - destFiles.add( - getRepositoryDirectoryPath(type, project) - + project.getArtifactId() - + "-snapshot-version"); + destFiles.add(snapshotVersionsFilename); // 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"); + deploySnapshot(artifact, "pom", project); } doDeploy(srcFiles, destFiles, project); - // Delete md5 files + // Delete md5 file md5File.delete(); - if (DEPLOY_POM_SNAPSHOT && !"pom".equals(type)) - { - projectMd5.delete(); - } - }; /** @@ -259,7 +225,15 @@ public class DefaultArtifactDeployer implements ArtifactDeployer public void install(String artifact, String type, Project project) throws MavenException { - File file = getFileForArtifact(artifact); + File file; + if("pom".equals(type)) + { + file = project.getFile(); + } + else + { + file = getFileForArtifact(artifact); + } doInstall(file, type, project, project.getCurrentVersion()); // do not install twice if (INSTALL_POM && !"pom".equals(type)) @@ -278,7 +252,15 @@ public class DefaultArtifactDeployer implements ArtifactDeployer public void installSnapshot(String artifact, String type, Project project) throws MavenException { - File file = getFileForArtifact(artifact); + File file; + if("pom".equals(type)) + { + file = project.getFile(); + } + else + { + file = getFileForArtifact(artifact); + } String snapshotSignature = getSnapshotSignature(); System.out.println("Installing snapshot of:'" + artifact + "''"); doInstall(file, type, project, MavenConstants.SNAPSHOT_SIGNIFIER); @@ -293,7 +275,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer MavenConstants.SNAPSHOT_SIGNIFIER); doInstall(projectFile, "pom", project, snapshotSignature); } - } /** @@ -311,7 +292,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer String version) throws MavenException { - try { File destFile = @@ -325,7 +305,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer System.out.println( "Copying: from '" + file + "' to: '" + destFile + "'"); FileUtils.copyFile(file, destFile); - } catch (IOException e) { @@ -336,7 +315,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer + e.getMessage(); throw new MavenException(msg, e); } - } /** @@ -365,7 +343,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer System.out.println( "Will deploy to " + repos.length + " repository(ies): " + repoStr); - Deployer deployer = null; for (int i = 0; i < repos.length; i++) { @@ -393,7 +370,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer } } - } /** @@ -487,7 +463,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer throw new MavenException(msg); } return file.getAbsoluteFile(); - } /** @@ -506,7 +481,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer throws MavenException { File file = null; - String basename = FileUtils.basename(artifact.getAbsolutePath()); String filename = project.getArtifactId() + "-" + type + "-snapshot-version"; try @@ -521,7 +495,6 @@ public class DefaultArtifactDeployer implements ArtifactDeployer "Cannot create snapshot-version file:" + file); } return file; - } /** @@ -576,5 +549,4 @@ public class DefaultArtifactDeployer implements ArtifactDeployer } return type; } - } diff --git a/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java b/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java index 22fedeab..77ee47e7 100644 --- a/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java +++ b/artifact/src/main/org/apache/maven/deploy/deployers/FileDeployer.java @@ -69,7 +69,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException; * file system. * * @author Michal Maczka - * @version $Id: FileDeployer.java,v 1.10 2003/08/19 04:45:05 dion Exp $ + * @version $Id: FileDeployer.java,v 1.11 2003/09/05 14:53:53 michal Exp $ */ public class FileDeployer extends AbstractDeployer { @@ -112,7 +112,7 @@ public class FileDeployer extends AbstractDeployer { destFile.mkdirs(); } - destFile = new File(destFile, request.getDestFile()); + destFile = new File(destFile, request.filename()); FileUtils.copyFile(srcFile, destFile); } catch (IOException e)