You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2008/11/08 01:25:37 UTC
svn commit: r712320 -
/geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/DependencyChangeMojo.java
Author: gdamour
Date: Fri Nov 7 16:25:37 2008
New Revision: 712320
URL: http://svn.apache.org/viewvc?rev=712320&view=rev
Log:
Improvide error message and save dependency tree listing so that it is easier to refer back to it following a dependency change as per David J's advice.
(GERONIMO-4400) Improve error message of DependencyChangeMojo
Modified:
geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/DependencyChangeMojo.java
Modified: geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/DependencyChangeMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/DependencyChangeMojo.java?rev=712320&r1=712319&r2=712320&view=diff
==============================================================================
--- geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/DependencyChangeMojo.java (original)
+++ geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/DependencyChangeMojo.java Fri Nov 7 16:25:37 2008
@@ -20,17 +20,21 @@
package org.apache.geronimo.mavenplugins.car;
+import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import javax.xml.stream.XMLStreamException;
import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
import org.apache.geronimo.system.plugin.PluginXmlUtil;
import org.apache.geronimo.system.plugin.model.DependencyType;
@@ -96,27 +100,7 @@
}
}
if (!dependencies.isEmpty() || !removed.getDependency().isEmpty()) {
- File addedFile = new File(dependencyFile.getParentFile(), "dependencies.added.xml");
- PluginArtifactType added = toPluginArtifactType(dependencies);
- writeDependencies(added, addedFile);
- File removedFile = new File(dependencyFile.getParentFile(), "dependencies.removed.xml");
- writeDependencies(removed, removedFile);
- StringWriter out = new StringWriter();
- out.write("Dependencies have changed:\n");
- if (!added.getDependency().isEmpty()) {
- out.write("added:\n");
- PluginXmlUtil.writePluginArtifact(added, out);
- }
- if (!removed.getDependency().isEmpty()) {
- out.write("removed:\n");
- PluginXmlUtil.writePluginArtifact(removed, out);
- }
- out.write(treeListing);
- if (warnOnDependencyChange) {
- getLog().warn(out.toString());
- } else {
- throw new MojoFailureException(out.toString());
- }
+ saveDependencyChanges(dependencies, removed);
}
} finally {
in.close();
@@ -131,6 +115,48 @@
}
}
+ protected void saveDependencyChanges(Collection<Dependency> dependencies, PluginArtifactType removed)
+ throws Exception {
+ File addedFile = new File(dependencyFile.getParentFile(), "dependencies.added.xml");
+ PluginArtifactType added = toPluginArtifactType(dependencies);
+ writeDependencies(added, addedFile);
+
+ File removedFile = new File(dependencyFile.getParentFile(), "dependencies.removed.xml");
+ writeDependencies(removed, removedFile);
+
+ File treeListing = saveTreeListing();
+
+ StringWriter out = new StringWriter();
+ out.write("Dependencies have changed:\n");
+ if (!added.getDependency().isEmpty()) {
+ out.write("\tAdded dependencies are saved here: " + addedFile.getAbsolutePath() + "\n");
+ }
+ if (!removed.getDependency().isEmpty()) {
+ out.write("\tRemoved dependencies are saved here: " + removedFile.getAbsolutePath() + "\n");
+ }
+ out.write("\tTree listing is saved here: " + treeListing.getAbsolutePath() + "\n");
+ out.write("Delete " + dependencyFile.getAbsolutePath()
+ + " if you are happy with the dependency changes.");
+
+ if (warnOnDependencyChange) {
+ getLog().warn(out.toString());
+ } else {
+ throw new MojoFailureException(out.toString());
+ }
+ }
+
+ protected File saveTreeListing() throws IOException {
+ File treeListFile = new File(dependencyFile.getParentFile(), "treeListing.xml");
+ OutputStream os = new FileOutputStream(treeListFile);
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os));
+ try {
+ writer.write(treeListing);
+ } finally {
+ writer.close();
+ }
+ return treeListFile;
+ }
+
private PluginArtifactType toPluginArtifactType(Collection<Dependency> dependencies) throws IOException, XMLStreamException, JAXBException {
PluginArtifactType pluginArtifactType = new PluginArtifactType();
for (Dependency dependency: dependencies) {