modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/BundleAntProject.java
| 6 +++++
modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java
| 11 +++++----
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
| 12 +++++++---
modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
| 11 +++++----
4 files changed, 28 insertions(+), 12 deletions(-)
New commits:
commit e865a40a1ea53b11fdf3b9f0485a1fc55e80ff67
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Tue Apr 27 18:06:18 2010 -0400
diffs are now logged to the Ant project log as well as sent back to the Server to be
stored in the deployment history
diff --git
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/BundleAntProject.java
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/BundleAntProject.java
index 1936997..8849ded 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/BundleAntProject.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/BundleAntProject.java
@@ -30,6 +30,7 @@ import org.apache.tools.ant.Project;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.util.updater.DeployDifferences;
/**
* This is the Ant project object that is used when processing bundle Ant scripts
@@ -53,6 +54,7 @@ public class BundleAntProject extends Project {
private File deployDir;
private final Set<String> bundleFileNames = new HashSet<String>();
private int deploymentId;
+ private DeployDifferences deployDiffs = new DeployDifferences();
public Set<String> getBundleFileNames() {
return bundleFileNames;
@@ -111,4 +113,8 @@ public class BundleAntProject extends Project {
public void setDeploymentId(int deploymentId) {
this.deploymentId = deploymentId;
}
+
+ public DeployDifferences getDeployDifferences() {
+ return deployDiffs;
+ }
}
diff --git
a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java
b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java
index 53df7c9..d9f4118 100644
--- a/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java
+++ b/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/task/DeployTask.java
@@ -27,6 +27,7 @@ import java.util.regex.Pattern;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
import org.rhq.bundle.ant.type.ArchiveType;
import org.rhq.bundle.ant.type.FileSet;
import org.rhq.bundle.ant.type.FileType;
@@ -69,20 +70,22 @@ public class DeployTask extends AbstractBundleTask {
throw new BuildException("You must specify at least one file to deploy
via nested rhq:file and/or rhq:archive elements.");
}
if (!this.files.isEmpty()) {
- log("Deploying files " + this.files + "...");
+ log("Deploying files " + this.files + "...",
Project.MSG_VERBOSE);
}
if (!this.archives.isEmpty()) {
- log("Deploying archives " + this.archives + "...");
+ log("Deploying archives " + this.archives + "...",
Project.MSG_VERBOSE);
}
Deployer deployer = new Deployer(deploymentProps, this.archives, this.files,
deployDir, this.replacePattern,
templateEngine, this.ignorePattern);
try {
- DeployDifferences diff = null;
- deployer.deploy(diff);
+ DeployDifferences diffs = getProject().getDeployDifferences();
+ deployer.deploy(diffs);
+ getProject().log("Results:\n" + diffs + "\n");
} catch (Exception e) {
throw new BuildException("Failed to deploy bundle '" +
getProject().getBundleName() + "' version "
+ getProject().getBundleVersion() + ": " + e, e);
}
+
return;
}
diff --git
a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
index f78a5f3..1309f79 100644
---
a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
+++
b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/AntBundlePluginComponent.java
@@ -33,9 +33,7 @@ import org.rhq.bundle.ant.AntLauncher;
import org.rhq.bundle.ant.BundleAntProject;
import org.rhq.bundle.ant.DeployPropertyNames;
import org.rhq.bundle.ant.LoggerAntBuildListener;
-import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.bundle.BundleResourceDeployment;
-import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.*;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -43,10 +41,12 @@ import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.bundle.BundleDeployRequest;
import org.rhq.core.pluginapi.bundle.BundleDeployResult;
import org.rhq.core.pluginapi.bundle.BundleFacet;
+import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.system.SystemInfoFactory;
import org.rhq.core.util.stream.StreamUtil;
+import org.rhq.core.util.updater.DeployDifferences;
/**
* @author John Mazzitelli
@@ -113,6 +113,12 @@ public class AntBundlePluginComponent implements ResourceComponent,
BundleFacet
AntLauncher antLauncher = new AntLauncher();
BundleAntProject project =
antLauncher.executeBundleDeployFile(recipeFile, null, antProps,
buildListeners);
+
+ // Send the diffs to the Server so it can store them as an entry in the
deployment history.
+ BundleManagerProvider bundleManagerProvider =
request.getBundleManagerProvider();
+ DeployDifferences diffs = project.getDeployDifferences();
+ bundleManagerProvider.auditDeployment(resourceDeployment,
BundleDeploymentAction.DEPLOYMENT_STEP,
+ BundleDeploymentStatus.SUCCESS, diffs.toString());
} catch (Throwable t) {
if (log.isDebugEnabled()) {
try {
diff --git
a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
index eacc8eb..86bde70 100644
---
a/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
+++
b/modules/plugins/ant-bundle/src/main/java/org/rhq/plugins/ant/DeploymentAuditorBuildListener.java
@@ -31,6 +31,9 @@ import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.pluginapi.bundle.BundleManagerProvider;
/**
+ * Ant build listener that sends targetFinished and taskFinished events to the Server to
be stored as entries in the
+ * deployment history.
+ *
* @author Ian Springer
*/
public class DeploymentAuditorBuildListener implements BuildListener {
@@ -67,7 +70,7 @@ public class DeploymentAuditorBuildListener implements BuildListener {
auditEvent(event);
}
- public void messageLogged(BuildEvent event) {
+ public void messageLogged(BuildEvent event) {
return;
}
@@ -84,6 +87,7 @@ public class DeploymentAuditorBuildListener implements BuildListener {
return;
}
+ @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"})
private static String createMessage(BuildEvent event) {
StringBuilder msg = new StringBuilder();
if (event.getTarget() != null) {
@@ -98,11 +102,8 @@ public class DeploymentAuditorBuildListener implements BuildListener
{
msg.append(event.getMessage());
}
- //noinspection ThrowableResultOfMethodCallIgnored
if (event.getException() != null) {
- msg.append("\n");
- //noinspection ThrowableResultOfMethodCallIgnored
- msg.append(StringUtils.getStackTrace(event.getException()));
+
msg.append("\n").append(StringUtils.getStackTrace(event.getException()));
}
return msg.toString();
}
Show replies by date