You are viewing a plain text version of this content. The canonical link for it is here.
Posted to easyant-commits@incubator.apache.org by hi...@apache.org on 2011/02/22 15:56:09 UTC
svn commit: r1073371 [16/28] - in /incubator/easyant/core/trunk: ./ bin/
example/build-configurations/
example/build-configurations/src/main/java/org/apache/easyant/example/
example/build-configurations/src/test/java/org/apache/easyant/example/
example...
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java Tue Feb 22 15:55:55 2011
@@ -52,533 +52,533 @@ import org.apache.ivy.util.XMLHelper;
*/
public class XMLEasyAntReportWriter {
- static final String REPORT_ENCODING = "UTF-8";
- private boolean displaySubProperties;
+ static final String REPORT_ENCODING = "UTF-8";
+ private boolean displaySubProperties;
- public void output(ConfigurationResolveReport report, OutputStream stream,
- EasyAntReport easyAntReport) {
- output(report, new String[] { report.getConfiguration() }, stream,
- easyAntReport);
- }
-
- public void output(ConfigurationResolveReport report, String[] confs,
- OutputStream stream, EasyAntReport easyAntReport) {
- OutputStreamWriter encodedOutStream;
- try {
- encodedOutStream = new OutputStreamWriter(stream, REPORT_ENCODING);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(REPORT_ENCODING
- + " is not known on your jvm", e);
- }
- PrintWriter out = new PrintWriter(new BufferedWriter(encodedOutStream));
- ModuleRevisionId mrid = report.getModuleDescriptor()
- .getModuleRevisionId();
- // out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
- out.println("<?xml version=\"1.0\" encoding=\"" + REPORT_ENCODING
- + "\"?>");
- out
- .println("<?xml-stylesheet type=\"text/xsl\" href=\"easyant-report.xsl\"?>");
- out.println("<ivy-report version=\"1.0\">");
- out.println("\t<info");
- out.println("\t\torganisation=\""
- + XMLHelper.escape(mrid.getOrganisation()) + "\"");
- out.println("\t\tmodule=\"" + XMLHelper.escape(mrid.getName()) + "\"");
- out.println("\t\trevision=\"" + XMLHelper.escape(mrid.getRevision())
- + "\"");
- if (mrid.getBranch() != null) {
- out.println("\t\tbranch=\"" + XMLHelper.escape(mrid.getBranch())
- + "\"");
- }
- Map extraAttributes = mrid.getExtraAttributes();
- for (Iterator it = extraAttributes.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Entry) it.next();
- out.println("\t\textra-" + entry.getKey() + "=\""
- + XMLHelper.escape(entry.getValue().toString()) + "\"");
- }
- out.println("\t\tconf=\"" + XMLHelper.escape(report.getConfiguration())
- + "\"");
- out.println("\t\tconfs=\""
- + XMLHelper.escape(StringUtils.join(confs, ", ")) + "\"");
- out.println("\t\tdate=\"" + Ivy.DATE_FORMAT.format(report.getDate())
- + "\"/>");
-
- out.println("\t<dependencies>");
-
- // create a list of ModuleRevisionIds indicating the position for each
- // dependency
- List dependencies = new ArrayList(report.getModuleRevisionIds());
-
- for (Iterator iter = report.getModuleIds().iterator(); iter.hasNext();) {
- ModuleId mid = (ModuleId) iter.next();
- out.println("\t\t<module organisation=\""
- + XMLHelper.escape(mid.getOrganisation()) + "\""
- + " name=\"" + XMLHelper.escape(mid.getName()) + "\" >");
- for (Iterator it2 = report.getNodes(mid).iterator(); it2.hasNext();) {
- IvyNode dep = (IvyNode) it2.next();
- ouputRevision(report, out, dependencies, dep, easyAntReport);
- }
- out.println("\t\t</module>");
- }
- out.println("\t</dependencies>");
- out.println("</ivy-report>");
- out.flush();
- }
-
- private void ouputRevision(ConfigurationResolveReport report,
- PrintWriter out, List dependencies, IvyNode dep,
- EasyAntReport easyAntReport) {
- Map extraAttributes;
- ModuleDescriptor md = null;
- if (dep.getModuleRevision() != null) {
- md = dep.getModuleRevision().getDescriptor();
- }
- StringBuffer details = new StringBuffer();
- if (dep.isLoaded()) {
- details.append(" status=\"");
- details.append(XMLHelper.escape(dep.getDescriptor().getStatus()));
- details.append("\" pubdate=\"");
- details.append(Ivy.DATE_FORMAT
- .format(new Date(dep.getPublication())));
- details.append("\" resolver=\"");
- details.append(XMLHelper.escape(dep.getModuleRevision()
- .getResolver().getName()));
- details.append("\" artresolver=\"");
- details.append(XMLHelper.escape(dep.getModuleRevision()
- .getArtifactResolver().getName()));
- details.append("\"");
- }
- if (dep.isEvicted(report.getConfiguration())) {
- EvictionData ed = dep.getEvictedData(report.getConfiguration());
- if (ed.getConflictManager() != null) {
- details.append(" evicted=\"").append(
- XMLHelper.escape(ed.getConflictManager().toString()))
- .append("\"");
- } else {
- details.append(" evicted=\"transitive\"");
- }
- details.append(" evicted-reason=\"").append(
- XMLHelper.escape(ed.getDetail() == null ? "" : ed
- .getDetail())).append("\"");
- }
- if (dep.hasProblem()) {
- details.append(" error=\"").append(
- XMLHelper.escape(dep.getProblem().getMessage())).append(
- "\"");
- }
- if (md != null && md.getHomePage() != null) {
- details.append(" homepage=\"").append(
- XMLHelper.escape(md.getHomePage())).append("\"");
- }
- extraAttributes = md != null ? md.getExtraAttributes() : dep
- .getResolvedId().getExtraAttributes();
- for (Iterator iterator = extraAttributes.keySet().iterator(); iterator
- .hasNext();) {
- String attName = (String) iterator.next();
- details.append(" extra-").append(attName).append("=\"").append(
- XMLHelper.escape(extraAttributes.get(attName).toString()))
- .append("\"");
- }
- String defaultValue = dep.getDescriptor() != null ? " default=\""
- + dep.getDescriptor().isDefault() + "\"" : "";
- int position = dependencies.indexOf(dep.getResolvedId());
- out.println("\t\t\t<revision name=\""
- + XMLHelper.escape(dep.getResolvedId().getRevision())
- + "\""
- + (dep.getResolvedId().getBranch() == null ? "" : " branch=\""
- + XMLHelper.escape(dep.getResolvedId().getBranch())
- + "\"") + details + " downloaded=\""
- + dep.isDownloaded() + "\"" + " searched=\"" + dep.isSearched()
- + "\"" + defaultValue + " conf=\""
- + toString(dep.getConfigurations(report.getConfiguration()))
- + "\"" + " position=\"" + position + "\">");
- if (md != null) {
- License[] licenses = md.getLicenses();
- for (int i = 0; i < licenses.length; i++) {
- String lurl;
- if (licenses[i].getUrl() != null) {
- lurl = " url=\"" + XMLHelper.escape(licenses[i].getUrl())
- + "\"";
- } else {
- lurl = "";
- }
- out.println("\t\t\t\t<license name=\""
- + XMLHelper.escape(licenses[i].getName()) + "\"" + lurl
- + "/>");
- }
- }
- if (md != null && md.getDescription() != null) {
- out.println("\t\t\t\t<description>" + md.getDescription()
- + "\t\t\t\t</description>");
- }
- outputMetadataArtifact(out, dep);
- outputEvictionInformation(report, out, dep);
- outputCallers(report, out, dep);
- outputArtifacts(report, out, dep);
- outputEasyAntModuleInfos(report, out, dep, easyAntReport);
- out.println("\t\t\t</revision>");
- }
-
- private void outputEasyAntModuleInfos(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
- out.println("\t\t\t\t<easyant>");
- // targets
- outputTargets(report, out, dep, easyAntReport);
- outputPhases(report, out, dep, easyAntReport);
- outputImportedModules(report, out, dep, easyAntReport);
- outputParameters(report, out, dep, easyAntReport);
- outputProperties(report, out, dep, easyAntReport);
- out.println("\t\t\t\t</easyant>");
-
- }
- private void outputProperties(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
- out.println("\t\t\t\t\t<properties>");
- Map<String, PropertyDescriptor> properties;
- if (displaySubProperties) {
- properties = easyAntReport.getAvailableProperties();
- } else {
- properties = easyAntReport.getPropertyDescriptors();
- }
-
- for (Entry<String, PropertyDescriptor> entry : properties.entrySet()) {
- PropertyDescriptor propertyDescriptor = entry.getValue();
-
- StringBuffer param= new StringBuffer();
- param.append("\t\t\t\t\t\t<property name=\"");
- param.append(propertyDescriptor.getName());
- param.append("\"");
- if (propertyDescriptor.getDescription() != null) {
- param.append(" description=\"");
- param.append(propertyDescriptor.getDescription());
- param.append("\"");
- }
- param.append(" required=\"");
- param.append(propertyDescriptor.isRequired());
- param.append("\"");
- if (propertyDescriptor.getDefaultValue() != null) {
- param.append(" default=\"");
- param.append(propertyDescriptor.getDefaultValue());
- param.append("\"");
- }
- if (propertyDescriptor.getValue() != null ) {
- param.append(" value=\"");
- param.append(propertyDescriptor.getValue());
- param.append("\"");
- }
- param.append("/>");
- out.println(param.toString());
-
- }
- out.println("\t\t\t\t\t</properties>");
- }
-
- private void outputParameters(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
- out.println("\t\t\t\t\t<parameters>");
- for (ParameterReport paramReport : easyAntReport.getParameterReports()) {
- StringBuffer param = new StringBuffer();
-
- if (ParameterType.PHASE.equals(paramReport.getType())) {
- param.append("\t\t\t\t\t\t<phase name=\"");
- param.append(paramReport.getName());
- param.append("\"");
- if (paramReport.getDescription() != null) {
- param.append(" description=\"");
- param.append(paramReport.getDescription());
- param.append("\"");
- }
- param.append("/>");
- } else if (ParameterType.PATH.equals(paramReport.getType())) {
- param.append("\t\t\t\t\t\t<path name=\"");
- param.append(paramReport.getName());
- param.append("\"");
- if (paramReport.getDescription() != null) {
- param.append(" description=\"");
- param.append(paramReport.getDescription());
- param.append("\"");
- }
- if (paramReport.isRequired()) {
- param.append(" required=\"");
- param.append(paramReport.isRequired());
- param.append("\"");
- }
- param.append("/>");
- }
- out.println(param);
- }
-
- out.println("\t\t\t\t\t</parameters>");
- }
-
- private void outputImportedModules(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
- out.println("\t\t\t\t\t<imports>");
- for (ImportedModuleReport importedModuleReport : easyAntReport.getImportedModuleReports()) {
- StringBuffer importedModule = new StringBuffer();
- try {
- ModuleRevisionId mrid = ModuleRevisionId
- .parse(importedModuleReport.getModuleMrid());
- importedModule.append("\t\t\t\t\t\t<import organisation=\"")
- .append(mrid.getOrganisation()).append("\" name=\"")
- .append(mrid.getName()).append("\" revision=\"")
- .append(mrid.getRevision()).append("\" type=\"")
- .append(importedModuleReport.getType()).append("\"");
-
- } catch (IllegalArgumentException e) {
- Message.debug("Unable to parse "
- + importedModuleReport.getModuleMrid());
- importedModule.append("\t\t\t\t\t\t<import organisation=\"")
- .append(importedModuleReport.getModuleMrid()).append(
- "\" name=\"").append("null").append(
- "\" revision=\"").append("null").append(
- "\" type=\"").append(
- importedModuleReport.getType()).append("\"");
-
- }
- importedModule.append(" mandatory=\"");
- importedModule.append(importedModuleReport.isMandatory());
- importedModule.append("\"");
- if (importedModuleReport.getAs() != null) {
- importedModule.append(" as=\"");
- importedModule.append(importedModuleReport.getAs());
- importedModule.append("\"");
- }
- importedModule.append(">");
- out.println(importedModule.toString());
- if (importedModuleReport.getEasyantReport() != null) {
- outputEasyAntModuleInfos(report, out, dep, importedModuleReport
- .getEasyantReport());
- }
- out.println("\t\t\t\t\t\t</import>");
-
- }
- out.println("\t\t\t\t\t</imports>");
-
- }
-
- private void outputPhases(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
- out.println("\t\t\t\t\t<phases>");
- for (PhaseReport phaseReport : easyAntReport.getPhaseReports()) {
- StringBuffer phase = new StringBuffer();
- phase.append("\t\t\t\t\t\t<phase name=\"").append(
- phaseReport.getName()).append("\"");
- if (phaseReport.getDescription() != null) {
- phase.append(" description=\"");
- phase.append(phaseReport.getDescription());
- phase.append("\"");
- }
- if (phaseReport.getDepends() != null) {
- phase.append(" depends=\"");
- phase.append(phaseReport.getDepends());
- phase.append("\"");
- }
- phase.append("/>");
- out.println(phase.toString());
- }
- out.println("\t\t\t\t\t</phases>");
- }
-
- private void outputTargets(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
- out.println("\t\t\t\t\t<targets>");
- for (TargetReport targetReport : easyAntReport.getTargetReports()) {
- StringBuffer target = new StringBuffer();
- target.append("\t\t\t\t\t\t<target name=\"").append(
- targetReport.getName()).append("\"");
- if (targetReport.getDescription() != null) {
- target.append(" description=\"");
- target.append(targetReport.getDescription());
- target.append("\"");
- }
- if (targetReport.getDepends() != null) {
- target.append(" depends=\"");
- target.append(targetReport.getDepends());
- target.append("\"");
- }
- if (targetReport.getIfCase() != null) {
- target.append(" if=\"");
- target.append(targetReport.getIfCase());
- target.append("\"");
- }
- if (targetReport.getPhase() != null) {
- target.append(" phase=\"");
- target.append(targetReport.getPhase());
- target.append("\"");
- }
- if (targetReport.getUnlessCase() != null) {
- target.append(" unless=\"");
- target.append(targetReport.getUnlessCase());
- target.append("\"");
- }
- target.append("/>");
- out.println(target.toString());
- }
- out.println("\t\t\t\t\t</targets>");
- }
-
- private void outputEvictionInformation(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep) {
- if (dep.isEvicted(report.getConfiguration())) {
- EvictionData ed = dep.getEvictedData(report.getConfiguration());
- Collection selected = ed.getSelected();
- if (selected != null) {
- for (Iterator it3 = selected.iterator(); it3.hasNext();) {
- IvyNode sel = (IvyNode) it3.next();
- out.println("\t\t\t\t<evicted-by rev=\""
- + XMLHelper.escape(sel.getResolvedId()
- .getRevision()) + "\"/>");
- }
- }
- }
- }
-
- private void outputMetadataArtifact(PrintWriter out, IvyNode dep) {
- if (dep.getModuleRevision() != null) {
- MetadataArtifactDownloadReport madr = dep.getModuleRevision()
- .getReport();
- out.print("\t\t\t\t<metadata-artifact");
- out.print(" status=\""
- + XMLHelper.escape(madr.getDownloadStatus().toString())
- + "\"");
- out.print(" details=\""
- + XMLHelper.escape(madr.getDownloadDetails()) + "\"");
- out.print(" size=\"" + madr.getSize() + "\"");
- out.print(" time=\"" + madr.getDownloadTimeMillis() + "\"");
- if (madr.getLocalFile() != null) {
- out.print(" location=\""
- + XMLHelper.escape(madr.getLocalFile()
- .getAbsolutePath()) + "\"");
- }
-
- out.print(" searched=\"" + madr.isSearched() + "\"");
- if (madr.getOriginalLocalFile() != null) {
- out.print(" original-local-location=\""
- + XMLHelper.escape(madr.getOriginalLocalFile()
- .getAbsolutePath()) + "\"");
- }
-
- ArtifactOrigin origin = madr.getArtifactOrigin();
- if (origin != null) {
- out.print(" origin-is-local=\""
- + String.valueOf(origin.isLocal()) + "\"");
- out.print(" origin-location=\""
- + XMLHelper.escape(origin.getLocation()) + "\"");
- }
- out.println("/>");
-
- }
- }
-
- private void outputCallers(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep) {
- Caller[] callers = dep.getCallers(report.getConfiguration());
- for (int i = 0; i < callers.length; i++) {
- StringBuffer callerDetails = new StringBuffer();
- Map callerExtraAttributes = callers[i].getDependencyDescriptor()
- .getExtraAttributes();
- for (Iterator iterator = callerExtraAttributes.keySet().iterator(); iterator
- .hasNext();) {
- String attName = (String) iterator.next();
- callerDetails.append(" extra-").append(attName).append("=\"")
- .append(
- XMLHelper.escape(callerExtraAttributes.get(
- attName).toString())).append("\"");
- }
-
- out.println("\t\t\t\t<caller organisation=\""
- + XMLHelper.escape(callers[i].getModuleRevisionId()
- .getOrganisation())
- + "\""
- + " name=\""
- + XMLHelper.escape(callers[i].getModuleRevisionId()
- .getName())
- + "\""
- + " conf=\""
- + XMLHelper.escape(toString(callers[i]
- .getCallerConfigurations()))
- + "\""
- + " rev=\""
- + XMLHelper.escape(callers[i].getAskedDependencyId(
- dep.getData()).getRevision())
- + "\""
- + " rev-constraint-default=\""
- + XMLHelper.escape(callers[i].getDependencyDescriptor()
- .getDependencyRevisionId().getRevision())
- + "\""
- + " rev-constraint-dynamic=\""
- + XMLHelper.escape(callers[i].getDependencyDescriptor()
- .getDynamicConstraintDependencyRevisionId()
- .getRevision())
- + "\""
- + " callerrev=\""
- + XMLHelper.escape(callers[i].getModuleRevisionId()
- .getRevision()) + "\"" + callerDetails + "/>");
- }
- }
-
- private void outputArtifacts(ConfigurationResolveReport report,
- PrintWriter out, IvyNode dep) {
- Map extraAttributes;
- ArtifactDownloadReport[] adr = report.getDownloadReports(dep
- .getResolvedId());
- out.println("\t\t\t\t<artifacts>");
- for (int i = 0; i < adr.length; i++) {
- out.print("\t\t\t\t\t<artifact name=\""
- + XMLHelper.escape(adr[i].getName()) + "\" type=\""
- + XMLHelper.escape(adr[i].getType()) + "\" ext=\""
- + XMLHelper.escape(adr[i].getExt()) + "\"");
- extraAttributes = adr[i].getArtifact().getExtraAttributes();
- for (Iterator iterator = extraAttributes.keySet().iterator(); iterator
- .hasNext();) {
- String attName = (String) iterator.next();
- out.print(" extra-"
- + attName
- + "=\""
- + XMLHelper.escape(extraAttributes.get(attName)
- .toString()) + "\"");
- }
- out.print(" status=\""
- + XMLHelper.escape(adr[i].getDownloadStatus().toString())
- + "\"");
- out.print(" details=\""
- + XMLHelper.escape(adr[i].getDownloadDetails()) + "\"");
- out.print(" size=\"" + adr[i].getSize() + "\"");
- out.print(" time=\"" + adr[i].getDownloadTimeMillis() + "\"");
- if (adr[i].getLocalFile() != null) {
- out.print(" location=\""
- + XMLHelper.escape(adr[i].getLocalFile()
- .getAbsolutePath()) + "\"");
- }
-
- ArtifactOrigin origin = adr[i].getArtifactOrigin();
- if (origin != null) {
- out.println(">");
- out.println("\t\t\t\t\t\t<origin-location is-local=\""
- + String.valueOf(origin.isLocal()) + "\""
- + " location=\""
- + XMLHelper.escape(origin.getLocation()) + "\"/>");
- out.println("\t\t\t\t\t</artifact>");
- } else {
- out.println("/>");
- }
- }
- out.println("\t\t\t\t</artifacts>");
- }
-
- private String toString(String[] strs) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < strs.length; i++) {
- buf.append(strs[i]);
- if (i + 1 < strs.length) {
- buf.append(", ");
- }
- }
- return XMLHelper.escape(buf.toString());
- }
-
- public void setDisplaySubProperties(boolean displaySubProperties) {
- this.displaySubProperties= displaySubProperties;
-
- }
+ public void output(ConfigurationResolveReport report, OutputStream stream,
+ EasyAntReport easyAntReport) {
+ output(report, new String[] { report.getConfiguration() }, stream,
+ easyAntReport);
+ }
+
+ public void output(ConfigurationResolveReport report, String[] confs,
+ OutputStream stream, EasyAntReport easyAntReport) {
+ OutputStreamWriter encodedOutStream;
+ try {
+ encodedOutStream = new OutputStreamWriter(stream, REPORT_ENCODING);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(REPORT_ENCODING
+ + " is not known on your jvm", e);
+ }
+ PrintWriter out = new PrintWriter(new BufferedWriter(encodedOutStream));
+ ModuleRevisionId mrid = report.getModuleDescriptor()
+ .getModuleRevisionId();
+ // out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
+ out.println("<?xml version=\"1.0\" encoding=\"" + REPORT_ENCODING
+ + "\"?>");
+ out
+ .println("<?xml-stylesheet type=\"text/xsl\" href=\"easyant-report.xsl\"?>");
+ out.println("<ivy-report version=\"1.0\">");
+ out.println(" <info");
+ out.println(" organisation=\""
+ + XMLHelper.escape(mrid.getOrganisation()) + "\"");
+ out.println(" module=\"" + XMLHelper.escape(mrid.getName()) + "\"");
+ out.println(" revision=\"" + XMLHelper.escape(mrid.getRevision())
+ + "\"");
+ if (mrid.getBranch() != null) {
+ out.println(" branch=\"" + XMLHelper.escape(mrid.getBranch())
+ + "\"");
+ }
+ Map extraAttributes = mrid.getExtraAttributes();
+ for (Iterator it = extraAttributes.entrySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Entry) it.next();
+ out.println(" extra-" + entry.getKey() + "=\""
+ + XMLHelper.escape(entry.getValue().toString()) + "\"");
+ }
+ out.println(" conf=\"" + XMLHelper.escape(report.getConfiguration())
+ + "\"");
+ out.println(" confs=\""
+ + XMLHelper.escape(StringUtils.join(confs, ", ")) + "\"");
+ out.println(" date=\"" + Ivy.DATE_FORMAT.format(report.getDate())
+ + "\"/>");
+
+ out.println(" <dependencies>");
+
+ // create a list of ModuleRevisionIds indicating the position for each
+ // dependency
+ List dependencies = new ArrayList(report.getModuleRevisionIds());
+
+ for (Iterator iter = report.getModuleIds().iterator(); iter.hasNext();) {
+ ModuleId mid = (ModuleId) iter.next();
+ out.println(" <module organisation=\""
+ + XMLHelper.escape(mid.getOrganisation()) + "\""
+ + " name=\"" + XMLHelper.escape(mid.getName()) + "\" >");
+ for (Iterator it2 = report.getNodes(mid).iterator(); it2.hasNext();) {
+ IvyNode dep = (IvyNode) it2.next();
+ ouputRevision(report, out, dependencies, dep, easyAntReport);
+ }
+ out.println(" </module>");
+ }
+ out.println(" </dependencies>");
+ out.println("</ivy-report>");
+ out.flush();
+ }
+
+ private void ouputRevision(ConfigurationResolveReport report,
+ PrintWriter out, List dependencies, IvyNode dep,
+ EasyAntReport easyAntReport) {
+ Map extraAttributes;
+ ModuleDescriptor md = null;
+ if (dep.getModuleRevision() != null) {
+ md = dep.getModuleRevision().getDescriptor();
+ }
+ StringBuffer details = new StringBuffer();
+ if (dep.isLoaded()) {
+ details.append(" status=\"");
+ details.append(XMLHelper.escape(dep.getDescriptor().getStatus()));
+ details.append("\" pubdate=\"");
+ details.append(Ivy.DATE_FORMAT
+ .format(new Date(dep.getPublication())));
+ details.append("\" resolver=\"");
+ details.append(XMLHelper.escape(dep.getModuleRevision()
+ .getResolver().getName()));
+ details.append("\" artresolver=\"");
+ details.append(XMLHelper.escape(dep.getModuleRevision()
+ .getArtifactResolver().getName()));
+ details.append("\"");
+ }
+ if (dep.isEvicted(report.getConfiguration())) {
+ EvictionData ed = dep.getEvictedData(report.getConfiguration());
+ if (ed.getConflictManager() != null) {
+ details.append(" evicted=\"").append(
+ XMLHelper.escape(ed.getConflictManager().toString()))
+ .append("\"");
+ } else {
+ details.append(" evicted=\"transitive\"");
+ }
+ details.append(" evicted-reason=\"").append(
+ XMLHelper.escape(ed.getDetail() == null ? "" : ed
+ .getDetail())).append("\"");
+ }
+ if (dep.hasProblem()) {
+ details.append(" error=\"").append(
+ XMLHelper.escape(dep.getProblem().getMessage())).append(
+ "\"");
+ }
+ if (md != null && md.getHomePage() != null) {
+ details.append(" homepage=\"").append(
+ XMLHelper.escape(md.getHomePage())).append("\"");
+ }
+ extraAttributes = md != null ? md.getExtraAttributes() : dep
+ .getResolvedId().getExtraAttributes();
+ for (Iterator iterator = extraAttributes.keySet().iterator(); iterator
+ .hasNext();) {
+ String attName = (String) iterator.next();
+ details.append(" extra-").append(attName).append("=\"").append(
+ XMLHelper.escape(extraAttributes.get(attName).toString()))
+ .append("\"");
+ }
+ String defaultValue = dep.getDescriptor() != null ? " default=\""
+ + dep.getDescriptor().isDefault() + "\"" : "";
+ int position = dependencies.indexOf(dep.getResolvedId());
+ out.println(" <revision name=\""
+ + XMLHelper.escape(dep.getResolvedId().getRevision())
+ + "\""
+ + (dep.getResolvedId().getBranch() == null ? "" : " branch=\""
+ + XMLHelper.escape(dep.getResolvedId().getBranch())
+ + "\"") + details + " downloaded=\""
+ + dep.isDownloaded() + "\"" + " searched=\"" + dep.isSearched()
+ + "\"" + defaultValue + " conf=\""
+ + toString(dep.getConfigurations(report.getConfiguration()))
+ + "\"" + " position=\"" + position + "\">");
+ if (md != null) {
+ License[] licenses = md.getLicenses();
+ for (int i = 0; i < licenses.length; i++) {
+ String lurl;
+ if (licenses[i].getUrl() != null) {
+ lurl = " url=\"" + XMLHelper.escape(licenses[i].getUrl())
+ + "\"";
+ } else {
+ lurl = "";
+ }
+ out.println(" <license name=\""
+ + XMLHelper.escape(licenses[i].getName()) + "\"" + lurl
+ + "/>");
+ }
+ }
+ if (md != null && md.getDescription() != null) {
+ out.println(" <description>" + md.getDescription()
+ + " </description>");
+ }
+ outputMetadataArtifact(out, dep);
+ outputEvictionInformation(report, out, dep);
+ outputCallers(report, out, dep);
+ outputArtifacts(report, out, dep);
+ outputEasyAntModuleInfos(report, out, dep, easyAntReport);
+ out.println(" </revision>");
+ }
+
+ private void outputEasyAntModuleInfos(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
+ out.println(" <easyant>");
+ // targets
+ outputTargets(report, out, dep, easyAntReport);
+ outputPhases(report, out, dep, easyAntReport);
+ outputImportedModules(report, out, dep, easyAntReport);
+ outputParameters(report, out, dep, easyAntReport);
+ outputProperties(report, out, dep, easyAntReport);
+ out.println(" </easyant>");
+
+ }
+ private void outputProperties(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
+ out.println(" <properties>");
+ Map<String, PropertyDescriptor> properties;
+ if (displaySubProperties) {
+ properties = easyAntReport.getAvailableProperties();
+ } else {
+ properties = easyAntReport.getPropertyDescriptors();
+ }
+
+ for (Entry<String, PropertyDescriptor> entry : properties.entrySet()) {
+ PropertyDescriptor propertyDescriptor = entry.getValue();
+
+ StringBuffer param= new StringBuffer();
+ param.append(" <property name=\"");
+ param.append(propertyDescriptor.getName());
+ param.append("\"");
+ if (propertyDescriptor.getDescription() != null) {
+ param.append(" description=\"");
+ param.append(propertyDescriptor.getDescription());
+ param.append("\"");
+ }
+ param.append(" required=\"");
+ param.append(propertyDescriptor.isRequired());
+ param.append("\"");
+ if (propertyDescriptor.getDefaultValue() != null) {
+ param.append(" default=\"");
+ param.append(propertyDescriptor.getDefaultValue());
+ param.append("\"");
+ }
+ if (propertyDescriptor.getValue() != null ) {
+ param.append(" value=\"");
+ param.append(propertyDescriptor.getValue());
+ param.append("\"");
+ }
+ param.append("/>");
+ out.println(param.toString());
+
+ }
+ out.println(" </properties>");
+ }
+
+ private void outputParameters(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
+ out.println(" <parameters>");
+ for (ParameterReport paramReport : easyAntReport.getParameterReports()) {
+ StringBuffer param = new StringBuffer();
+
+ if (ParameterType.PHASE.equals(paramReport.getType())) {
+ param.append(" <phase name=\"");
+ param.append(paramReport.getName());
+ param.append("\"");
+ if (paramReport.getDescription() != null) {
+ param.append(" description=\"");
+ param.append(paramReport.getDescription());
+ param.append("\"");
+ }
+ param.append("/>");
+ } else if (ParameterType.PATH.equals(paramReport.getType())) {
+ param.append(" <path name=\"");
+ param.append(paramReport.getName());
+ param.append("\"");
+ if (paramReport.getDescription() != null) {
+ param.append(" description=\"");
+ param.append(paramReport.getDescription());
+ param.append("\"");
+ }
+ if (paramReport.isRequired()) {
+ param.append(" required=\"");
+ param.append(paramReport.isRequired());
+ param.append("\"");
+ }
+ param.append("/>");
+ }
+ out.println(param);
+ }
+
+ out.println(" </parameters>");
+ }
+
+ private void outputImportedModules(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
+ out.println(" <imports>");
+ for (ImportedModuleReport importedModuleReport : easyAntReport.getImportedModuleReports()) {
+ StringBuffer importedModule = new StringBuffer();
+ try {
+ ModuleRevisionId mrid = ModuleRevisionId
+ .parse(importedModuleReport.getModuleMrid());
+ importedModule.append(" <import organisation=\"")
+ .append(mrid.getOrganisation()).append("\" name=\"")
+ .append(mrid.getName()).append("\" revision=\"")
+ .append(mrid.getRevision()).append("\" type=\"")
+ .append(importedModuleReport.getType()).append("\"");
+
+ } catch (IllegalArgumentException e) {
+ Message.debug("Unable to parse "
+ + importedModuleReport.getModuleMrid());
+ importedModule.append(" <import organisation=\"")
+ .append(importedModuleReport.getModuleMrid()).append(
+ "\" name=\"").append("null").append(
+ "\" revision=\"").append("null").append(
+ "\" type=\"").append(
+ importedModuleReport.getType()).append("\"");
+
+ }
+ importedModule.append(" mandatory=\"");
+ importedModule.append(importedModuleReport.isMandatory());
+ importedModule.append("\"");
+ if (importedModuleReport.getAs() != null) {
+ importedModule.append(" as=\"");
+ importedModule.append(importedModuleReport.getAs());
+ importedModule.append("\"");
+ }
+ importedModule.append(">");
+ out.println(importedModule.toString());
+ if (importedModuleReport.getEasyantReport() != null) {
+ outputEasyAntModuleInfos(report, out, dep, importedModuleReport
+ .getEasyantReport());
+ }
+ out.println(" </import>");
+
+ }
+ out.println(" </imports>");
+
+ }
+
+ private void outputPhases(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
+ out.println(" <phases>");
+ for (PhaseReport phaseReport : easyAntReport.getPhaseReports()) {
+ StringBuffer phase = new StringBuffer();
+ phase.append(" <phase name=\"").append(
+ phaseReport.getName()).append("\"");
+ if (phaseReport.getDescription() != null) {
+ phase.append(" description=\"");
+ phase.append(phaseReport.getDescription());
+ phase.append("\"");
+ }
+ if (phaseReport.getDepends() != null) {
+ phase.append(" depends=\"");
+ phase.append(phaseReport.getDepends());
+ phase.append("\"");
+ }
+ phase.append("/>");
+ out.println(phase.toString());
+ }
+ out.println(" </phases>");
+ }
+
+ private void outputTargets(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep, EasyAntReport easyAntReport) {
+ out.println(" <targets>");
+ for (TargetReport targetReport : easyAntReport.getTargetReports()) {
+ StringBuffer target = new StringBuffer();
+ target.append(" <target name=\"").append(
+ targetReport.getName()).append("\"");
+ if (targetReport.getDescription() != null) {
+ target.append(" description=\"");
+ target.append(targetReport.getDescription());
+ target.append("\"");
+ }
+ if (targetReport.getDepends() != null) {
+ target.append(" depends=\"");
+ target.append(targetReport.getDepends());
+ target.append("\"");
+ }
+ if (targetReport.getIfCase() != null) {
+ target.append(" if=\"");
+ target.append(targetReport.getIfCase());
+ target.append("\"");
+ }
+ if (targetReport.getPhase() != null) {
+ target.append(" phase=\"");
+ target.append(targetReport.getPhase());
+ target.append("\"");
+ }
+ if (targetReport.getUnlessCase() != null) {
+ target.append(" unless=\"");
+ target.append(targetReport.getUnlessCase());
+ target.append("\"");
+ }
+ target.append("/>");
+ out.println(target.toString());
+ }
+ out.println(" </targets>");
+ }
+
+ private void outputEvictionInformation(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep) {
+ if (dep.isEvicted(report.getConfiguration())) {
+ EvictionData ed = dep.getEvictedData(report.getConfiguration());
+ Collection selected = ed.getSelected();
+ if (selected != null) {
+ for (Iterator it3 = selected.iterator(); it3.hasNext();) {
+ IvyNode sel = (IvyNode) it3.next();
+ out.println(" <evicted-by rev=\""
+ + XMLHelper.escape(sel.getResolvedId()
+ .getRevision()) + "\"/>");
+ }
+ }
+ }
+ }
+
+ private void outputMetadataArtifact(PrintWriter out, IvyNode dep) {
+ if (dep.getModuleRevision() != null) {
+ MetadataArtifactDownloadReport madr = dep.getModuleRevision()
+ .getReport();
+ out.print(" <metadata-artifact");
+ out.print(" status=\""
+ + XMLHelper.escape(madr.getDownloadStatus().toString())
+ + "\"");
+ out.print(" details=\""
+ + XMLHelper.escape(madr.getDownloadDetails()) + "\"");
+ out.print(" size=\"" + madr.getSize() + "\"");
+ out.print(" time=\"" + madr.getDownloadTimeMillis() + "\"");
+ if (madr.getLocalFile() != null) {
+ out.print(" location=\""
+ + XMLHelper.escape(madr.getLocalFile()
+ .getAbsolutePath()) + "\"");
+ }
+
+ out.print(" searched=\"" + madr.isSearched() + "\"");
+ if (madr.getOriginalLocalFile() != null) {
+ out.print(" original-local-location=\""
+ + XMLHelper.escape(madr.getOriginalLocalFile()
+ .getAbsolutePath()) + "\"");
+ }
+
+ ArtifactOrigin origin = madr.getArtifactOrigin();
+ if (origin != null) {
+ out.print(" origin-is-local=\""
+ + String.valueOf(origin.isLocal()) + "\"");
+ out.print(" origin-location=\""
+ + XMLHelper.escape(origin.getLocation()) + "\"");
+ }
+ out.println("/>");
+
+ }
+ }
+
+ private void outputCallers(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep) {
+ Caller[] callers = dep.getCallers(report.getConfiguration());
+ for (int i = 0; i < callers.length; i++) {
+ StringBuffer callerDetails = new StringBuffer();
+ Map callerExtraAttributes = callers[i].getDependencyDescriptor()
+ .getExtraAttributes();
+ for (Iterator iterator = callerExtraAttributes.keySet().iterator(); iterator
+ .hasNext();) {
+ String attName = (String) iterator.next();
+ callerDetails.append(" extra-").append(attName).append("=\"")
+ .append(
+ XMLHelper.escape(callerExtraAttributes.get(
+ attName).toString())).append("\"");
+ }
+
+ out.println(" <caller organisation=\""
+ + XMLHelper.escape(callers[i].getModuleRevisionId()
+ .getOrganisation())
+ + "\""
+ + " name=\""
+ + XMLHelper.escape(callers[i].getModuleRevisionId()
+ .getName())
+ + "\""
+ + " conf=\""
+ + XMLHelper.escape(toString(callers[i]
+ .getCallerConfigurations()))
+ + "\""
+ + " rev=\""
+ + XMLHelper.escape(callers[i].getAskedDependencyId(
+ dep.getData()).getRevision())
+ + "\""
+ + " rev-constraint-default=\""
+ + XMLHelper.escape(callers[i].getDependencyDescriptor()
+ .getDependencyRevisionId().getRevision())
+ + "\""
+ + " rev-constraint-dynamic=\""
+ + XMLHelper.escape(callers[i].getDependencyDescriptor()
+ .getDynamicConstraintDependencyRevisionId()
+ .getRevision())
+ + "\""
+ + " callerrev=\""
+ + XMLHelper.escape(callers[i].getModuleRevisionId()
+ .getRevision()) + "\"" + callerDetails + "/>");
+ }
+ }
+
+ private void outputArtifacts(ConfigurationResolveReport report,
+ PrintWriter out, IvyNode dep) {
+ Map extraAttributes;
+ ArtifactDownloadReport[] adr = report.getDownloadReports(dep
+ .getResolvedId());
+ out.println(" <artifacts>");
+ for (int i = 0; i < adr.length; i++) {
+ out.print(" <artifact name=\""
+ + XMLHelper.escape(adr[i].getName()) + "\" type=\""
+ + XMLHelper.escape(adr[i].getType()) + "\" ext=\""
+ + XMLHelper.escape(adr[i].getExt()) + "\"");
+ extraAttributes = adr[i].getArtifact().getExtraAttributes();
+ for (Iterator iterator = extraAttributes.keySet().iterator(); iterator
+ .hasNext();) {
+ String attName = (String) iterator.next();
+ out.print(" extra-"
+ + attName
+ + "=\""
+ + XMLHelper.escape(extraAttributes.get(attName)
+ .toString()) + "\"");
+ }
+ out.print(" status=\""
+ + XMLHelper.escape(adr[i].getDownloadStatus().toString())
+ + "\"");
+ out.print(" details=\""
+ + XMLHelper.escape(adr[i].getDownloadDetails()) + "\"");
+ out.print(" size=\"" + adr[i].getSize() + "\"");
+ out.print(" time=\"" + adr[i].getDownloadTimeMillis() + "\"");
+ if (adr[i].getLocalFile() != null) {
+ out.print(" location=\""
+ + XMLHelper.escape(adr[i].getLocalFile()
+ .getAbsolutePath()) + "\"");
+ }
+
+ ArtifactOrigin origin = adr[i].getArtifactOrigin();
+ if (origin != null) {
+ out.println(">");
+ out.println(" <origin-location is-local=\""
+ + String.valueOf(origin.isLocal()) + "\""
+ + " location=\""
+ + XMLHelper.escape(origin.getLocation()) + "\"/>");
+ out.println(" </artifact>");
+ } else {
+ out.println("/>");
+ }
+ }
+ out.println(" </artifacts>");
+ }
+
+ private String toString(String[] strs) {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < strs.length; i++) {
+ buf.append(strs[i]);
+ if (i + 1 < strs.length) {
+ buf.append(", ");
+ }
+ }
+ return XMLHelper.escape(buf.toString());
+ }
+
+ public void setDisplaySubProperties(boolean displaySubProperties) {
+ this.displaySubProperties= displaySubProperties;
+
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XmlEasyAntReportOutputter.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XmlEasyAntReportOutputter.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XmlEasyAntReportOutputter.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XmlEasyAntReportOutputter.java Tue Feb 22 15:55:55 2011
@@ -35,7 +35,7 @@ import org.apache.ivy.util.Message;
* resolution cache.
*/
public class XmlEasyAntReportOutputter {
-
+
public static final String CONSOLE = "console";
public static final String XML = "xml";
@@ -58,7 +58,7 @@ public class XmlEasyAntReportOutputter {
public void output(ConfigurationResolveReport report, String resolveId,
String[] confs, ResolutionCacheManager cacheMgr, EasyAntReport easyAntReport , boolean displaySubProperties)
throws IOException {
- writer.setDisplaySubProperties(displaySubProperties);
+ writer.setDisplaySubProperties(displaySubProperties);
File reportFile = cacheMgr.getConfigurationResolveReportInCache(
resolveId, report.getConfiguration());
File reportParentDir = reportFile.getParentFile();
@@ -82,4 +82,3 @@ public class XmlEasyAntReportOutputter {
}
}
}
-
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java Tue Feb 22 15:55:55 2011
@@ -25,163 +25,163 @@ import org.apache.ivy.core.module.id.Mod
public interface PluginService {
- /**
- * Generate an easyantReport for a given moduleRevisionID
- *
- * @param moduleRevisionId
- * a given moduleRevisionID
- * @return an easyantReport an easyantReport
- * @throws Exception
- */
- EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId)
- throws Exception;
-
- /**
- * Generate an easyantReport for a given string representing a plugin
- * moduleRevisionID mrid should be with the following format :
- * organisation#moduleName;revision If no organisation is specified, this
- * method will use the default one, then you could use the shorter form like
- * myPlugin;0.1
- *
- * @param moduleRevisionId
- * a given moduleRevisionID
- * @return an easyantReport an easyantReport
- * @throws Exception
- */
- EasyAntReport getPluginInfo(String moduleRevisionId) throws Exception;
-
- /**
- * Generate an easyantReport for a given string representing a buildtype
- * moduleRevisionID mrid should be with the following format :
- * organisation#moduleName;revision If no organisation is specified, this
- * method will use the default one, then you could use the shorter form like
- * myPlugin;0.1
- *
- * @param moduleRevisionId
- * a given moduleRevisionID
- * @return an easyantReport an easyantReport
- * @throws Exception
- */
- EasyAntReport getBuildTypeInfo(String moduleRevisionId) throws Exception;
-
- /**
- * Generate an easyantReport for a given moduleRevisionID
- *
- * @param moduleRevisionId
- * a given moduleRevisionID
- * @param conf
- * a configuration name
- * @return an easyantReport an easyantReport
- * @throws Exception
- */
- EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId, String conf)
- throws Exception;
-
- /**
- * Return an array of moduleRevisionId that match with given criteria.
- * Equivalent to {@link #search(String, String, String, String, String, String)
- * search(organisation, moduleName, null, null, PatternMatcher.EXACT_OR_REGEXP, null)}
- *
- * @param organisation
- * the organisation name
- * @param moduleName
- * the module name
- * @return an array of moduleRevisionId
- * @throws Exception
- * @see org.apache.ivy.plugins.matcher.PatternMatcher
- */
- ModuleRevisionId[] search(String organisation, String moduleName)
- throws Exception;
-
- /**
- * Return an array of moduleRevisionId that match with given criteria. Null values are unconstrained
- * (any value is matched).
- *
- * @param organisation
- * the organisation name as it appears in the module descriptor
- * @param moduleName
- * the module name as it appears in the module descriptor
- * @param revision
- * the revision as it appears in the module descriptor
- * @param branch
- * the branch as it appears in the module descriptor
- * @param matcher
- * an Ivy pattern matcher types, see {@link org.apache.ivy.plugins.matcher.PatternMatcher}
+ /**
+ * Generate an easyantReport for a given moduleRevisionID
+ *
+ * @param moduleRevisionId
+ * a given moduleRevisionID
+ * @return an easyantReport an easyantReport
+ * @throws Exception
+ */
+ EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId)
+ throws Exception;
+
+ /**
+ * Generate an easyantReport for a given string representing a plugin
+ * moduleRevisionID mrid should be with the following format :
+ * organisation#moduleName;revision If no organisation is specified, this
+ * method will use the default one, then you could use the shorter form like
+ * myPlugin;0.1
+ *
+ * @param moduleRevisionId
+ * a given moduleRevisionID
+ * @return an easyantReport an easyantReport
+ * @throws Exception
+ */
+ EasyAntReport getPluginInfo(String moduleRevisionId) throws Exception;
+
+ /**
+ * Generate an easyantReport for a given string representing a buildtype
+ * moduleRevisionID mrid should be with the following format :
+ * organisation#moduleName;revision If no organisation is specified, this
+ * method will use the default one, then you could use the shorter form like
+ * myPlugin;0.1
+ *
+ * @param moduleRevisionId
+ * a given moduleRevisionID
+ * @return an easyantReport an easyantReport
+ * @throws Exception
+ */
+ EasyAntReport getBuildTypeInfo(String moduleRevisionId) throws Exception;
+
+ /**
+ * Generate an easyantReport for a given moduleRevisionID
+ *
+ * @param moduleRevisionId
+ * a given moduleRevisionID
+ * @param conf
+ * a configuration name
+ * @return an easyantReport an easyantReport
+ * @throws Exception
+ */
+ EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId, String conf)
+ throws Exception;
+
+ /**
+ * Return an array of moduleRevisionId that match with given criteria.
+ * Equivalent to {@link #search(String, String, String, String, String, String)
+ * search(organisation, moduleName, null, null, PatternMatcher.EXACT_OR_REGEXP, null)}
+ *
+ * @param organisation
+ * the organisation name
+ * @param moduleName
+ * the module name
+ * @return an array of moduleRevisionId
+ * @throws Exception
+ * @see org.apache.ivy.plugins.matcher.PatternMatcher
+ */
+ ModuleRevisionId[] search(String organisation, String moduleName)
+ throws Exception;
+
+ /**
+ * Return an array of moduleRevisionId that match with given criteria. Null values are unconstrained
+ * (any value is matched).
+ *
+ * @param organisation
+ * the organisation name as it appears in the module descriptor
+ * @param moduleName
+ * the module name as it appears in the module descriptor
+ * @param revision
+ * the revision as it appears in the module descriptor
+ * @param branch
+ * the branch as it appears in the module descriptor
+ * @param matcher
+ * an Ivy pattern matcher types, see {@link org.apache.ivy.plugins.matcher.PatternMatcher}
* @param resolver
- * the name of the Ivy resolver. null matches the default resolver; "*" searches all resolvers.
- * @return an array of matching moduleRevisionId
- * @throws Exception
- */
- ModuleRevisionId[] search(String organisation, String moduleName,
- String revision, String branch, String matcher, String resolver) throws Exception;
-
- /**
- * Generate an easyantReport for a given moduleDescriptor. Using this report
- * you should have all properties / plugins / targets loaded in your module
- * descriptor
- *
- * @param moduleDescriptor
- * a file that represent the module descriptor
- * @return an easyantReport for a given moduleDescriptor
- * @throws Exception
- */
- EasyAntReport generateEasyAntReport(File moduleDescriptor) throws Exception;
-
- /**
- * Return the EasyAnt model containing all data of the module described in
- * given file.
- *
- * @param moduleDescriptor
- * a file that represent the module descriptor
- * @return an EasyAnt module descriptor
- * @throws Exception
- */
- EasyAntModuleDescriptor getEasyAntModuleDescriptor(File moduleDescriptor)
- throws Exception;
-
- /**
- * Return an array of string representing the fully qualified named matching
- * with given criterias
- *
- * @param organisation
- * the organisation name
- * @param moduleName
- * the module name
- * @return an array of moduleRevisionId
- * @throws Exception
- */
- String[] searchModule(String organisation, String moduleName)
- throws Exception;
-
- /**
- * Return the description of a module descriptor
- * Useful for IDE's integration
- * @param mrid the module revision id to check
- * @return a string representing the description of the module descriptor
- */
- String getDescription(ModuleRevisionId mrid);
-
- /**
- * Return the description of a module descriptor
- * Useful for IDE's integration
- * The module revision id parameter should be with the following format
- * organisation#moduleName;revision
- * If no organisation is specified, this method will use the default one,
- * then you could use the shorter form like myPlugin;0.1
- * @param moduleRevisionId a string representing a buildtype
- * @return a string representing the description of the module descriptor
- */
- String getPluginDescription(String moduleRevisionId);
-
- /**
- * Return the description of a module descriptor
- * Useful for IDE's integration
- * The module revision id parameter should be with the following format
- * organisation#moduleName;revision
- * If no organisation is specified, this method will use the default one,
- * then you could use the shorter form like myBuildType;0.1
- * @param moduleRevisionId a string representing a buildtype
- * @return a string representing the description of the module descriptor
- */
- public String getBuildTypeDescription(String moduleRevisionId);
+ * the name of the Ivy resolver. null matches the default resolver; "*" searches all resolvers.
+ * @return an array of matching moduleRevisionId
+ * @throws Exception
+ */
+ ModuleRevisionId[] search(String organisation, String moduleName,
+ String revision, String branch, String matcher, String resolver) throws Exception;
+
+ /**
+ * Generate an easyantReport for a given moduleDescriptor. Using this report
+ * you should have all properties / plugins / targets loaded in your module
+ * descriptor
+ *
+ * @param moduleDescriptor
+ * a file that represent the module descriptor
+ * @return an easyantReport for a given moduleDescriptor
+ * @throws Exception
+ */
+ EasyAntReport generateEasyAntReport(File moduleDescriptor) throws Exception;
+
+ /**
+ * Return the EasyAnt model containing all data of the module described in
+ * given file.
+ *
+ * @param moduleDescriptor
+ * a file that represent the module descriptor
+ * @return an EasyAnt module descriptor
+ * @throws Exception
+ */
+ EasyAntModuleDescriptor getEasyAntModuleDescriptor(File moduleDescriptor)
+ throws Exception;
+
+ /**
+ * Return an array of string representing the fully qualified named matching
+ * with given criterias
+ *
+ * @param organisation
+ * the organisation name
+ * @param moduleName
+ * the module name
+ * @return an array of moduleRevisionId
+ * @throws Exception
+ */
+ String[] searchModule(String organisation, String moduleName)
+ throws Exception;
+
+ /**
+ * Return the description of a module descriptor
+ * Useful for IDE's integration
+ * @param mrid the module revision id to check
+ * @return a string representing the description of the module descriptor
+ */
+ String getDescription(ModuleRevisionId mrid);
+
+ /**
+ * Return the description of a module descriptor
+ * Useful for IDE's integration
+ * The module revision id parameter should be with the following format
+ * organisation#moduleName;revision
+ * If no organisation is specified, this method will use the default one,
+ * then you could use the shorter form like myPlugin;0.1
+ * @param moduleRevisionId a string representing a buildtype
+ * @return a string representing the description of the module descriptor
+ */
+ String getPluginDescription(String moduleRevisionId);
+
+ /**
+ * Return the description of a module descriptor
+ * Useful for IDE's integration
+ * The module revision id parameter should be with the following format
+ * organisation#moduleName;revision
+ * If no organisation is specified, this method will use the default one,
+ * then you could use the shorter form like myBuildType;0.1
+ * @param moduleRevisionId a string representing a buildtype
+ * @return a string representing the description of the module descriptor
+ */
+ public String getBuildTypeDescription(String moduleRevisionId);
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java Tue Feb 22 15:55:55 2011
@@ -45,239 +45,239 @@ import org.xml.sax.SAXException;
public class DefaultPluginServiceImpl implements PluginService {
- private final EasyAntModuleDescriptorParser parser;
+ private final EasyAntModuleDescriptorParser parser;
- private final Ivy ivyInstance;
+ private final Ivy ivyInstance;
- /**
- * This is the default constructor, the IvyContext should be the IvyContext
- * configured to the easyant ivy instance
- * @param ivyInstance the easyant ivy instance
- */
- public DefaultPluginServiceImpl(final Ivy ivyInstance) {
- this(ivyInstance, new DefaultEasyAntXmlModuleDescriptorParser());
- }
-
- /**
- * A custom constructor if you want to specify your own parser /
- * configuration service, you should use this constructor
- * the IvyContext should be the IvyContext
- * configured to the easyant ivy instance
- * @param ivyInstance the easyant ivy instance
- * @param parser
- * a valid easyantModuleDescriptor
- */
- public DefaultPluginServiceImpl(final Ivy ivyInstance,
- EasyAntModuleDescriptorParser parser) {
- this.ivyInstance = ivyInstance;
- if (parser == null) {
- throw new IllegalArgumentException(
- "You must set a valid easyant module descriptor parser");
- }
- this.parser = parser;
- ModuleDescriptorParserRegistry.getInstance().addParser(parser);
- }
-
- public EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId,
- String conf) throws Exception {
- try {
-
- IvyContext.pushNewContext().setIvy(ivyInstance);
- EasyAntReport eaReport = EasyAntReportModuleParser.parseEasyAntModule(
- moduleRevisionId, conf);
-
- IvyContext.popContext();
- return eaReport;
- } catch (SAXException e) {
- throw new Exception("Impossible to parse " + moduleRevisionId, e);
- }
- }
-
- public EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId)
- throws Exception {
- return getPluginInfo(moduleRevisionId, "default");
- }
-
- public EasyAntReport getPluginInfo(String moduleRevisionId)
- throws Exception {
- String mrid = moduleRevisionId;
- if (!mrid.matches(".*#.*")) {
- Message.debug("No organisation specified for plugin " + mrid
- + " using the default one");
- mrid = EasyAntConstants.EASYANT_PLUGIN_ORGANISATION + "#" + mrid;
- }
- ModuleRevisionId module = ModuleRevisionId.parse(mrid);
- return getPluginInfo(module);
- }
-
- public EasyAntReport getBuildTypeInfo(String moduleRevisionId)
- throws Exception {
- String mrid = moduleRevisionId;
- if (!mrid.matches(".*#.*")) {
- Message.debug("No organisation specified for buildtype " + mrid
- + " using the default one");
- mrid = EasyAntConstants.EASYANT_BUILDTYPES_ORGANISATION + "#"
- + mrid;
- }
- ModuleRevisionId module = ModuleRevisionId.parse(mrid);
- return getPluginInfo(module);
- }
-
- public EasyAntModuleDescriptor getEasyAntModuleDescriptor(
- File moduleDescriptor) throws Exception {
- if (moduleDescriptor == null)
- throw new Exception("moduleDescriptor cannot be null");
- if (!moduleDescriptor.exists()) {
- throw new Exception(
- "imposible to find the specified module descriptor"
- + moduleDescriptor.getAbsolutePath());
- }
- IvyContext.pushNewContext().setIvy(ivyInstance);
- // First we need to parse the specified file to retrieve all the easyant
- // stuff
- parser.parseDescriptor(ivyInstance.getSettings(),
- moduleDescriptor.toURL(), new URLResource(moduleDescriptor
- .toURL()), true);
- EasyAntModuleDescriptor md = parser.getEasyAntModuleDescriptor();
- IvyContext.popContext();
- return md;
- }
-
- public EasyAntReport generateEasyAntReport(File moduleDescriptor)
- throws Exception {
- EasyAntReport eaReport = new EasyAntReport();
- try {
- EasyAntModuleDescriptor md = getEasyAntModuleDescriptor(moduleDescriptor);
-
- // Then we can Store properties
- for (Iterator<PropertyDescriptor> iterator = md.getProperties()
- .values().iterator(); iterator.hasNext();) {
- PropertyDescriptor property = iterator.next();
- eaReport.addPropertyDescriptor(property.getName(), property);
- }
-
- // Store infos on the buildtype
- if (md.getBuildType() != null) {
- ImportedModuleReport buildType = new ImportedModuleReport();
- buildType.setModuleMrid(md.getBuildType());
- buildType.setEasyantReport(getPluginInfo(ModuleRevisionId
- .parse(md.getBuildType())));
- eaReport.addImportedModuleReport(buildType);
- // Store infos on plugins
- for (Iterator iterator = md.getPlugins().iterator(); iterator
- .hasNext();) {
- PluginDescriptor plugin = (PluginDescriptor) iterator
- .next();
- ImportedModuleReport pluginReport = new ImportedModuleReport();
- pluginReport.setModuleMrid(plugin.getMrid());
- pluginReport.setAs(plugin.getAs());
- pluginReport.setType(plugin.getMode());
- pluginReport
- .setEasyantReport(getPluginInfo(ModuleRevisionId
- .parse(plugin.getMrid())));
- eaReport.addImportedModuleReport(pluginReport);
- }
- }
-
- } catch (Exception e) {
- throw new Exception("problem while parsing Ivy module file: "
- + e.getMessage(), e);
- }
- return eaReport;
- }
-
- public ModuleRevisionId[] search(String organisation, String moduleName,
- String revision, String branch, String matcher, String resolver) throws Exception {
- IvySettings settings = ivyInstance.getSettings();
-
- if (moduleName == null && PatternMatcher.EXACT.equals(matcher)) {
- throw new Exception(
- "no module name provided for ivy repository graph task: "
- + "It can either be set explicitely via the attribute 'module' or "
- + "via 'ivy.module' property or a prior call to <resolve/>");
- } else if (moduleName == null && !PatternMatcher.EXACT.equals(matcher)) {
- moduleName = PatternMatcher.ANY_EXPRESSION;
- }
- ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation,
- moduleName, revision);
-
- ModuleRevisionId criteria = null;
-
- if ((revision == null) || settings.getVersionMatcher().isDynamic(mrid)) {
- criteria = new ModuleRevisionId(new ModuleId(organisation,
- moduleName), branch, "*");
- } else {
- criteria = new ModuleRevisionId(new ModuleId(organisation,
- moduleName), branch, revision);
- }
-
- PatternMatcher patternMatcher = settings.getMatcher(matcher);
- if ("*".equals(resolver)) {
- //search in all resolvers. this can be quite slow for complex repository configurations
- //with ChainResolvers, since resolvers in chains will be searched multiple times.
- return ivyInstance.listModules(criteria, patternMatcher);
- } else {
- //limit search to the specified resolver.
- DependencyResolver dependencyResolver =
- resolver == null ? settings.getDefaultResolver()
- : settings.getResolver(resolver);
- if (dependencyResolver == null) {
- throw new IllegalArgumentException("Unknown dependency resolver for search: " + resolver);
- }
-
- ivyInstance.pushContext();
- try {
- return ivyInstance.getSearchEngine().listModules(dependencyResolver, criteria, patternMatcher);
- } finally {
- ivyInstance.popContext();
- }
- }
- }
-
- public ModuleRevisionId[] search(String organisation, String moduleName)
- throws Exception {
- return search(organisation, moduleName, null, null,
- PatternMatcher.EXACT_OR_REGEXP, null);
- }
-
- public String[] searchModule(String organisation, String moduleName)
- throws Exception {
- ModuleRevisionId[] mrids = search(organisation, moduleName);
- String[] result = new String[mrids.length];
- for (int i = 0; i < mrids.length; i++) {
- result[i] = mrids[i].toString();
- }
- return result;
- }
-
- public String getDescription(ModuleRevisionId mrid) {
- ResolvedModuleRevision rmr = ivyInstance.findModule(mrid);
- return rmr.getDescriptor().getDescription();
- }
-
-
- public String getPluginDescription(String moduleRevisionId) {
- String mrid = moduleRevisionId;
- if (!mrid.matches(".*#.*")) {
- Message.debug("No organisation specified for plugin " + mrid
- + " using the default one");
- mrid = EasyAntConstants.EASYANT_PLUGIN_ORGANISATION + "#" + mrid;
- }
- ModuleRevisionId module = ModuleRevisionId.parse(mrid);
-
- return getDescription(module);
- }
-
- public String getBuildTypeDescription(String moduleRevisionId) {
- String mrid = moduleRevisionId;
- if (!mrid.matches(".*#.*")) {
- Message.debug("No organisation specified for buildtype " + mrid
- + " using the default one");
- mrid = EasyAntConstants.EASYANT_BUILDTYPES_ORGANISATION + "#" + mrid;
- }
- ModuleRevisionId module = ModuleRevisionId.parse(mrid);
+ /**
+ * This is the default constructor, the IvyContext should be the IvyContext
+ * configured to the easyant ivy instance
+ * @param ivyInstance the easyant ivy instance
+ */
+ public DefaultPluginServiceImpl(final Ivy ivyInstance) {
+ this(ivyInstance, new DefaultEasyAntXmlModuleDescriptorParser());
+ }
+
+ /**
+ * A custom constructor if you want to specify your own parser /
+ * configuration service, you should use this constructor
+ * the IvyContext should be the IvyContext
+ * configured to the easyant ivy instance
+ * @param ivyInstance the easyant ivy instance
+ * @param parser
+ * a valid easyantModuleDescriptor
+ */
+ public DefaultPluginServiceImpl(final Ivy ivyInstance,
+ EasyAntModuleDescriptorParser parser) {
+ this.ivyInstance = ivyInstance;
+ if (parser == null) {
+ throw new IllegalArgumentException(
+ "You must set a valid easyant module descriptor parser");
+ }
+ this.parser = parser;
+ ModuleDescriptorParserRegistry.getInstance().addParser(parser);
+ }
+
+ public EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId,
+ String conf) throws Exception {
+ try {
+
+ IvyContext.pushNewContext().setIvy(ivyInstance);
+ EasyAntReport eaReport = EasyAntReportModuleParser.parseEasyAntModule(
+ moduleRevisionId, conf);
+
+ IvyContext.popContext();
+ return eaReport;
+ } catch (SAXException e) {
+ throw new Exception("Impossible to parse " + moduleRevisionId, e);
+ }
+ }
+
+ public EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId)
+ throws Exception {
+ return getPluginInfo(moduleRevisionId, "default");
+ }
+
+ public EasyAntReport getPluginInfo(String moduleRevisionId)
+ throws Exception {
+ String mrid = moduleRevisionId;
+ if (!mrid.matches(".*#.*")) {
+ Message.debug("No organisation specified for plugin " + mrid
+ + " using the default one");
+ mrid = EasyAntConstants.EASYANT_PLUGIN_ORGANISATION + "#" + mrid;
+ }
+ ModuleRevisionId module = ModuleRevisionId.parse(mrid);
+ return getPluginInfo(module);
+ }
+
+ public EasyAntReport getBuildTypeInfo(String moduleRevisionId)
+ throws Exception {
+ String mrid = moduleRevisionId;
+ if (!mrid.matches(".*#.*")) {
+ Message.debug("No organisation specified for buildtype " + mrid
+ + " using the default one");
+ mrid = EasyAntConstants.EASYANT_BUILDTYPES_ORGANISATION + "#"
+ + mrid;
+ }
+ ModuleRevisionId module = ModuleRevisionId.parse(mrid);
+ return getPluginInfo(module);
+ }
+
+ public EasyAntModuleDescriptor getEasyAntModuleDescriptor(
+ File moduleDescriptor) throws Exception {
+ if (moduleDescriptor == null)
+ throw new Exception("moduleDescriptor cannot be null");
+ if (!moduleDescriptor.exists()) {
+ throw new Exception(
+ "imposible to find the specified module descriptor"
+ + moduleDescriptor.getAbsolutePath());
+ }
+ IvyContext.pushNewContext().setIvy(ivyInstance);
+ // First we need to parse the specified file to retrieve all the easyant
+ // stuff
+ parser.parseDescriptor(ivyInstance.getSettings(),
+ moduleDescriptor.toURL(), new URLResource(moduleDescriptor
+ .toURL()), true);
+ EasyAntModuleDescriptor md = parser.getEasyAntModuleDescriptor();
+ IvyContext.popContext();
+ return md;
+ }
+
+ public EasyAntReport generateEasyAntReport(File moduleDescriptor)
+ throws Exception {
+ EasyAntReport eaReport = new EasyAntReport();
+ try {
+ EasyAntModuleDescriptor md = getEasyAntModuleDescriptor(moduleDescriptor);
+
+ // Then we can Store properties
+ for (Iterator<PropertyDescriptor> iterator = md.getProperties()
+ .values().iterator(); iterator.hasNext();) {
+ PropertyDescriptor property = iterator.next();
+ eaReport.addPropertyDescriptor(property.getName(), property);
+ }
+
+ // Store infos on the buildtype
+ if (md.getBuildType() != null) {
+ ImportedModuleReport buildType = new ImportedModuleReport();
+ buildType.setModuleMrid(md.getBuildType());
+ buildType.setEasyantReport(getPluginInfo(ModuleRevisionId
+ .parse(md.getBuildType())));
+ eaReport.addImportedModuleReport(buildType);
+ // Store infos on plugins
+ for (Iterator iterator = md.getPlugins().iterator(); iterator
+ .hasNext();) {
+ PluginDescriptor plugin = (PluginDescriptor) iterator
+ .next();
+ ImportedModuleReport pluginReport = new ImportedModuleReport();
+ pluginReport.setModuleMrid(plugin.getMrid());
+ pluginReport.setAs(plugin.getAs());
+ pluginReport.setType(plugin.getMode());
+ pluginReport
+ .setEasyantReport(getPluginInfo(ModuleRevisionId
+ .parse(plugin.getMrid())));
+ eaReport.addImportedModuleReport(pluginReport);
+ }
+ }
+
+ } catch (Exception e) {
+ throw new Exception("problem while parsing Ivy module file: "
+ + e.getMessage(), e);
+ }
+ return eaReport;
+ }
+
+ public ModuleRevisionId[] search(String organisation, String moduleName,
+ String revision, String branch, String matcher, String resolver) throws Exception {
+ IvySettings settings = ivyInstance.getSettings();
+
+ if (moduleName == null && PatternMatcher.EXACT.equals(matcher)) {
+ throw new Exception(
+ "no module name provided for ivy repository graph task: "
+ + "It can either be set explicitely via the attribute 'module' or "
+ + "via 'ivy.module' property or a prior call to <resolve/>");
+ } else if (moduleName == null && !PatternMatcher.EXACT.equals(matcher)) {
+ moduleName = PatternMatcher.ANY_EXPRESSION;
+ }
+ ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation,
+ moduleName, revision);
+
+ ModuleRevisionId criteria = null;
+
+ if ((revision == null) || settings.getVersionMatcher().isDynamic(mrid)) {
+ criteria = new ModuleRevisionId(new ModuleId(organisation,
+ moduleName), branch, "*");
+ } else {
+ criteria = new ModuleRevisionId(new ModuleId(organisation,
+ moduleName), branch, revision);
+ }
+
+ PatternMatcher patternMatcher = settings.getMatcher(matcher);
+ if ("*".equals(resolver)) {
+ //search in all resolvers. this can be quite slow for complex repository configurations
+ //with ChainResolvers, since resolvers in chains will be searched multiple times.
+ return ivyInstance.listModules(criteria, patternMatcher);
+ } else {
+ //limit search to the specified resolver.
+ DependencyResolver dependencyResolver =
+ resolver == null ? settings.getDefaultResolver()
+ : settings.getResolver(resolver);
+ if (dependencyResolver == null) {
+ throw new IllegalArgumentException("Unknown dependency resolver for search: " + resolver);
+ }
+
+ ivyInstance.pushContext();
+ try {
+ return ivyInstance.getSearchEngine().listModules(dependencyResolver, criteria, patternMatcher);
+ } finally {
+ ivyInstance.popContext();
+ }
+ }
+ }
+
+ public ModuleRevisionId[] search(String organisation, String moduleName)
+ throws Exception {
+ return search(organisation, moduleName, null, null,
+ PatternMatcher.EXACT_OR_REGEXP, null);
+ }
+
+ public String[] searchModule(String organisation, String moduleName)
+ throws Exception {
+ ModuleRevisionId[] mrids = search(organisation, moduleName);
+ String[] result = new String[mrids.length];
+ for (int i = 0; i < mrids.length; i++) {
+ result[i] = mrids[i].toString();
+ }
+ return result;
+ }
+
+ public String getDescription(ModuleRevisionId mrid) {
+ ResolvedModuleRevision rmr = ivyInstance.findModule(mrid);
+ return rmr.getDescriptor().getDescription();
+ }
+
+
+ public String getPluginDescription(String moduleRevisionId) {
+ String mrid = moduleRevisionId;
+ if (!mrid.matches(".*#.*")) {
+ Message.debug("No organisation specified for plugin " + mrid
+ + " using the default one");
+ mrid = EasyAntConstants.EASYANT_PLUGIN_ORGANISATION + "#" + mrid;
+ }
+ ModuleRevisionId module = ModuleRevisionId.parse(mrid);
+
+ return getDescription(module);
+ }
+
+ public String getBuildTypeDescription(String moduleRevisionId) {
+ String mrid = moduleRevisionId;
+ if (!mrid.matches(".*#.*")) {
+ Message.debug("No organisation specified for buildtype " + mrid
+ + " using the default one");
+ mrid = EasyAntConstants.EASYANT_BUILDTYPES_ORGANISATION + "#" + mrid;
+ }
+ ModuleRevisionId module = ModuleRevisionId.parse(mrid);
- return getDescription(module);
- }
+ return getDescription(module);
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/Describe.java Tue Feb 22 15:55:55 2011
@@ -30,61 +30,60 @@ import org.apache.tools.ant.Project;
* supplied search name and returns result for each of these sequentially.
*/
public class Describe implements ManCommand {
- private String target;
-
- // convenient string constants
- private static final String TAB = "\t";
- private static final String NONE = "NONE";
-
- public void addParam(String param) {
- this.target = param;
- }
+ private String target;
+
+ // convenient string constants
+ private static final String NONE = "NONE";
+
+ public void addParam(String param) {
+ this.target = param;
+ }
- public void execute(EasyAntReport earep, Project project) {
- String lineSep = System.getProperty("line.separator");
-
- if(target == null || target.length() == 0) {
- throw new IllegalArgumentException("No parameter specified for -describe parameter.");
- }
-
- project.log(lineSep + "--- Available references for: " + target +
- " in current project: " + project.getName() + " ---" + lineSep);
-
- PhaseReport phaseRep = earep.getPhaseReport(target, true);
- if(phaseRep != null) {
- project.log(TAB + "Phase: " + target);
- project.log(TAB + TAB + "Description: " + (phaseRep.getDescription() == null ? NONE : phaseRep.getDescription()));
- project.log(TAB + TAB + "Depends: " + (phaseRep.getDepends() == null ? NONE : phaseRep.getDepends()));
- project.log(lineSep + TAB + TAB + "For information on targets attached to this phase, run:");
- project.log(TAB + TAB + "easyant -listTargets " + target);
- } else {
- project.log(TAB + "No Phase found for name: " + target);
- }
- TargetReport targetRep = earep.getTargetReport(target, true);
- if(targetRep != null) {
- project.log(TAB + "Target: " + target);
- project.log(TAB + TAB + "Phase: " + (targetRep.getPhase() == null ? NONE : targetRep.getPhase()));
- project.log(TAB + TAB + "Description: " + (targetRep.getDescription() == null ? NONE : targetRep.getDescription()));
- project.log(TAB + TAB + "Depends: " + (targetRep.getDepends() == null ? NONE : targetRep.getDepends()));
- project.log(TAB + TAB + "IF: " + (targetRep.getIfCase() == null ? NONE : targetRep.getIfCase()));
- project.log(TAB + TAB + "UNLESS: " + (targetRep.getUnlessCase() == null ? NONE : targetRep.getUnlessCase()));
- } else {
- project.log(TAB + "No Target found for name: " + target);
- }
- PropertyDescriptor prop = earep.getAvailableProperties().get(target);
- if(prop != null) {
- project.log(TAB + "Property: " + target);
- project.log(TAB + TAB + "Description: " + (prop.getDescription() == null ? NONE : prop.getDescription()));
- String defaultValue = prop.getDefaultValue() == null ? NONE : prop.getDefaultValue();
- project.log(TAB + TAB + "Default: " + defaultValue);
- project.log(TAB + TAB + "Required: " + prop.isRequired());
- String currentValue = prop.getValue() == null ? defaultValue : prop.getValue();
- project.log(TAB + TAB + "Current value: " + currentValue);
- } else {
- project.log(TAB + "No Property found for name: " + target);
- }
-
- project.log(lineSep + "--- End Of (Describe) ---");
- }
+ public void execute(EasyAntReport earep, Project project) {
+ String lineSep = System.getProperty("line.separator");
+
+ if(target == null || target.length() == 0) {
+ throw new IllegalArgumentException("No parameter specified for -describe parameter.");
+ }
+
+ project.log(lineSep + "--- Available references for: " + target +
+ " in current project: " + project.getName() + " ---" + lineSep);
+
+ PhaseReport phaseRep = earep.getPhaseReport(target, true);
+ if(phaseRep != null) {
+ project.log("\tPhase: " + target);
+ project.log("\t\tDescription: " + (phaseRep.getDescription() == null ? NONE : phaseRep.getDescription()));
+ project.log("\t\tDepends: " + (phaseRep.getDepends() == null ? NONE : phaseRep.getDepends()));
+ project.log(lineSep + "\t\tFor information on targets attached to this phase, run:");
+ project.log("\t\teasyant -listTargets " + target);
+ } else {
+ project.log("\tNo Phase found for name: " + target);
+ }
+ TargetReport targetRep = earep.getTargetReport(target, true);
+ if(targetRep != null) {
+ project.log("\tTarget: " + target);
+ project.log("\t\tPhase: " + (targetRep.getPhase() == null ? NONE : targetRep.getPhase()));
+ project.log("\t\tDescription: " + (targetRep.getDescription() == null ? NONE : targetRep.getDescription()));
+ project.log("\t\tDepends: " + (targetRep.getDepends() == null ? NONE : targetRep.getDepends()));
+ project.log("\t\tIF: " + (targetRep.getIfCase() == null ? NONE : targetRep.getIfCase()));
+ project.log("\t\tUNLESS: " + (targetRep.getUnlessCase() == null ? NONE : targetRep.getUnlessCase()));
+ } else {
+ project.log("\tNo Target found for name: " + target);
+ }
+ PropertyDescriptor prop = earep.getAvailableProperties().get(target);
+ if(prop != null) {
+ project.log("\tProperty: " + target);
+ project.log("\t\tDescription: " + (prop.getDescription() == null ? NONE : prop.getDescription()));
+ String defaultValue = prop.getDefaultValue() == null ? NONE : prop.getDefaultValue();
+ project.log("\t\tDefault: " + defaultValue);
+ project.log("\t\tRequired: " + prop.isRequired());
+ String currentValue = prop.getValue() == null ? defaultValue : prop.getValue();
+ project.log("\t\tCurrent value: " + currentValue);
+ } else {
+ project.log("\tNo Property found for name: " + target);
+ }
+
+ project.log(lineSep + "--- End Of (Describe) ---");
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListPhases.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListPhases.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListPhases.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/man/ListPhases.java Tue Feb 22 15:55:55 2011
@@ -30,24 +30,22 @@ import org.apache.tools.ant.Project;
* Supports the -listPhases switch.
*/
public class ListPhases implements ManCommand {
- // convenient string constant for formatting
- private static String TAB = "\t";
-
- public void addParam(String param) {
- // this command does not make use of params
- }
+
+ public void addParam(String param) {
+ // this command does not make use of params
+ }
- public void execute(EasyAntReport earep, Project project) {
- String lineSep = System.getProperty("line.separator");
- project.log(lineSep + "--- Available Phases for current project: " + project.getName() + " ---" + lineSep);
-
- List<PhaseReport> phases = earep.getAvailablePhases();
- for(int i = 0; i<phases.size(); i++) {
- project.log(TAB + phases.get(i).getName());
- }
-
- project.log(lineSep + lineSep + "For more information on a Phase, run:" + lineSep + "\t easyant -describe <PHASE>");
- project.log(lineSep + "--- End Of (Phases Listing) ---");
- }
+ public void execute(EasyAntReport earep, Project project) {
+ String lineSep = System.getProperty("line.separator");
+ project.log(lineSep + "--- Available Phases for current project: " + project.getName() + " ---" + lineSep);
+
+ List<PhaseReport> phases = earep.getAvailablePhases();
+ for(int i = 0; i<phases.size(); i++) {
+ project.log("\t" + phases.get(i).getName());
+ }
+
+ project.log(lineSep + lineSep + "For more information on a Phase, run:" + lineSep + "\t easyant -describe <PHASE>");
+ project.log(lineSep + "--- End Of (Phases Listing) ---");
+ }
}