Author: jlboudart
Date: Thu Jul 18 19:20:04 2013
New Revision: 1504612
URL: http://svn.apache.org/r1504612
Log:
PluginReport task should not display elements from transitive modules
Modified:
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/TaskCollectorFromImplicitTargetListener.java
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java
ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java
Modified:
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/TaskCollectorFromImplicitTargetListener.java
URL:
http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/TaskCollectorFromImplicitTargetListener.java?rev=1504612&r1=1504611&r2=1504612&view=diff
==============================================================================
---
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/TaskCollectorFromImplicitTargetListener.java
(original)
+++
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/ant/listerners/TaskCollectorFromImplicitTargetListener.java
Thu Jul 18 19:20:04 2013
@@ -32,6 +32,7 @@ import org.apache.tools.ant.types.FileSe
import org.apache.tools.ant.types.Path;
public class TaskCollectorFromImplicitTargetListener implements BuildListener {
+ public static final String ROOT_MODULE_LOCATION =
"report.root.module.location";
private List<Task> tasksCollected = new ArrayList<Task>();
private List<Class<?>> supportedClasses = new ArrayList<Class<?>>();
@@ -45,6 +46,7 @@ public class TaskCollectorFromImplicitTa
}
public void taskStarted(BuildEvent buildEvent) {
+ collectRootModuleLocation(buildEvent);
if (buildEvent.getTarget().getName().equals("")) {
Task task = buildEvent.getTask();
if (task.getTaskType() != null) {
@@ -62,6 +64,13 @@ public class TaskCollectorFromImplicitTa
}
}
+ private void collectRootModuleLocation(BuildEvent buildEvent) {
+ if (buildEvent.getProject().getProperty(ROOT_MODULE_LOCATION) == null)
{
+ buildEvent.getProject().setNewProperty(ROOT_MODULE_LOCATION,
+ buildEvent.getTask().getLocation().getFileName());
+ }
+ }
+
public List<Task> getTasksCollected() {
return tasksCollected;
}
Modified:
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java
URL:
http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java?rev=1504612&r1=1504611&r2=1504612&view=diff
==============================================================================
---
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java
(original)
+++
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/EasyAntReport.java
Thu Jul 18 19:20:04 2013
@@ -40,6 +40,13 @@ public class EasyAntReport {
private List<ParameterReport> parameterReports = new
ArrayList<ParameterReport>();
private Set<ImportedModuleReport> importedModuleReports = new
HashSet<ImportedModuleReport>();
private Map<String, PropertyDescriptor> propertyReports = new
HashMap<String, PropertyDescriptor>();
+
+ private List<TargetReport> targetReportsFromCurrentModule = new
ArrayList<TargetReport>();
+ private List<ExtensionPointReport> extensionPointReportsFromCurrentModule
= new ArrayList<ExtensionPointReport>();
+ private List<ParameterReport> parameterReportsFromCurrentModule = new
ArrayList<ParameterReport>();
+ private Set<ImportedModuleReport> importedModuleReportsFromCurrentModule =
new HashSet<ImportedModuleReport>();
+ private Map<String, PropertyDescriptor> propertyReportsFromCurrentModule =
new HashMap<String, PropertyDescriptor>();
+
private ResolveReport resolveReport;
private ModuleDescriptor moduleDescriptor;
private boolean extensionPointsConfigured;
@@ -71,11 +78,14 @@ public class EasyAntReport {
* @param targetReport
* a given targeReport
*/
- public void addTargetReport(TargetReport targetReport) {
+ public void addTargetReport(TargetReport targetReport, boolean
isCurrentModule) {
if (targetReport == null) {
throw new IllegalArgumentException("targetReport cannot be null");
}
targetReports.add(targetReport);
+ if (isCurrentModule) {
+ targetReportsFromCurrentModule.add(targetReport);
+ }
}
/**
@@ -128,12 +138,16 @@ public class EasyAntReport {
*
* @param extensionPointReport
* a given extensionPointReport
+ * @param isCurrentModule
*/
- public void addExtensionPointReport(ExtensionPointReport
extensionPointReport) {
+ public void addExtensionPointReport(ExtensionPointReport
extensionPointReport, boolean isCurrentModule) {
if (extensionPointReport == null) {
throw new IllegalArgumentException("extensionPointReport cannot be
null");
}
extensionPointReports.add(extensionPointReport);
+ if (isCurrentModule) {
+ extensionPointReportsFromCurrentModule.add(extensionPointReport);
+ }
}
/**
@@ -169,12 +183,16 @@ public class EasyAntReport {
*
* @param parameterReport
* a parameterReport
+ * @param isCurrentModule
*/
- public void addParameterReport(ParameterReport parameterReport) {
+ public void addParameterReport(ParameterReport parameterReport, boolean
isCurrentModule) {
if (parameterReport == null) {
throw new IllegalArgumentException("parameterReport cannot be
null");
}
parameterReports.add(parameterReport);
+ if (isCurrentModule) {
+ parameterReportsFromCurrentModule.add(parameterReport);
+ }
}
/**
@@ -228,12 +246,16 @@ public class EasyAntReport {
*
* @param importedModuleReport
* a report that represent the importedModule
+ * @param isCurrentModule
*/
- public void addImportedModuleReport(ImportedModuleReport
importedModuleReport) {
+ public void addImportedModuleReport(ImportedModuleReport
importedModuleReport, boolean isCurrentModule) {
if (importedModuleReport == null) {
throw new IllegalArgumentException("importedModuleReport cannot be
null");
}
importedModuleReports.add(importedModuleReport);
+ if (isCurrentModule) {
+ importedModuleReportsFromCurrentModule.add(importedModuleReport);
+ }
}
/**
@@ -243,12 +265,17 @@ public class EasyAntReport {
* the property name
* @param propertyDescriptor
* a property descriptor that contains several info on the
propery (description / required or not etc...)
+ * @param isCurrentModule
*/
- public void addPropertyDescriptor(String propertyName, PropertyDescriptor
propertyDescriptor) {
+ public void addPropertyDescriptor(String propertyName, PropertyDescriptor
propertyDescriptor,
+ boolean isCurrentModule) {
if (propertyName == null || propertyDescriptor == null) {
throw new IllegalArgumentException("propertyName and
propertyDescriptor cannot be null");
}
addProperty(propertyDescriptor, propertyReports);
+ if (isCurrentModule) {
+ addProperty(propertyDescriptor, propertyReportsFromCurrentModule);
+ }
}
/**
@@ -277,25 +304,10 @@ public class EasyAntReport {
* Get a list of all the properties available in this module or in all
imported modules
*
* @return a list of all the properties available in this module or in all
imported modules
+ * @deprecated since 0.10 use getPropertyDescriptors() method instead or
getPropertiesFromCurrentModule()
*/
public Map<String, PropertyDescriptor> getAvailableProperties() {
- Map<String, PropertyDescriptor> availableProperties = new
HashMap<String, PropertyDescriptor>();
-
- if (propertyReports != null) {
- availableProperties.putAll(propertyReports);
- }
- if (importedModuleReports != null) {
- for (ImportedModuleReport importedModuleReport :
importedModuleReports) {
- if (importedModuleReport.getEasyantReport() != null) {
- Map<String, PropertyDescriptor> subproperties =
importedModuleReport.getEasyantReport()
- .getAvailableProperties();
- for (PropertyDescriptor propertyDescriptor :
subproperties.values()) {
- addProperty(propertyDescriptor, availableProperties);
- }
- }
- }
- }
- return availableProperties;
+ return getPropertyDescriptors();
}
private void addProperty(PropertyDescriptor propertyDescriptor,
Map<String, PropertyDescriptor> availableProperties) {
@@ -360,4 +372,24 @@ public class EasyAntReport {
}
+ public List<TargetReport> getTargetReportsFromCurrentModule() {
+ return Collections.unmodifiableList(targetReportsFromCurrentModule);
+ }
+
+ public List<ExtensionPointReport>
getExtensionPointReportsFromCurrentModule() {
+ return
Collections.unmodifiableList(extensionPointReportsFromCurrentModule);
+ }
+
+ public List<ParameterReport> getParameterReportsFromCurrentModule() {
+ return Collections.unmodifiableList(parameterReportsFromCurrentModule);
+ }
+
+ public Set<ImportedModuleReport>
getImportedModuleReportsFromCurrentModule() {
+ return
Collections.unmodifiableSet(importedModuleReportsFromCurrentModule);
+ }
+
+ public Map<String, PropertyDescriptor>
getPropertyReportsFromCurrentModule() {
+ return Collections.unmodifiableMap(propertyReportsFromCurrentModule);
+ }
+
}
Modified:
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java
URL:
http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java?rev=1504612&r1=1504611&r2=1504612&view=diff
==============================================================================
---
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java
(original)
+++
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/report/XMLEasyAntReportWriter.java
Thu Jul 18 19:20:04 2013
@@ -30,9 +30,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import org.apache.easyant.core.descriptor.PropertyDescriptor;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.ArtifactOrigin;
import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.License;
@@ -45,6 +45,7 @@ import org.apache.ivy.core.report.Metada
import org.apache.ivy.core.resolve.IvyNode;
import org.apache.ivy.core.resolve.IvyNodeCallers.Caller;
import org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData;
+import org.apache.ivy.util.DateUtil;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.XMLHelper;
@@ -54,7 +55,7 @@ import org.apache.ivy.util.XMLHelper;
public class XMLEasyAntReportWriter {
static final String REPORT_ENCODING = "UTF-8";
- private boolean displaySubProperties = false;
+ private boolean displaySubElements = false;
public void output(EasyAntReport easyAntReport, OutputStream stream) {
for (String conf :
easyAntReport.getResolveReport().getConfigurations()) {
@@ -87,7 +88,7 @@ public class XMLEasyAntReportWriter {
out.println("\t\textra-" + entry.getKey() + "=\"" +
XMLHelper.escape(entry.getValue().toString()) + "\"");
}
out.println("\t\tconf=\"" +
XMLHelper.escape(report.getConfiguration()) + "\"");
- out.println("\t\tdate=\"" + Ivy.DATE_FORMAT.format(report.getDate()) +
"\"/>");
+ out.println("\t\tdate=\"" + DateUtil.format(report.getDate()) +
"\"/>");
out.println("\t<description>");
out.println(report.getModuleDescriptor().getDescription());
out.println("\t</description>");
@@ -132,7 +133,7 @@ public class XMLEasyAntReportWriter {
out.flush();
}
- private void ouputRevision(ConfigurationResolveReport report, PrintWriter
out, List dependencies, IvyNode dep,
+ private void ouputRevision(ConfigurationResolveReport report, PrintWriter
out, List<?> dependencies, IvyNode dep,
EasyAntReport easyAntReport) {
Map<?, ?> extraAttributes;
ModuleDescriptor md = null;
@@ -144,7 +145,7 @@ public class XMLEasyAntReportWriter {
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(DateUtil.format(new Date(dep.getPublication())));
details.append("\" resolver=\"");
details.append(XMLHelper.escape(dep.getModuleRevision().getResolver().getName()));
details.append("\" artresolver=\"");
@@ -170,20 +171,18 @@ public class XMLEasyAntReportWriter {
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("\"");
+ 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 + "\">");
+ 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++) {
@@ -252,8 +251,8 @@ public class XMLEasyAntReportWriter {
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("\"");
+ callerDetails.append(" extra-").append(attName).append("=\"")
+
.append(XMLHelper.escape(callerExtraAttributes.get(attName).toString())).append("\"");
}
out.println("\t\t\t\t<caller organisation=\""
@@ -323,8 +322,8 @@ public class XMLEasyAntReportWriter {
return XMLHelper.escape(buf.toString());
}
- public void setDisplaySubProperties(boolean displaySubProperties) {
- this.displaySubProperties = displaySubProperties;
+ public void setDisplaySubElements(boolean displaySubElements) {
+ this.displaySubElements = displaySubElements;
}
@@ -343,10 +342,10 @@ public class XMLEasyAntReportWriter {
private void outputProperties(EasyAntReport easyAntReport, PrintWriter
out) {
out.println("\t\t<properties>");
Map<String, PropertyDescriptor> properties;
- if (displaySubProperties) {
- properties = easyAntReport.getAvailableProperties();
- } else {
+ if (displaySubElements) {
properties = easyAntReport.getPropertyDescriptors();
+ } else {
+ properties = easyAntReport.getPropertyReportsFromCurrentModule();
}
for (Entry<String, PropertyDescriptor> entry : properties.entrySet()) {
@@ -383,7 +382,13 @@ public class XMLEasyAntReportWriter {
private void outputParameters(EasyAntReport easyAntReport, PrintWriter
out) {
out.println("\t\t<parameters>");
- for (ParameterReport paramReport :
easyAntReport.getParameterReports()) {
+ List<ParameterReport> parameterReports;
+ if (displaySubElements) {
+ parameterReports = easyAntReport.getParameterReports();
+ } else {
+ parameterReports =
easyAntReport.getParameterReportsFromCurrentModule();
+ }
+ for (ParameterReport paramReport : parameterReports) {
StringBuffer param = new StringBuffer();
if (!ParameterType.PROPERTY.equals(paramReport.getType())) {
@@ -415,20 +420,28 @@ public class XMLEasyAntReportWriter {
private void outputImportedModules(EasyAntReport easyAntReport,
PrintWriter out) {
out.println("\t\t<imports>");
- for (ImportedModuleReport importedModuleReport :
easyAntReport.getImportedModuleReports()) {
+ Set<ImportedModuleReport> importedModuleReports;
+ if (displaySubElements) {
+ importedModuleReports = easyAntReport.getImportedModuleReports();
+ } else {
+ importedModuleReports =
easyAntReport.getImportedModuleReportsFromCurrentModule();
+ }
+
+ for (ImportedModuleReport importedModuleReport :
importedModuleReports) {
StringBuffer importedModule = new StringBuffer();
try {
ModuleRevisionId mrid =
ModuleRevisionId.parse(importedModuleReport.getModuleMrid());
- importedModule.append("\t\t\t<import
organisation=\"").append(mrid.getOrganisation()).append(
- "\" name=\"").append(mrid.getName()).append("\"
revision=\"").append(mrid.getRevision())
- .append("\"
type=\"").append(importedModuleReport.getMode()).append("\"");
+ importedModule.append("\t\t\t<import
organisation=\"").append(mrid.getOrganisation())
+ .append("\"
name=\"").append(mrid.getName()).append("\" revision=\"")
+ .append(mrid.getRevision()).append("\"
type=\"").append(importedModuleReport.getMode())
+ .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.getMode())
- .append("\"");
+ importedModule.append(" <import
organisation=\"")
+
.append(importedModuleReport.getModuleMrid()).append("\"
name=\"").append("null")
+ .append("\" revision=\"").append("null").append("\"
type=\"")
+ .append(importedModuleReport.getMode()).append("\"");
}
importedModule.append(" mandatory=\"");
@@ -453,7 +466,13 @@ public class XMLEasyAntReportWriter {
private void outputExtensionPoints(EasyAntReport easyAntReport,
PrintWriter out) {
out.println("\t\t<extension-points>");
- for (ExtensionPointReport extensionPointReport :
easyAntReport.getExtensionPointReports()) {
+ List<ExtensionPointReport> extensionPointReports;
+ if (displaySubElements) {
+ extensionPointReports = easyAntReport.getExtensionPointReports();
+ } else {
+ extensionPointReports =
easyAntReport.getExtensionPointReportsFromCurrentModule();
+ }
+ for (ExtensionPointReport extensionPointReport :
extensionPointReports) {
StringBuffer extensionPoint = new StringBuffer();
extensionPoint.append("\t\t\t<extension-point
name=\"").append(extensionPointReport.getName()).append("\"");
if (extensionPointReport.getDescription() != null) {
@@ -474,7 +493,14 @@ public class XMLEasyAntReportWriter {
private void outputTargets(EasyAntReport easyAntReport, PrintWriter out) {
out.println("\t\t<targets>");
- for (TargetReport targetReport : easyAntReport.getTargetReports()) {
+ List<TargetReport> targetReports;
+ if (displaySubElements) {
+ targetReports = easyAntReport.getTargetReports();
+ } else {
+ targetReports = easyAntReport.getTargetReportsFromCurrentModule();
+ }
+
+ for (TargetReport targetReport : targetReports) {
StringBuffer target = new StringBuffer();
target.append("\t\t\t<target
name=\"").append(targetReport.getName()).append("\"");
if (targetReport.getDescription() != null) {
Modified:
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java
URL:
http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java?rev=1504612&r1=1504611&r2=1504612&view=diff
==============================================================================
---
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java
(original)
+++
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/PluginService.java
Thu Jul 18 19:20:04 2013
@@ -33,15 +33,12 @@ public interface PluginService {
* @return an easyantReport an easyantReport
* @throws Exception
*/
- EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId)
- 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
+ * 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
@@ -51,11 +48,9 @@ public interface PluginService {
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
+ * 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
@@ -71,27 +66,29 @@ public interface PluginService {
* a given moduleRevisionID
* @param conf
* a configuration name
- * @return an easyantReport
+ * @return an easyantReport
* @throws Exception
*/
- EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId, String conf)
- throws Exception;
-
+ EasyAntReport getPluginInfo(ModuleRevisionId moduleRevisionId, String
conf) throws Exception;
+
/**
* Generate an {@link EasyAntReport} for a given pluginIvyFile
- * @param pluginIvyFile plugin ivy file
- * @param sourceDirectory source directory
- * @param conf a configuration name
+ *
+ * @param pluginIvyFile
+ * plugin ivy file
+ * @param sourceDirectory
+ * source directory
+ * @param conf
+ * a configuration name
* @return an {@link EasyAntReport}
* @throws Exception
*/
EasyAntReport getPluginInfo(File pluginIvyFile, File sourceDirectory,
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)}
+ * 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
@@ -101,12 +98,11 @@ public interface PluginService {
* @throws Exception
* @see org.apache.ivy.plugins.matcher.PatternMatcher
*/
- ModuleRevisionId[] search(String organisation, String moduleName)
- throws Exception;
+ 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).
+ * 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
@@ -119,31 +115,32 @@ public interface PluginService {
* @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.
+ * 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;
+ 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
+ * 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
- * @param optionalAntModule the optional build file
- * @param overrideAntModule an optional override buildfile
+ * @param optionalAntModule
+ * the optional build file
+ * @param overrideAntModule
+ * an optional override buildfile
* @return an easyantReport for a given moduleDescriptor
* @throws Exception
*/
- EasyAntReport generateEasyAntReport(File moduleDescriptor, File
optionalAntModule, File overrideAntModule) throws Exception;
+ EasyAntReport generateEasyAntReport(File moduleDescriptor, File
optionalAntModule, File overrideAntModule)
+ throws Exception;
/**
- * Generate an easyantReport for a given moduleDescriptor. Using this
report
- * you should have all properties / plugins / targets loaded in your module
- * descriptor
+ * 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
@@ -152,22 +149,18 @@ public interface PluginService {
*/
EasyAntReport generateEasyAntReport(File moduleDescriptor) throws
Exception;
-
/**
- * Return the EasyAnt model containing all data of the module described in
- * given file.
+ * 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;
+ EasyAntModuleDescriptor getEasyAntModuleDescriptor(File moduleDescriptor)
throws Exception;
/**
- * Return an array of string representing the fully qualified named
matching
- * with given criterias
+ * Return an array of string representing the fully qualified named
matching with given criterias
*
* @param organisation
* the organisation name
@@ -176,37 +169,35 @@ public interface PluginService {
* @return an array of moduleRevisionId
* @throws Exception
*/
- String[] searchModule(String organisation, String moduleName)
- 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 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 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 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:
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java
URL:
http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java?rev=1504612&r1=1504611&r2=1504612&view=diff
==============================================================================
---
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java
(original)
+++
ant/easyant/core/trunk/src/main/java/org/apache/easyant/core/services/impl/DefaultPluginServiceImpl.java
Thu Jul 18 19:20:04 2013
@@ -153,7 +153,6 @@ public class DefaultPluginServiceImpl im
}
public EasyAntReport getPluginInfo(final ModuleRevisionId
moduleRevisionId, String conf) throws Exception {
-
IvyContext.pushNewContext().setIvy(ivyInstance);
EasyAntReport eaReport = null;
try {
@@ -303,6 +302,15 @@ public class DefaultPluginServiceImpl im
}
}
+ private boolean isCurrentModule(Project project, Location location) {
+ String rootModuleLocation =
project.getProperty(TaskCollectorFromImplicitTargetListener.ROOT_MODULE_LOCATION);
+ if (rootModuleLocation == null) {
+ throw new IllegalStateException(
+ "rootModuleLocation not found, looks like
TaskCOllectorFromImplicitTargetListener is not properly configured");
+ }
+ return rootModuleLocation != null && location != null &&
location.getFileName().equals(rootModuleLocation);
+ }
+
private void handleImport(Import importTask, EasyAntReport eaReport,
String conf) throws Exception {
ImportedModuleReport importedModuleReport = new ImportedModuleReport();
@@ -313,16 +321,18 @@ public class DefaultPluginServiceImpl im
importedModuleReport.setMandatory(importTask.isMandatory());
importedModuleReport.setMode(importTask.getMode());
importedModuleReport.setAs(importTask.getAs());
- importedModuleReport
-
.setEasyantReport(getPluginInfo(ModuleRevisionId.parse(importedModuleReport.getModuleMrid())));
- eaReport.addImportedModuleReport(importedModuleReport);
+
+ EasyAntReport pluginInfo =
getPluginInfo(ModuleRevisionId.parse(importedModuleReport.getModuleMrid()),
conf);
+ importedModuleReport.setEasyantReport(pluginInfo);
+ eaReport.addImportedModuleReport(importedModuleReport,
+ isCurrentModule(importTask.getProject(),
importTask.getLocation()));
Message.debug("Ant file import another module called : " +
importedModuleReport.getModuleMrid() + " with mode "
+ importedModuleReport.getMode());
}
private void handleProperty(Property property, EasyAntReport eaReport)
throws IOException {
-
+ boolean isCurrentModule = isCurrentModule(property.getProject(),
property.getLocation());
if (property.getFile() != null) {
Properties propToLoad = new Properties();
File f = property.getFile();
@@ -336,7 +346,8 @@ public class DefaultPluginServiceImpl im
if (property.getOwningTarget() != null) {
propertyDescriptor.setOwningTarget(property.getOwningTarget().getName());
}
-
eaReport.addPropertyDescriptor(propertyDescriptor.getName(),
propertyDescriptor);
+
eaReport.addPropertyDescriptor(propertyDescriptor.getName(), propertyDescriptor,
+ isCurrentModule);
}
} catch (IOException e) {
@@ -352,11 +363,13 @@ public class DefaultPluginServiceImpl im
if (property.getOwningTarget() != null) {
propertyDescriptor.setOwningTarget(property.getOwningTarget().getName());
}
- eaReport.addPropertyDescriptor(property.getName(),
propertyDescriptor);
+ eaReport.addPropertyDescriptor(property.getName(),
propertyDescriptor, isCurrentModule);
}
}
private void handleParameterTask(ParameterTask parameterTask,
EasyAntReport eaReport) {
+ boolean isCurrentModule = isCurrentModule(parameterTask.getProject(),
parameterTask.getLocation());
+
if (parameterTask.getProperty() != null) {
PropertyDescriptor propertyDescriptor = new
PropertyDescriptor(parameterTask.getProperty());
propertyDescriptor.setDefaultValue(parameterTask.getDefault());
@@ -366,7 +379,7 @@ public class DefaultPluginServiceImpl im
propertyDescriptor.setOwningTarget(parameterTask.getOwningTarget().getName());
}
Message.debug("Ant file has a property called : " +
propertyDescriptor.getName());
- eaReport.addPropertyDescriptor(propertyDescriptor.getName(),
propertyDescriptor);
+ eaReport.addPropertyDescriptor(propertyDescriptor.getName(),
propertyDescriptor, isCurrentModule);
} else if (parameterTask.getPath() != null) {
ParameterReport parameterReport = new
ParameterReport(ParameterType.PATH);
parameterReport.setName(parameterTask.getPath());
@@ -375,7 +388,7 @@ public class DefaultPluginServiceImpl im
if (parameterTask.getOwningTarget() != null) {
parameterReport.setOwningTarget(parameterTask.getOwningTarget().getName());
}
- eaReport.addParameterReport(parameterReport);
+ eaReport.addParameterReport(parameterReport, isCurrentModule);
Message.debug("Ant file has a path called : " +
parameterReport.getName());
}
}
@@ -389,7 +402,7 @@ public class DefaultPluginServiceImpl im
if (target != null) {
parameterReport.setOwningTarget(target.getName());
}
- eaReport.addParameterReport(parameterReport);
+ eaReport.addParameterReport(parameterReport,
isCurrentModule(fileSet.getProject(), fileSet.getLocation()));
Message.debug("Ant file has a fileset called : " +
parameterReport.getName());
}
@@ -404,7 +417,7 @@ public class DefaultPluginServiceImpl im
if (target != null) {
parameterReport.setOwningTarget(target.getName());
}
- eaReport.addParameterReport(parameterReport);
+ eaReport.addParameterReport(parameterReport,
isCurrentModule(path.getProject(), path.getLocation()));
Message.debug("Ant file has a path called : " +
parameterReport.getName());
}
}
@@ -418,12 +431,13 @@ public class DefaultPluginServiceImpl im
if (pathTask.getOwningTarget() != null) {
parameterReport.setOwningTarget(pathTask.getOwningTarget().getName());
}
- eaReport.addParameterReport(parameterReport);
+ eaReport.addParameterReport(parameterReport,
isCurrentModule(pathTask.getProject(), pathTask.getLocation()));
Message.debug("Ant file has a path called : " +
parameterReport.getName());
}
}
private void handleTarget(Target target, EasyAntReport eaReport) {
+ boolean isCurrentModule = isCurrentModule(target.getProject(),
target.getLocation());
boolean isExtensionPoint = target instanceof ExtensionPoint;
if (!isExtensionPoint) {
TargetReport targetReport = new TargetReport();
@@ -455,7 +469,7 @@ public class DefaultPluginServiceImpl im
}
}
- eaReport.addTargetReport(targetReport);
+ eaReport.addTargetReport(targetReport, isCurrentModule);
Message.debug("Ant file has a target called : " +
targetReport.getName());
} else {
@@ -471,7 +485,7 @@ public class DefaultPluginServiceImpl im
}
extensionPoint.setDepends(sb.toString());
extensionPoint.setDescription(target.getDescription());
- eaReport.addExtensionPointReport(extensionPoint);
+ eaReport.addExtensionPointReport(extensionPoint, isCurrentModule);
Message.debug("Ant file has an extensionPoint called : " +
extensionPoint.getName());
}
}
Modified:
ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java
URL:
http://svn.apache.org/viewvc/ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java?rev=1504612&r1=1504611&r2=1504612&view=diff
==============================================================================
---
ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java
(original)
+++
ant/easyant/core/trunk/src/test/java/org/apache/easyant/core/services/PluginServiceTest.java
Thu Jul 18 19:20:04 2013
@@ -158,6 +158,23 @@ public class PluginServiceTest {
}
@Test
+ public void testGetPluginInfoOnlyForCurrentPlugin() throws Exception {
+ ModuleRevisionId mrid =
ModuleRevisionId.parse("org.apache.easyant.plugins#compile-java;0.9");
+ EasyAntReport pluginInfo = pluginService.getPluginInfo(mrid,
"default");
+ Assert.assertNotNull(pluginInfo);
+ Assert.assertEquals(1,
pluginInfo.getImportedModuleReportsFromCurrentModule().size());
+ ImportedModuleReport abstractCompile =
pluginInfo.getImportedModuleReport("abstract-compile");
+ Assert.assertNotNull(abstractCompile);
+ Assert.assertEquals(1,
abstractCompile.getEasyantReport().getImportedModuleReportsFromCurrentModule().size());
+
Assert.assertNotNull(abstractCompile.getEasyantReport().getImportedModuleReport("abstract-provisioning"));
+ checkPropertyDefaultValueEquals(
+
pluginInfo.getPropertyReportsFromCurrentModule().get("compile.java.includes.pattern"),
"**/*.java");
+ checkPropertyDefaultValueEquals(
+
abstractCompile.getEasyantReport().getPropertyReportsFromCurrentModule()
+ .get("target.test.integration.classes"),
"${target}/integration-test/classes");
+ }
+
+ @Test
public void testGetPluginInfoWithNestedPlugin() throws Exception {
EasyAntReport pluginInfo =
pluginService.getPluginInfo("org.apache.easyant.plugins#compile-java;0.9");
Assert.assertNotNull(pluginInfo);