[jboss-svn-commits] JBL Code SVN: r16710 - labs/jbossbuild/maven-plugins/trunk/maven-jboss-deploy-plugin/src/main/java/org/jboss/maven/plugins/deploy.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 20 18:42:47 EST 2007
Author: pgier
Date: 2007-11-20 18:42:47 -0500 (Tue, 20 Nov 2007)
New Revision: 16710
Modified:
labs/jbossbuild/maven-plugins/trunk/maven-jboss-deploy-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java
Log:
[JBBUILD-426] Adding option to remove the version number from deployed artifacts.
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jboss-deploy-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jboss-deploy-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java 2007-11-20 23:19:10 UTC (rev 16709)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jboss-deploy-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java 2007-11-20 23:42:47 UTC (rev 16710)
@@ -67,6 +67,13 @@
private String license;
/**
+ * Boolean that determines if the artifact version should be included in the
+ * deployed jar files.
+ * @parameter default-value="false"
+ */
+ private boolean removeArtifactVersion;
+
+ /**
* Maven project properties.
*
* @parameter expression="${project.properties}"
@@ -210,11 +217,12 @@
Artifact projectArtifact = project.getArtifact();
if (projectArtifact != null && projectArtifact.getFile() != null)
{
- artifactSet.add(" <artifact id=\"" + projectArtifact.getFile().getName() + "\"/>\n");
+ String deployFileName = generateOutputFileName(projectArtifact, removeArtifactVersion);
+ artifactSet.add(" <artifact id=\"" + deployFileName + "\"/>\n");
try
{
- this.getLog().debug("Deploying file://" + deployToLibDir + fileSep + projectArtifact.getFile().getName());
- FileUtils.copyFileToDirectory(projectArtifact.getFile(), deployToLibDir);
+ this.getLog().debug("Deploying file://" + deployToLibDir + fileSep + deployFileName);
+ FileUtils.copyFile(projectArtifact.getFile(), new File(deployToLibDir, deployFileName));
}
catch (IOException ioe)
{
@@ -234,8 +242,8 @@
String classifierStr = artifact.getClassifier();
if (classifierStr == null) {
classifierStr = "";
- // If the classifier is null and the artifactId matches the project
- // the it must be a composite project, so we add the artifact to the
+ // If the classifier is null and the artifactId matches the project artifactId
+ // it must be a composite project, so we add the artifact to the
// list of exports.
if (artifact.getArtifactId().equals(project.getArtifactId())) {
exports.add(artifact.getArtifactId() + "." + artifact.getType());
@@ -245,7 +253,8 @@
getLog().warn("This could be caused by an assembly descriptor with no id.");
}
}
- String artifactLine = " <artifact id=\"" + artifact.getFile().getName() + "\"/>\n";
+ String deployFileName = generateOutputFileName(artifact, removeArtifactVersion);
+ String artifactLine = " <artifact id=\"" + deployFileName + "\"/>\n";
// Check for duplicates
if (artifactSet.contains(artifactLine)) {
@@ -257,8 +266,9 @@
try
{
- this.getLog().debug("Deploying file://" + deployToLibDir + fileSep + artifact.getFile().getName());
- FileUtils.copyFileToDirectory(artifact.getFile(), deployToLibDir);
+ this.getLog().debug("Deploying file://" + deployToLibDir + fileSep + deployFileName);
+ File deploytoFile = new File(deployToLibDir, deployFileName);
+ FileUtils.copyFile(artifact.getFile(), deploytoFile);
}
catch (IOException ioe)
{
@@ -321,6 +331,20 @@
}
}
+ private String generateOutputFileName(Artifact artifact, boolean removeArtifactVersion)
+ {
+ String deployFileName = artifact.getFile().getName();
+ if (removeArtifactVersion)
+ {
+ if ( deployFileName.contains( artifact.getBaseVersion() ) )
+ {
+ deployFileName = deployFileName.replace( ("-" + artifact.getBaseVersion()), "" );
+ }
+ }
+ return deployFileName;
+
+ }
+
/**
* Creates the list of imports to include in the component-info.xml
*/
More information about the jboss-svn-commits
mailing list