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 [19/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/tasks/PropertyTask.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/PropertyTask.java Tue Feb 22 15:55:55 2011
@@ -31,36 +31,36 @@ import org.apache.tools.ant.taskdefs.Pro
*/
public class PropertyTask extends Property {
- private String buildConfigurations = null;
+ private String buildConfigurations = null;
- @Override
- public void execute() throws BuildException {
- //Build the message
- StringBuilder message= new StringBuilder("property ");
- if (getName() != null ) {
- message.append(getName());
- }
- if (getFile()!=null) {
- message.append("file ").append(getFile());
- }
-
- if (BuildConfigurationHelper.isBuildConfigurationActive(getBuildConfigurations(), getProject(), message.toString())) {
- super.execute();
- } else {
- log("this property will be skipped ", Project.MSG_DEBUG);
- }
- }
+ @Override
+ public void execute() throws BuildException {
+ //Build the message
+ StringBuilder message= new StringBuilder("property ");
+ if (getName() != null ) {
+ message.append(getName());
+ }
+ if (getFile()!=null) {
+ message.append("file ").append(getFile());
+ }
+
+ if (BuildConfigurationHelper.isBuildConfigurationActive(getBuildConfigurations(), getProject(), message.toString())) {
+ super.execute();
+ } else {
+ log("this property will be skipped ", Project.MSG_DEBUG);
+ }
+ }
- public String getBuildConfigurations() {
- return buildConfigurations;
- }
+ public String getBuildConfigurations() {
+ return buildConfigurations;
+ }
- public void setBuildConfigurations(String confs) {
- this.buildConfigurations = confs;
- }
-
- public void setConf(String conf) {
- this.buildConfigurations = conf;
- }
+ public void setBuildConfigurations(String confs) {
+ this.buildConfigurations = confs;
+ }
+
+ public void setConf(String conf) {
+ this.buildConfigurations = conf;
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RegisterArtifact.java Tue Feb 22 15:55:55 2011
@@ -31,94 +31,94 @@ import org.apache.tools.ant.BuildExcepti
public class RegisterArtifact extends IvyPostResolveTask {
- private String name;
- private String type;
- private String ext;
- private String conf="*";
- private String classifier;
-
- @Override
- public void doExecute() throws BuildException {
- prepareAndCheck();
- DefaultModuleDescriptor md= (DefaultModuleDescriptor) getResolvedReport().getModuleDescriptor();
-
- // this is a published artifact
- String artName = getSettings().substitute(getName());
- artName = artName == null ? md.getModuleRevisionId().getName() : artName;
- String type = getSettings().substitute(getType());
- type = type == null ? "jar" : type;
- String ext = getSettings().substitute(getExt());
- ext = ext != null ? ext : type;
- Map<String,String> extraAttributes = new HashMap<String,String>();
- if (getClassifier()!=null) {
- md.addExtraAttributeNamespace("m", "http://ant.apache.org/ivy/maven");
- extraAttributes.put("m:classifier", getClassifier());
- }
-
- MDArtifact artifact = new MDArtifact(md, artName, type, ext, null, extraAttributes);
- if ("*".equals(getConf())) {
- String[] confs = md.getConfigurationsNames();
- for (int i = 0; i < confs.length; i++) {
- artifact.addConfiguration(confs[i]);
- md.addArtifact(confs[i], artifact);
- }
- } else {
- artifact.addConfiguration(getConf());
- md.addArtifact(getConf(), artifact);
- }
-
-
-
- ResolutionCacheManager cacheManager= getSettings().getResolutionCacheManager();
- File ivyFileInCache = cacheManager.getResolvedIvyFileInCache(md.getResolvedModuleRevisionId());
- try {
- XmlModuleDescriptorWriter.write(md, ivyFileInCache);
- } catch (IOException e) {
- throw new BuildException("Can't register specified artifact",e);
- }
-
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getExt() {
- return ext;
- }
-
- public void setExt(String ext) {
- this.ext = ext;
- }
-
- public String getConf() {
- return conf;
- }
-
- public void setConf(String conf) {
- this.conf = conf;
- }
-
- public String getClassifier() {
- return classifier;
- }
-
- public void setClassifier(String classifier) {
- this.classifier = classifier;
- }
-
-
+ private String name;
+ private String type;
+ private String ext;
+ private String conf="*";
+ private String classifier;
+
+ @Override
+ public void doExecute() throws BuildException {
+ prepareAndCheck();
+ DefaultModuleDescriptor md= (DefaultModuleDescriptor) getResolvedReport().getModuleDescriptor();
+
+ // this is a published artifact
+ String artName = getSettings().substitute(getName());
+ artName = artName == null ? md.getModuleRevisionId().getName() : artName;
+ String type = getSettings().substitute(getType());
+ type = type == null ? "jar" : type;
+ String ext = getSettings().substitute(getExt());
+ ext = ext != null ? ext : type;
+ Map<String,String> extraAttributes = new HashMap<String,String>();
+ if (getClassifier()!=null) {
+ md.addExtraAttributeNamespace("m", "http://ant.apache.org/ivy/maven");
+ extraAttributes.put("m:classifier", getClassifier());
+ }
+
+ MDArtifact artifact = new MDArtifact(md, artName, type, ext, null, extraAttributes);
+ if ("*".equals(getConf())) {
+ String[] confs = md.getConfigurationsNames();
+ for (int i = 0; i < confs.length; i++) {
+ artifact.addConfiguration(confs[i]);
+ md.addArtifact(confs[i], artifact);
+ }
+ } else {
+ artifact.addConfiguration(getConf());
+ md.addArtifact(getConf(), artifact);
+ }
+
+
+
+ ResolutionCacheManager cacheManager= getSettings().getResolutionCacheManager();
+ File ivyFileInCache = cacheManager.getResolvedIvyFileInCache(md.getResolvedModuleRevisionId());
+ try {
+ XmlModuleDescriptorWriter.write(md, ivyFileInCache);
+ } catch (IOException e) {
+ throw new BuildException("Can't register specified artifact",e);
+ }
+
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getExt() {
+ return ext;
+ }
+
+ public void setExt(String ext) {
+ this.ext = ext;
+ }
+
+ public String getConf() {
+ return conf;
+ }
+
+ public void setConf(String conf) {
+ this.conf = conf;
+ }
+
+ public String getClassifier() {
+ return classifier;
+ }
+
+ public void setClassifier(String classifier) {
+ this.classifier = classifier;
+ }
+
+
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RepositoryReport.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RepositoryReport.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RepositoryReport.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/RepositoryReport.java Tue Feb 22 15:55:55 2011
@@ -58,59 +58,59 @@ import org.apache.tools.ant.util.FileNam
* set of modules is specified using organisation/module and matcher.
*/
public class RepositoryReport extends AbstractEasyAntTask {
- private String organisation = "*";
+ private String organisation = "*";
- private String module;
+ private String module;
- private String branch;
+ private String branch;
- private String revision = "latest.integration";
+ private String revision = "latest.integration";
- private String matcher = PatternMatcher.EXACT_OR_REGEXP;
+ private String matcher = PatternMatcher.EXACT_OR_REGEXP;
- private File todir;
+ private File todir;
- private boolean graph = false;
+ private boolean graph = false;
- private boolean dot = false;
+ private boolean dot = false;
- private boolean xml = false;
+ private boolean xml = false;
- private boolean xsl = true;
+ private boolean xsl = true;
- private boolean displaySubProperties = false;
+ private boolean displaySubProperties = false;
- private String xslFile;
+ private String xslFile;
- private String outputname = "ivy-repository-report";
+ private String outputname = "ivy-repository-report";
- private String xslext = "html";
+ private String xslext = "html";
private String resolver;
- private List<XSLTProcess.Param> params = new ArrayList<XSLTProcess.Param>();
+ private List<XSLTProcess.Param> params = new ArrayList<XSLTProcess.Param>();
- private List<ReportMenu> menus = new ArrayList<ReportMenu>();
+ private List<ReportMenu> menus = new ArrayList<ReportMenu>();
- public void execute() throws BuildException {
- Ivy ivy = getEasyAntIvyInstance();
- IvySettings settings = ivy.getSettings();
-
- ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation,
- module, revision);
-
- PluginService pluginService = (PluginService) getProject()
- .getReference(EasyAntMagicNames.PLUGIN_SERVICE_INSTANCE);
- try {
- ModuleRevisionId[] mrids = pluginService.search(organisation,
- module, revision, branch, matcher, resolver);
- // replace all found revisions with the original requested revision
- Set<ModuleRevisionId> modules = new HashSet<ModuleRevisionId>();
- for (int i = 0; i < mrids.length; i++) {
- modules.add(ModuleRevisionId.newInstance(mrids[i], revision));
- }
+ public void execute() throws BuildException {
+ Ivy ivy = getEasyAntIvyInstance();
+ IvySettings settings = ivy.getSettings();
+
+ ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation,
+ module, revision);
+
+ PluginService pluginService = (PluginService) getProject()
+ .getReference(EasyAntMagicNames.PLUGIN_SERVICE_INSTANCE);
+ try {
+ ModuleRevisionId[] mrids = pluginService.search(organisation,
+ module, revision, branch, matcher, resolver);
+ // replace all found revisions with the original requested revision
+ Set<ModuleRevisionId> modules = new HashSet<ModuleRevisionId>();
+ for (int i = 0; i < mrids.length; i++) {
+ modules.add(ModuleRevisionId.newInstance(mrids[i], revision));
+ }
- String conf = "default";
+ String conf = "default";
XslReport xslReport = new XslReport();
ResolutionCacheManager cacheMgr = ivy.getResolutionCacheManager();
@@ -118,51 +118,51 @@ public class RepositoryReport extends Ab
final String graphXsl = graph ? getGraphStylePath(cacheMgr.getResolutionCacheRoot()) : null;
final String reportXsl = xsl ? getXslPath() : null;
- for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
- ModuleRevisionId moduleRevisionId = (ModuleRevisionId) iterator
- .next();
- ModuleDescriptor md = DefaultModuleDescriptor
- .newCallerInstance(moduleRevisionId, conf.split(","),
- true, false);
- outputname = moduleRevisionId.getName();
- String resolveId = ResolveOptions.getDefaultResolveId(md);
- EasyAntReport easyAntReport = null;
- try {
- easyAntReport = pluginService.getPluginInfo(
- moduleRevisionId, conf);
- } catch (Exception e) {
- throw new Exception("can't parse " + moduleRevisionId.toString(),e);
- }
- if (easyAntReport == null
- || easyAntReport.getResolveReport() == null) {
- throw new Exception("impossible to generate graph for "
- + moduleRevisionId.toString()
- + ": can't find easyant report");
- }
-
- new XmlEasyAntReportOutputter().output(easyAntReport
- .getResolveReport(), cacheMgr, new ResolveOptions(),
- easyAntReport, displaySubProperties);
-
+ for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
+ ModuleRevisionId moduleRevisionId = (ModuleRevisionId) iterator
+ .next();
+ ModuleDescriptor md = DefaultModuleDescriptor
+ .newCallerInstance(moduleRevisionId, conf.split(","),
+ true, false);
+ outputname = moduleRevisionId.getName();
+ String resolveId = ResolveOptions.getDefaultResolveId(md);
+ EasyAntReport easyAntReport = null;
+ try {
+ easyAntReport = pluginService.getPluginInfo(
+ moduleRevisionId, conf);
+ } catch (Exception e) {
+ throw new Exception("can't parse " + moduleRevisionId.toString(),e);
+ }
+ if (easyAntReport == null
+ || easyAntReport.getResolveReport() == null) {
+ throw new Exception("impossible to generate graph for "
+ + moduleRevisionId.toString()
+ + ": can't find easyant report");
+ }
+
+ new XmlEasyAntReportOutputter().output(easyAntReport
+ .getResolveReport(), cacheMgr, new ResolveOptions(),
+ easyAntReport, displaySubProperties);
+
File xmlSource = cacheMgr.getConfigurationResolveReportInCache(
resolveId, "default");
- if (graph) {
+ if (graph) {
xslReport.add(graphXsl, xmlSource, outputname, "graphml");
- }
- if (dot) {
+ }
+ if (dot) {
xslReport.add(dotXsl, xmlSource, outputname, "dot");
- }
+ }
if (xsl) {
xslReport.add(reportXsl, xmlSource, outputname, getXslext());
}
- if (xml) {
- FileUtil.copy(cacheMgr
- .getConfigurationResolveReportInCache(resolveId,
- "default"), new File(getTodir(), outputname
- + ".xml"), null);
- }
- }
+ if (xml) {
+ FileUtil.copy(cacheMgr
+ .getConfigurationResolveReportInCache(resolveId,
+ "default"), new File(getTodir(), outputname
+ + ".xml"), null);
+ }
+ }
//run XSL transform on accumulated source files
xslReport.generateAll();
@@ -183,165 +183,165 @@ public class RepositoryReport extends Ab
}
}
- } catch (Exception e) {
- throw new BuildException("impossible to generate graph for " + mrid
- + ": " + e, e);
- }
- }
-
- private String getGraphStylePath(File cache) throws IOException {
- // style should be a file (and not an url)
- // so we have to copy it from classpath to cache
- File style = new File(cache, "easyant-report-graph.xsl");
- FileUtil.copy(XmlReportOutputter.class
- .getResourceAsStream("easyant-report-graph.xsl"), style, null);
- return style.getAbsolutePath();
- }
-
- private String getXslPath() throws IOException {
- if (xslFile != null) {
- return xslFile;
- }
- // style should be a file (and not an url)
- // so we have to copy it from classpath to cache
- ResolutionCacheManager cacheMgr = getEasyAntIvyInstance()
- .getResolutionCacheManager();
- File style = new File(cacheMgr.getResolutionCacheRoot(),
- "easyant-report.xsl");
- FileUtil.copy(XmlEasyAntReportOutputter.class
- .getResourceAsStream("easyant-report.xsl"), style, null);
- return style.getAbsolutePath();
- }
-
- private String getDotStylePath(File cache) throws IOException {
- // style should be a file (and not an url)
- // so we have to copy it from classpath to cache
- File style = new File(cache, "easyant-report-dot.xsl");
- FileUtil.copy(XmlEasyAntReportOutputter.class
- .getResourceAsStream("easyant-report-dot.xsl"), style, null);
- return style.getAbsolutePath();
- }
-
- public File getTodir() {
- if (todir == null && getProject() != null) {
- return getProject().getBaseDir();
- }
- return todir;
- }
-
- public void setTodir(File todir) {
- this.todir = todir;
- }
-
- public boolean isGraph() {
- return graph;
- }
-
- public void setGraph(boolean graph) {
- this.graph = graph;
- }
-
- public String getXslfile() {
- return xslFile;
- }
-
- public void setXslfile(String xslFile) {
- this.xslFile = xslFile;
- }
-
- public boolean isXml() {
- return xml;
- }
-
- public void setXml(boolean xml) {
- this.xml = xml;
- }
-
- public boolean isXsl() {
- return xsl;
- }
-
- public void setXsl(boolean xsl) {
- this.xsl = xsl;
- }
-
- public String getXslext() {
- return xslext;
- }
-
- public void setXslext(String xslext) {
- this.xslext = xslext;
- }
-
- public XSLTProcess.Param createParam() {
- XSLTProcess.Param result = new XSLTProcess.Param();
- params.add(result);
- return result;
- }
-
- public String getOutputname() {
- return outputname;
- }
-
- public void setOutputname(String outputpattern) {
- outputname = outputpattern;
- }
-
- public String getMatcher() {
- return matcher;
- }
-
- public void setMatcher(String matcher) {
- this.matcher = matcher;
- }
-
- public String getModule() {
- return module;
- }
-
- public void setModule(String module) {
- this.module = module;
- }
-
- public String getOrganisation() {
- return organisation;
- }
-
- public void setOrganisation(String organisation) {
- this.organisation = organisation;
- }
-
- public String getRevision() {
- return revision;
- }
-
- public void setRevision(String revision) {
- this.revision = revision;
- }
-
- public String getBranch() {
- return branch;
- }
-
- public void setBranch(String branch) {
- this.branch = branch;
- }
-
- public boolean isDot() {
- return dot;
- }
-
- public void setDot(boolean dot) {
- this.dot = dot;
- }
-
- public boolean isDisplaySubProperties() {
- return displaySubProperties;
- }
-
- public void setDisplaySubProperties(boolean displaySubProperties) {
- this.displaySubProperties = displaySubProperties;
- }
+ } catch (Exception e) {
+ throw new BuildException("impossible to generate graph for " + mrid
+ + ": " + e, e);
+ }
+ }
+
+ private String getGraphStylePath(File cache) throws IOException {
+ // style should be a file (and not an url)
+ // so we have to copy it from classpath to cache
+ File style = new File(cache, "easyant-report-graph.xsl");
+ FileUtil.copy(XmlReportOutputter.class
+ .getResourceAsStream("easyant-report-graph.xsl"), style, null);
+ return style.getAbsolutePath();
+ }
+
+ private String getXslPath() throws IOException {
+ if (xslFile != null) {
+ return xslFile;
+ }
+ // style should be a file (and not an url)
+ // so we have to copy it from classpath to cache
+ ResolutionCacheManager cacheMgr = getEasyAntIvyInstance()
+ .getResolutionCacheManager();
+ File style = new File(cacheMgr.getResolutionCacheRoot(),
+ "easyant-report.xsl");
+ FileUtil.copy(XmlEasyAntReportOutputter.class
+ .getResourceAsStream("easyant-report.xsl"), style, null);
+ return style.getAbsolutePath();
+ }
+
+ private String getDotStylePath(File cache) throws IOException {
+ // style should be a file (and not an url)
+ // so we have to copy it from classpath to cache
+ File style = new File(cache, "easyant-report-dot.xsl");
+ FileUtil.copy(XmlEasyAntReportOutputter.class
+ .getResourceAsStream("easyant-report-dot.xsl"), style, null);
+ return style.getAbsolutePath();
+ }
+
+ public File getTodir() {
+ if (todir == null && getProject() != null) {
+ return getProject().getBaseDir();
+ }
+ return todir;
+ }
+
+ public void setTodir(File todir) {
+ this.todir = todir;
+ }
+
+ public boolean isGraph() {
+ return graph;
+ }
+
+ public void setGraph(boolean graph) {
+ this.graph = graph;
+ }
+
+ public String getXslfile() {
+ return xslFile;
+ }
+
+ public void setXslfile(String xslFile) {
+ this.xslFile = xslFile;
+ }
+
+ public boolean isXml() {
+ return xml;
+ }
+
+ public void setXml(boolean xml) {
+ this.xml = xml;
+ }
+
+ public boolean isXsl() {
+ return xsl;
+ }
+
+ public void setXsl(boolean xsl) {
+ this.xsl = xsl;
+ }
+
+ public String getXslext() {
+ return xslext;
+ }
+
+ public void setXslext(String xslext) {
+ this.xslext = xslext;
+ }
+
+ public XSLTProcess.Param createParam() {
+ XSLTProcess.Param result = new XSLTProcess.Param();
+ params.add(result);
+ return result;
+ }
+
+ public String getOutputname() {
+ return outputname;
+ }
+
+ public void setOutputname(String outputpattern) {
+ outputname = outputpattern;
+ }
+
+ public String getMatcher() {
+ return matcher;
+ }
+
+ public void setMatcher(String matcher) {
+ this.matcher = matcher;
+ }
+
+ public String getModule() {
+ return module;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ public String getOrganisation() {
+ return organisation;
+ }
+
+ public void setOrganisation(String organisation) {
+ this.organisation = organisation;
+ }
+
+ public String getRevision() {
+ return revision;
+ }
+
+ public void setRevision(String revision) {
+ this.revision = revision;
+ }
+
+ public String getBranch() {
+ return branch;
+ }
+
+ public void setBranch(String branch) {
+ this.branch = branch;
+ }
+
+ public boolean isDot() {
+ return dot;
+ }
+
+ public void setDot(boolean dot) {
+ this.dot = dot;
+ }
+
+ public boolean isDisplaySubProperties() {
+ return displaySubProperties;
+ }
+
+ public void setDisplaySubProperties(boolean displaySubProperties) {
+ this.displaySubProperties = displaySubProperties;
+ }
public String getResolver() {
return resolver;
@@ -355,116 +355,116 @@ public class RepositoryReport extends Ab
this.resolver = resolver;
}
- /**
- * Add a menu generator context, to which menu entries will be published for each report file created.
- */
- public ReportMenu createMenuGenerator() {
- ReportMenu menu = new ReportMenu();
- menus.add(menu);
- return menu;
- }
-
- /**
- * Represents a single menu generator context, to which entries will be added as repository report files
- * are created. The attribute {@link #setContext context} is required. Additionally supports three optional nested
- * elements:
- * <ol>
- * <li><code>mapper</code> maps report file to menu item title and link path (both title and link path
- * will have the same value). The mapped title and link path are arguments to {@link MenuGenerator#addEntry(String, String)}.</li>
- * <li><code>linkMapper</code> maps report file to menu item link. <code>linkMapper</code> and <code>titleMapper</code>
- * can be used together as an alternative to <code>mapper</code>, in cases were the link and title for the menu entry
- * have different values.</li>
- * <li><code>titleMapper</code> maps report file to menu item title. <code>linkMapper</code> and <code>titleMapper</code>
- * can be used together as an alternative to <code>mapper</code>, in cases were the link and title for the menu entry
- * have different values.</li>
- * </ol>
- * If none of the above elements are provided,
- */
- public class ReportMenu {
-
- private Mapper titleMapper;
- private Mapper linkMapper;
-
- private String context;
- private MenuGeneratorRegistry registry;
-
- //TreeMap to sort menu entries in alphabetical order. should this behavior be configurable somehow?
- private Map<String,String> entries = new TreeMap<String,String>();
-
- /**
- * Set the menu generator context name. Entries will be added to this context for each generated report file.
- * @see MenuGenerateRegistry
- */
- public void setContext(String context) {
- this.context = context;
- }
-
- public Mapper createMapper() {
- return createLinkMapper();
- }
-
- public void setMapper(String typeName, String from, String to) {
- setLinkMapper(typeName, from, to);
- }
-
- public Mapper createTitleMapper() {
- return titleMapper = new Mapper(getProject());
- }
-
- public void setTitleMapper(String typeName, String from, String to) {
- configureMapper(createTitleMapper(), typeName, from, to);
- }
-
- public Mapper createLinkMapper() {
- return linkMapper = new Mapper(getProject());
- }
-
- public void setLinkMapper(String typeName, String from, String to) {
- configureMapper(createLinkMapper(), typeName, from, to);
- }
-
- public void addEntry(String reportPath) {
- String link = map(reportPath, linkMapper, reportPath);
- String title = map(reportPath, titleMapper, link);
-
- entries.put(title, link);
- }
-
- public void generate() throws IOException {
- for (Map.Entry<String,String> entry : entries.entrySet()) {
- for (MenuGenerator generator : getRegistry().getMenuGenerators()) {
- generator.addEntry(entry.getValue(), entry.getKey());
- }
- }
- }
-
- private MenuGeneratorRegistry getRegistry() {
- if (registry == null) {
- registry = MenuGeneratorUtils.getRegistryForContext(getProject(), context, false);
- }
- return registry;
- }
-
- private void configureMapper(Mapper mapper, String typeName, String from, String to) {
- Mapper.MapperType type = new Mapper.MapperType();
- type.setValue(typeName);
-
- mapper.setType(type);
- mapper.setFrom(from);
- mapper.setTo(to);
- }
-
- private String map(String reportPath, Mapper mapper, String defaultValue) {
- if (mapper != null) {
- String[] mappedTitle = mapper.getImplementation().mapFileName(reportPath);
- if (mappedTitle != null && mappedTitle.length > 0) {
- return mappedTitle[0];
- }
- }
- return defaultValue;
- }
+ /**
+ * Add a menu generator context, to which menu entries will be published for each report file created.
+ */
+ public ReportMenu createMenuGenerator() {
+ ReportMenu menu = new ReportMenu();
+ menus.add(menu);
+ return menu;
+ }
+
+ /**
+ * Represents a single menu generator context, to which entries will be added as repository report files
+ * are created. The attribute {@link #setContext context} is required. Additionally supports three optional nested
+ * elements:
+ * <ol>
+ * <li><code>mapper</code> maps report file to menu item title and link path (both title and link path
+ * will have the same value). The mapped title and link path are arguments to {@link MenuGenerator#addEntry(String, String)}.</li>
+ * <li><code>linkMapper</code> maps report file to menu item link. <code>linkMapper</code> and <code>titleMapper</code>
+ * can be used together as an alternative to <code>mapper</code>, in cases were the link and title for the menu entry
+ * have different values.</li>
+ * <li><code>titleMapper</code> maps report file to menu item title. <code>linkMapper</code> and <code>titleMapper</code>
+ * can be used together as an alternative to <code>mapper</code>, in cases were the link and title for the menu entry
+ * have different values.</li>
+ * </ol>
+ * If none of the above elements are provided,
+ */
+ public class ReportMenu {
+
+ private Mapper titleMapper;
+ private Mapper linkMapper;
+
+ private String context;
+ private MenuGeneratorRegistry registry;
+
+ //TreeMap to sort menu entries in alphabetical order. should this behavior be configurable somehow?
+ private Map<String,String> entries = new TreeMap<String,String>();
+
+ /**
+ * Set the menu generator context name. Entries will be added to this context for each generated report file.
+ * @see MenuGenerateRegistry
+ */
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+ public Mapper createMapper() {
+ return createLinkMapper();
+ }
+
+ public void setMapper(String typeName, String from, String to) {
+ setLinkMapper(typeName, from, to);
+ }
+
+ public Mapper createTitleMapper() {
+ return titleMapper = new Mapper(getProject());
+ }
+
+ public void setTitleMapper(String typeName, String from, String to) {
+ configureMapper(createTitleMapper(), typeName, from, to);
+ }
+
+ public Mapper createLinkMapper() {
+ return linkMapper = new Mapper(getProject());
+ }
+
+ public void setLinkMapper(String typeName, String from, String to) {
+ configureMapper(createLinkMapper(), typeName, from, to);
+ }
+
+ public void addEntry(String reportPath) {
+ String link = map(reportPath, linkMapper, reportPath);
+ String title = map(reportPath, titleMapper, link);
+
+ entries.put(title, link);
+ }
+
+ public void generate() throws IOException {
+ for (Map.Entry<String,String> entry : entries.entrySet()) {
+ for (MenuGenerator generator : getRegistry().getMenuGenerators()) {
+ generator.addEntry(entry.getValue(), entry.getKey());
+ }
+ }
+ }
+
+ private MenuGeneratorRegistry getRegistry() {
+ if (registry == null) {
+ registry = MenuGeneratorUtils.getRegistryForContext(getProject(), context, false);
+ }
+ return registry;
+ }
- }
+ private void configureMapper(Mapper mapper, String typeName, String from, String to) {
+ Mapper.MapperType type = new Mapper.MapperType();
+ type.setValue(typeName);
+
+ mapper.setType(type);
+ mapper.setFrom(from);
+ mapper.setTo(to);
+ }
+
+ private String map(String reportPath, Mapper mapper, String defaultValue) {
+ if (mapper != null) {
+ String[] mappedTitle = mapper.getImplementation().mapFileName(reportPath);
+ if (mappedTitle != null && mappedTitle.length > 0) {
+ return mappedTitle[0];
+ }
+ }
+ return defaultValue;
+ }
+
+ }
/** accumulates a set of input XML files and their transformed destination files */
private class XslReport {
@@ -531,9 +531,9 @@ public class RepositoryReport extends Ab
xslt.execute();
- for (ReportMenu menu : menus) {
- menu.generate();
- }
+ for (ReportMenu menu : menus) {
+ menu.generate();
+ }
}
/**
@@ -543,9 +543,9 @@ public class RepositoryReport extends Ab
public void add(File source, String destination) {
map.put(source.getPath(), destination + "." + extension);
createPathElement().setLocation(source);
- for (ReportMenu menu : menus) {
- menu.addEntry(destination);
- }
+ for (ReportMenu menu : menus) {
+ menu.addEntry(destination);
+ }
}
public void setFrom(String s) {}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SearchModule.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SearchModule.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SearchModule.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SearchModule.java Tue Feb 22 15:55:55 2011
@@ -34,163 +34,163 @@ import org.apache.tools.ant.input.Multip
public class SearchModule extends IvyTask {
- private String organisation;
+ private String organisation;
- private String module;
+ private String module;
- private String branch = PatternMatcher.ANY_EXPRESSION;
+ private String branch = PatternMatcher.ANY_EXPRESSION;
- private String revision;
+ private String revision;
- private String matcher = PatternMatcher.EXACT_OR_REGEXP;
-
- private String propertyPrefix;
- private String resolver;
-
- public void doExecute() throws BuildException {
- if (getOrganisation() == null) {
- throw new BuildException(
- "no organisation provided for SearchModule task");
- }
- if (getModule() == null) {
- throw new BuildException(
- "no module name provided for SearchModule task");
- }
- if (getRevision() == null) {
- throw new BuildException(
- "no revision provided for SearchModule task");
- }
-
- if (getPropertyPrefix() == null) {
- throw new BuildException(
- "no property prefix provided provided for SearchModule task");
- }
- Ivy ivy = getIvyInstance();
- IvySettings settings = ivy.getSettings();
-
- // search all modules revision matching the requested criteria
- DependencyResolver resolverToCheck;
- if (getResolver() != null) {
- resolverToCheck = settings.getResolver(getResolver());
- } else {
- resolverToCheck = settings.getDefaultResolver();
- }
- ModuleRevisionId mridToSearch = ModuleRevisionId.newInstance(
- getOrganisation(), getModule(), getBranch(), getRevision());
- ModuleRevisionId[] mrids = ivy.getSearchEngine().listModules(
- resolverToCheck, mridToSearch, settings.getMatcher(matcher));
-
- // diplay the list
- Vector<String> choices = new Vector<String>();
- for (int i = 0; i < mrids.length; i++) {
- choices.add(String.valueOf(i));
- StringBuilder sb = new StringBuilder();
- sb.append(i).append(": ");
- sb.append(mrids[i].getName());
- sb.append(" v").append(mrids[i].getRevision());
- // hide organization if its the default one
- if (!mrids[i].getOrganisation().equals(
- EasyAntConstants.EASYANT_SKELETONS_ORGANISATION))
- sb.append(" by ").append(mrids[i].getOrganisation());
- // Get the description
- ResolvedModuleRevision rmr = ivy.findModule(mrids[i]);
- if (rmr.getDescriptor().getDescription() != null
- && !rmr.getDescriptor().getDescription().equals("")) {
- sb.append(" (").append(rmr.getDescriptor().getDescription())
- .append(")");
- }
- log(sb.toString());
-
- }
-
-
- // ask end user to select a module
- //TODO handle a default value
- Integer value = new Integer(getInput("Choose a number:", null, choices));
- ModuleRevisionId moduleToRetrieve = mrids[value];
-
- // set final properties
- getProject().setProperty(getPropertyPrefix() + ".org",
- moduleToRetrieve.getOrganisation());
- getProject().setProperty(getPropertyPrefix() + ".module",
- moduleToRetrieve.getName());
- getProject().setProperty(getPropertyPrefix() + ".rev",
- moduleToRetrieve.getRevision());
-
- }
-
- protected String getInput(String message, String defaultvalue, Vector<String> choices) {
- InputRequest request = null;
- request = new MultipleChoiceInputRequest(message, choices);
- request.setDefaultValue(defaultvalue);
-
- InputHandler h = getProject().getInputHandler();
-
- h.handleInput(request);
-
- String value = request.getInput();
- if ((value == null || value.trim().length() == 0)
- && defaultvalue != null) {
- value = defaultvalue;
- }
- return value;
-
- }
-
- public String getMatcher() {
- return matcher;
- }
-
- public void setMatcher(String matcher) {
- this.matcher = matcher;
- }
-
- public String getModule() {
- return module;
- }
-
- public void setModule(String module) {
- this.module = module;
- }
-
- public String getOrganisation() {
- return organisation;
- }
-
- public void setOrganisation(String organisation) {
- this.organisation = organisation;
- }
-
- public String getRevision() {
- return revision;
- }
-
- public void setRevision(String revision) {
- this.revision = revision;
- }
-
- public String getBranch() {
- return branch;
- }
-
- public void setBranch(String branch) {
- this.branch = branch;
- }
-
- public String getPropertyPrefix() {
- return propertyPrefix;
- }
-
- public void setPropertyPrefix(String propertyPrefix) {
- this.propertyPrefix = propertyPrefix;
- }
-
- public String getResolver() {
- return resolver;
- }
-
- public void setResolver(String resolver) {
- this.resolver = resolver;
- }
+ private String matcher = PatternMatcher.EXACT_OR_REGEXP;
+
+ private String propertyPrefix;
+ private String resolver;
+
+ public void doExecute() throws BuildException {
+ if (getOrganisation() == null) {
+ throw new BuildException(
+ "no organisation provided for SearchModule task");
+ }
+ if (getModule() == null) {
+ throw new BuildException(
+ "no module name provided for SearchModule task");
+ }
+ if (getRevision() == null) {
+ throw new BuildException(
+ "no revision provided for SearchModule task");
+ }
+
+ if (getPropertyPrefix() == null) {
+ throw new BuildException(
+ "no property prefix provided provided for SearchModule task");
+ }
+ Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
+
+ // search all modules revision matching the requested criteria
+ DependencyResolver resolverToCheck;
+ if (getResolver() != null) {
+ resolverToCheck = settings.getResolver(getResolver());
+ } else {
+ resolverToCheck = settings.getDefaultResolver();
+ }
+ ModuleRevisionId mridToSearch = ModuleRevisionId.newInstance(
+ getOrganisation(), getModule(), getBranch(), getRevision());
+ ModuleRevisionId[] mrids = ivy.getSearchEngine().listModules(
+ resolverToCheck, mridToSearch, settings.getMatcher(matcher));
+
+ // diplay the list
+ Vector<String> choices = new Vector<String>();
+ for (int i = 0; i < mrids.length; i++) {
+ choices.add(String.valueOf(i));
+ StringBuilder sb = new StringBuilder();
+ sb.append(i).append(": ");
+ sb.append(mrids[i].getName());
+ sb.append(" v").append(mrids[i].getRevision());
+ // hide organization if its the default one
+ if (!mrids[i].getOrganisation().equals(
+ EasyAntConstants.EASYANT_SKELETONS_ORGANISATION))
+ sb.append(" by ").append(mrids[i].getOrganisation());
+ // Get the description
+ ResolvedModuleRevision rmr = ivy.findModule(mrids[i]);
+ if (rmr.getDescriptor().getDescription() != null
+ && !rmr.getDescriptor().getDescription().equals("")) {
+ sb.append(" (").append(rmr.getDescriptor().getDescription())
+ .append(")");
+ }
+ log(sb.toString());
+
+ }
+
+
+ // ask end user to select a module
+ //TODO handle a default value
+ Integer value = new Integer(getInput("Choose a number:", null, choices));
+ ModuleRevisionId moduleToRetrieve = mrids[value];
+
+ // set final properties
+ getProject().setProperty(getPropertyPrefix() + ".org",
+ moduleToRetrieve.getOrganisation());
+ getProject().setProperty(getPropertyPrefix() + ".module",
+ moduleToRetrieve.getName());
+ getProject().setProperty(getPropertyPrefix() + ".rev",
+ moduleToRetrieve.getRevision());
+
+ }
+
+ protected String getInput(String message, String defaultvalue, Vector<String> choices) {
+ InputRequest request = null;
+ request = new MultipleChoiceInputRequest(message, choices);
+ request.setDefaultValue(defaultvalue);
+
+ InputHandler h = getProject().getInputHandler();
+
+ h.handleInput(request);
+
+ String value = request.getInput();
+ if ((value == null || value.trim().length() == 0)
+ && defaultvalue != null) {
+ value = defaultvalue;
+ }
+ return value;
+
+ }
+
+ public String getMatcher() {
+ return matcher;
+ }
+
+ public void setMatcher(String matcher) {
+ this.matcher = matcher;
+ }
+
+ public String getModule() {
+ return module;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ public String getOrganisation() {
+ return organisation;
+ }
+
+ public void setOrganisation(String organisation) {
+ this.organisation = organisation;
+ }
+
+ public String getRevision() {
+ return revision;
+ }
+
+ public void setRevision(String revision) {
+ this.revision = revision;
+ }
+
+ public String getBranch() {
+ return branch;
+ }
+
+ public void setBranch(String branch) {
+ this.branch = branch;
+ }
+
+ public String getPropertyPrefix() {
+ return propertyPrefix;
+ }
+
+ public void setPropertyPrefix(String propertyPrefix) {
+ this.propertyPrefix = propertyPrefix;
+ }
+
+ public String getResolver() {
+ return resolver;
+ }
+
+ public void setResolver(String resolver) {
+ this.resolver = resolver;
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/SubModule.java Tue Feb 22 15:55:55 2011
@@ -52,508 +52,513 @@ import org.apache.tools.ant.util.StringU
*/
public class SubModule extends Task {
- private boolean failOnError = true;
- private boolean verbose = false;
- private String moduleFile = EasyAntConstants.DEFAULT_BUILD_MODULE;
-
- private Path buildpath;
- private TargetList targets = null;
- private boolean useBuildRepository = false;
- private boolean overwrite = true;
-
- public void execute() throws BuildException {
- if (buildpath == null) {
- throw new BuildException("No buildpath specified");
- }
- final String[] filenames = buildpath.list();
- final int count = filenames.length;
- if (count < 1) {
- log("No sub-builds to iterate on", Project.MSG_WARN);
- return;
- }
-
- // Change the default output logger
- PrintStream out = System.out;
- PrintStream err = System.err;
- int currentLogLevel = Project.MSG_INFO;
- log("removing current logger", Project.MSG_DEBUG);
- // since BuildLogger doesn't offer any way to get the out / err print
- // streams we should use reflection
- // TODO: we should find a better way to do this
- for (Iterator<?> i = getProject().getBuildListeners().iterator(); i
- .hasNext();) {
- BuildListener l = (BuildListener) i.next();
- if (l instanceof DefaultLogger) {
- Field fields[];
- //case of classes extending DefaultLogger
- if (l.getClass().getSuperclass() == DefaultLogger.class) {
- fields = l.getClass().getSuperclass().getDeclaredFields();
- } else {
- fields = l.getClass().getDeclaredFields();
- }
-
- for (int j = 0; j < fields.length; j++) {
- try {
- if (fields[j].getType().equals(PrintStream.class)
- && fields[j].getName().equals("out")) {
- fields[j].setAccessible(true);
- out = (PrintStream) fields[j].get(l);
- fields[j].setAccessible(false);
- }
- if (fields[j].getType().equals(PrintStream.class)
- && fields[j].getName().equals("err")) {
- fields[j].setAccessible(true);
- err = (PrintStream) fields[j].get(l);
- fields[j].setAccessible(false);
- }
- if (fields[j].getName().equals("msgOutputLevel")) {
- fields[j].setAccessible(true);
- currentLogLevel = (Integer) fields[j].get(l);
- fields[j].setAccessible(false);
- }
- } catch (IllegalAccessException ex) {
- throw new BuildException(ex);
- }
- }
- }
- getProject().removeBuildListener(l);
-
- }
- log("Initializing BigProjectLogger", Project.MSG_DEBUG);
- // Intanciate the new logger
- BuildLogger bl = new MultiModuleLogger();
- bl.setOutputPrintStream(out);
- bl.setErrorPrintStream(err);
- bl.setMessageOutputLevel(currentLogLevel);
- getProject().setProjectReference(bl);
- getProject().addBuildListener(bl);
-
- BuildException buildException = null;
- for (int i = 0; i < count; ++i) {
- File file = null;
- String subdirPath = null;
- Throwable thrownException = null;
- try {
- File directory = null;
- file = new File(filenames[i]);
- if (file.isDirectory()) {
- if (verbose) {
- subdirPath = file.getPath();
- log("Entering directory: " + subdirPath + "\n",
- Project.MSG_INFO);
- }
- file = new File(file, moduleFile);
- }
- directory = file.getParentFile();
- execute(file, directory);
- if (verbose && subdirPath != null) {
- log("Leaving directory: " + subdirPath + "\n",
- Project.MSG_INFO);
- }
- } catch (RuntimeException ex) {
- if (!(getProject().isKeepGoingMode())) {
- if (verbose && subdirPath != null) {
- log("Leaving directory: " + subdirPath + "\n",
- Project.MSG_INFO);
- }
- throw ex; // throw further
- }
- thrownException = ex;
- } catch (Throwable ex) {
- if (!(getProject().isKeepGoingMode())) {
- if (verbose && subdirPath != null) {
- log("Leaving directory: " + subdirPath + "\n",
- Project.MSG_INFO);
- }
- throw new BuildException(ex);
- }
- thrownException = ex;
- }
- if (thrownException != null) {
- if (thrownException instanceof BuildException) {
- log("File '" + file + "' failed with message '"
- + thrownException.getMessage() + "'.",
- Project.MSG_ERR);
- // only the first build exception is reported
- if (buildException == null) {
- buildException = (BuildException) thrownException;
- }
- } else {
- log("Target '" + file + "' failed with message '"
- + thrownException.getMessage() + "'.",
- Project.MSG_ERR);
- thrownException.printStackTrace(System.err);
- if (buildException == null) {
- buildException = new BuildException(thrownException);
- }
- }
- if (verbose && subdirPath != null) {
- log("Leaving directory: " + subdirPath + "\n",
- Project.MSG_INFO);
- }
- }
- }
- // check if one of the builds failed in keep going mode
- if (buildException != null) {
- throw buildException;
- }
- }
-
- /**
- * Runs the given target on the provided build file.
- *
- * @param file
- * the build file to execute
- * @param directory
- * the directory of the current iteration
- * @throws BuildException
- * is the file cannot be found, read, is a directory, or the
- * target called failed, but only if <code>failOnError</code> is
- * <code>true</code>. Otherwise, a warning log message is simply
- * output.
- */
- private void execute(File file, File directory) throws BuildException {
- if (!file.exists() || file.isDirectory() || !file.canRead()) {
- String msg = "Invalid file: " + file;
- if (failOnError) {
- throw new BuildException(msg);
- }
- log(msg, Project.MSG_WARN);
- return;
- }
-
- Project subModule = getProject().createSubProject();
-
- subModule.setJavaVersionProperty();
-
- for (int i = 0; i < getProject().getBuildListeners().size(); i++) {
- BuildListener buildListener = (BuildListener) getProject()
- .getBuildListeners().elementAt(i);
- subModule.addBuildListener(buildListener);
- }
-
- subModule.setName(file.getName());
- subModule.setBaseDir(directory);
-
- subModule.fireSubBuildStarted();
-
- try {
- // Emulate an empty project
- // import task check that projectHelper is at toplevel by checking
- // the
- // size of projectHelper.getImportTask()
- ProjectHelper projectHelper = ProjectHelper.getProjectHelper();
- File mainscript;
- try {
- mainscript = File.createTempFile(
- EasyAntConstants.EASYANT_TASK_NAME, null);
- mainscript.deleteOnExit();
- } catch (IOException e1) {
- throw new BuildException("Can't create temp file", e1);
- }
-
- @SuppressWarnings("unchecked")
- Vector<File> imports = projectHelper.getImportStack();
- imports.addElement(mainscript);
- subModule.addReference(ProjectHelper.PROJECTHELPER_REFERENCE,
- projectHelper);
-
- // copy all User properties
- addAlmostAll(getProject().getUserProperties(), subModule,
- PropertyType.USER);
-
- // copy easyantIvyInstance
- IvyAntSettings ivyAntSettings = IvyInstanceHelper.getEasyAntIvyAntSettings(getProject());
- subModule.addReference(EasyAntMagicNames.EASYANT_IVY_INSTANCE,
- ivyAntSettings);
-
- // buildFile should be in the same directory of buildModule
- File buildfile = new File(directory,
- EasyAntConstants.DEFAULT_BUILD_FILE);
- if (buildfile.exists()) {
- subModule.setNewProperty(MagicNames.ANT_FILE, buildfile
- .getAbsolutePath());
- }
- subModule.setNewProperty(EasyAntMagicNames.EASYANT_FILE, file
- .getAbsolutePath());
-
- // inherit meta.target directory, for shared build repository.
- String metaTarget = getProject().getProperty("meta.target");
- if (metaTarget != null) {
- File metaDir = getProject().resolveFile(metaTarget);
- subModule.setNewProperty("meta.target", metaDir
- .getAbsolutePath());
- }
-
- // Used to emulate top level target
- Target topLevel = new Target();
- topLevel.setName("");
-
- LoadModule lm = new LoadModule();
- lm.setBuildModule(file);
- lm.setBuildFile(buildfile);
- lm.setTaskName(EasyAntConstants.EASYANT_TASK_NAME);
- lm.setProject(subModule);
- lm.setOwningTarget(topLevel);
- lm.setLocation(new Location(mainscript.toString()));
- lm.setUseBuildRepository(useBuildRepository);
- lm.execute();
-
- filterTargets(subModule);
- printExecutingTargetMsg(subModule);
-
- if (targets != null && !targets.isEmpty()) {
- subModule.executeTargets(targets);
- if (useBuildRepository) {
-
- File artifactsDir = subModule.resolveFile(subModule
- .getProperty("target.artifacts"));
- if (artifactsDir.isDirectory()) {
-
- // this property set by LoadModule task when it
- // configures the build repo
- String resolver = subModule
- .getProperty(EasyAntMagicNames.EASYANT_BUILD_REPOSITORY);
-
- subModule.log("Publishing in build scoped repository",
- Project.MSG_INFO);
- // Publish on build scoped repository
- IvyPublish ivyPublish = new IvyPublish();
- ivyPublish.setSettingsRef(IvyInstanceHelper.buildProjectIvyReference(subModule));
- ivyPublish.setResolver(resolver);
- // TODO: this should be more flexible!
- ivyPublish
- .setArtifactspattern("${target.artifacts}/[artifact](-[classifier]).[ext]");
- // not all sub-build targets will generate ivy
- // artifacts. we don't want to fail
- // a successful build just because there's nothing to
- // publish.
- ivyPublish.setWarnonmissing(false);
- ivyPublish.setHaltonmissing(false);
- ivyPublish.setProject(subModule);
- ivyPublish.setOwningTarget(getOwningTarget());
- ivyPublish.setLocation(getLocation());
- ivyPublish.setOverwrite(overwrite);
- ivyPublish.execute();
- } else {
- subModule.log("Skipping publish because "
- + artifactsDir.getPath()
- + " is not a directory", Project.MSG_VERBOSE);
- }
- }
- } else {
- subModule
- .log(
- "Skipping sub-project build because no matching targets were found",
- Project.MSG_VERBOSE);
- }
- subModule.fireSubBuildFinished(null);
- } catch (BuildException e) {
- subModule.fireSubBuildFinished(e);
- throw e;
- }
-
- }
-
- /**
- * Filter the active set of targets to only those defined in the given
- * project.
- */
- private void filterTargets(Project subProject) {
- Set<?> keys = subProject.getTargets().keySet();
- for (Iterator<String> it = targets.iterator(); it.hasNext();) {
- String target = it.next();
- if (!keys.contains(target) && target.trim().length() > 0) {
- subProject.log("Skipping undefined target '" + target + "'",
- Project.MSG_VERBOSE);
- it.remove();
- }
- }
- }
-
- /**
- * Print a message when executing the target
- *
- * @param subProject
- * a subproject where the log will be printed
- */
- private void printExecutingTargetMsg(Project subProject) {
- final String HEADER = "======================================================================";
- StringBuilder sb = new StringBuilder();
- sb.append(HEADER).append(StringUtils.LINE_SEP);
- sb.append("Executing ").append(targets).append(" on ").append(
- subProject.getName());
- sb.append(StringUtils.LINE_SEP).append(HEADER);
- subProject.log(sb.toString());
- }
-
- /**
- * Copies all properties from the given table to the new project - omitting
- * those that have already been set in the new project as well as properties
- * named basedir or ant.file.
- *
- * @param props
- * properties <code>Hashtable</code> to copy to the new project.
- * @param the
- * type of property to set (a plain Ant property, a user property
- * or an inherited property).
- * @since Ant 1.8.0
- */
- private void addAlmostAll(Hashtable<?, ?> props, Project subProject,
- PropertyType type) {
- Enumeration<?> e = props.keys();
- while (e.hasMoreElements()) {
- String key = e.nextElement().toString();
- if (MagicNames.PROJECT_BASEDIR.equals(key)
- || MagicNames.ANT_FILE.equals(key)) {
- // basedir and ant.file get special treatment in execute()
- continue;
- }
-
- String value = props.get(key).toString();
- if (type == PropertyType.PLAIN) {
- // don't re-set user properties, avoid the warning message
- if (subProject.getProperty(key) == null) {
- // no user property
- subProject.setNewProperty(key, value);
- }
- } else if (type == PropertyType.USER) {
- subProject.setUserProperty(key, value);
- } else if (type == PropertyType.INHERITED) {
- subProject.setInheritedProperty(key, value);
- }
- }
- }
-
- private static final class PropertyType {
- private PropertyType() {
- }
-
- private static final PropertyType PLAIN = new PropertyType();
- private static final PropertyType INHERITED = new PropertyType();
- private static final PropertyType USER = new PropertyType();
- }
-
- /**
- * The target to call on the different sub-builds. Set to "" to execute the
- * default target.
- *
- * @param target
- * the target
- * <p>
- */
- // REVISIT: Defaults to the target name that contains this task if not
- // specified.
- public void setTarget(String target) {
- setTargets(new TargetList(target));
- }
-
- /**
- * The targets to call on the different sub-builds.
- *
- * @param target
- * a list of targets to execute
- */
- public void setTargets(TargetList targets) {
- this.targets = targets;
- }
-
- /**
- * Set the buildpath to be used to find sub-projects.
- *
- * @param s
- * an Ant Path object containing the buildpath.
- */
- public void setBuildpath(Path s) {
- getBuildpath().append(s);
- }
-
- /**
- * Gets the implicit build path, creating it if <code>null</code>.
- *
- * @return the implicit build path.
- */
- private Path getBuildpath() {
- if (buildpath == null) {
- buildpath = new Path(getProject());
- }
- return buildpath;
- }
-
- /**
- * Buildpath to use, by reference.
- *
- * @param r
- * a reference to an Ant Path object containing the buildpath.
- */
- public void setBuildpathRef(Reference r) {
- createBuildpath().setRefid(r);
- }
-
- /**
- * Creates a nested build path, and add it to the implicit build path.
- *
- * @return the newly created nested build path.
- */
- public Path createBuildpath() {
- return getBuildpath().createPath();
- }
-
- /**
- * Enable/ disable verbose log messages showing when each sub-build path is
- * entered/ exited. The default value is "false".
- *
- * @param on
- * true to enable verbose mode, false otherwise (default).
- */
- public void setVerbose(boolean on) {
- this.verbose = on;
- }
-
- /**
- * Sets whether to fail with a build exception on error, or go on.
- *
- * @param failOnError
- * the new value for this boolean flag.
- */
- public void setFailonerror(boolean failOnError) {
- this.failOnError = failOnError;
- }
-
- /**
- * Sets whether a submodule should use build repository or not
- *
- * @param useBuildRepository
- * the new value for this boolean flag
- */
- public void setUseBuildRepository(boolean useBuildRepository) {
- this.useBuildRepository = useBuildRepository;
- }
-
- /**
- * Set whether publish operations for the
- * {@link #setUseBuildRepository(boolean) build-scoped repository} should
- * overwrite existing artifacts. Defaults to <code>true</code> if
- * unspecified.
- */
- public void setOverwrite(boolean overwrite) {
- this.overwrite = overwrite;
- }
-
- /**
- * A Vector or target names, which can be constructed from a simple
- * comma-separated list of values.
- */
- public static class TargetList extends Vector<String> {
- private static final long serialVersionUID = 2302999727821991487L;
-
- public TargetList(String commaSeparated) {
- this(commaSeparated.split(","));
- }
-
- public TargetList(String... targets) {
- for (String target : targets)
- add(target);
- }
- }
+ private boolean failOnError = true;
+ private boolean verbose = false;
+ private String moduleFile = EasyAntConstants.DEFAULT_BUILD_MODULE;
+
+ private Path buildpath;
+ private TargetList targets = null;
+ private boolean useBuildRepository = false;
+ private boolean overwrite = true;
+
+ public void execute() throws BuildException {
+ if (buildpath == null) {
+ throw new BuildException("No buildpath specified");
+ }
+ final String[] filenames = buildpath.list();
+ final int count = filenames.length;
+ if (count < 1) {
+ log("No sub-builds to iterate on", Project.MSG_WARN);
+ return;
+ }
+
+ // Change the default output logger
+ PrintStream out = System.out;
+ PrintStream err = System.err;
+ int currentLogLevel = Project.MSG_INFO;
+ log("removing current logger", Project.MSG_DEBUG);
+ // since BuildLogger doesn't offer any way to get the out / err print
+ // streams we should use reflection
+ // TODO: we should find a better way to do this
+ for (Iterator<?> i = getProject().getBuildListeners().iterator(); i
+ .hasNext();) {
+ BuildListener l = (BuildListener) i.next();
+ if (l instanceof DefaultLogger) {
+ Field fields[];
+ //case of classes extending DefaultLogger
+ if (l.getClass().getSuperclass() == DefaultLogger.class) {
+ fields = l.getClass().getSuperclass().getDeclaredFields();
+ } else {
+ fields = l.getClass().getDeclaredFields();
+ }
+
+ for (int j = 0; j < fields.length; j++) {
+ try {
+ if (fields[j].getType().equals(PrintStream.class)
+ && fields[j].getName().equals("out")) {
+ fields[j].setAccessible(true);
+ out = (PrintStream) fields[j].get(l);
+ fields[j].setAccessible(false);
+ }
+ if (fields[j].getType().equals(PrintStream.class)
+ && fields[j].getName().equals("err")) {
+ fields[j].setAccessible(true);
+ err = (PrintStream) fields[j].get(l);
+ fields[j].setAccessible(false);
+ }
+ if (fields[j].getName().equals("msgOutputLevel")) {
+ fields[j].setAccessible(true);
+ currentLogLevel = (Integer) fields[j].get(l);
+ fields[j].setAccessible(false);
+ }
+ } catch (IllegalAccessException ex) {
+ throw new BuildException(ex);
+ }
+ }
+ }
+ getProject().removeBuildListener(l);
+
+ }
+ log("Initializing BigProjectLogger", Project.MSG_DEBUG);
+ // Intanciate the new logger
+ BuildLogger bl = new MultiModuleLogger();
+ bl.setOutputPrintStream(out);
+ bl.setErrorPrintStream(err);
+ bl.setMessageOutputLevel(currentLogLevel);
+ getProject().setProjectReference(bl);
+ getProject().addBuildListener(bl);
+
+ BuildException buildException = null;
+ for (int i = 0; i < count; ++i) {
+ File file = null;
+ String subdirPath = null;
+ Throwable thrownException = null;
+ try {
+ File directory = null;
+ file = new File(filenames[i]);
+ if (file.isDirectory()) {
+ if (verbose) {
+ subdirPath = file.getPath();
+ log("Entering directory: " + subdirPath + "
+",
+ Project.MSG_INFO);
+ }
+ file = new File(file, moduleFile);
+ }
+ directory = file.getParentFile();
+ execute(file, directory);
+ if (verbose && subdirPath != null) {
+ log("Leaving directory: " + subdirPath + "
+",
+ Project.MSG_INFO);
+ }
+ } catch (RuntimeException ex) {
+ if (!(getProject().isKeepGoingMode())) {
+ if (verbose && subdirPath != null) {
+ log("Leaving directory: " + subdirPath + "
+",
+ Project.MSG_INFO);
+ }
+ throw ex; // throw further
+ }
+ thrownException = ex;
+ } catch (Throwable ex) {
+ if (!(getProject().isKeepGoingMode())) {
+ if (verbose && subdirPath != null) {
+ log("Leaving directory: " + subdirPath + "
+",
+ Project.MSG_INFO);
+ }
+ throw new BuildException(ex);
+ }
+ thrownException = ex;
+ }
+ if (thrownException != null) {
+ if (thrownException instanceof BuildException) {
+ log("File '" + file + "' failed with message '"
+ + thrownException.getMessage() + "'.",
+ Project.MSG_ERR);
+ // only the first build exception is reported
+ if (buildException == null) {
+ buildException = (BuildException) thrownException;
+ }
+ } else {
+ log("Target '" + file + "' failed with message '"
+ + thrownException.getMessage() + "'.",
+ Project.MSG_ERR);
+ thrownException.printStackTrace(System.err);
+ if (buildException == null) {
+ buildException = new BuildException(thrownException);
+ }
+ }
+ if (verbose && subdirPath != null) {
+ log("Leaving directory: " + subdirPath + "
+",
+ Project.MSG_INFO);
+ }
+ }
+ }
+ // check if one of the builds failed in keep going mode
+ if (buildException != null) {
+ throw buildException;
+ }
+ }
+
+ /**
+ * Runs the given target on the provided build file.
+ *
+ * @param file
+ * the build file to execute
+ * @param directory
+ * the directory of the current iteration
+ * @throws BuildException
+ * is the file cannot be found, read, is a directory, or the
+ * target called failed, but only if <code>failOnError</code> is
+ * <code>true</code>. Otherwise, a warning log message is simply
+ * output.
+ */
+ private void execute(File file, File directory) throws BuildException {
+ if (!file.exists() || file.isDirectory() || !file.canRead()) {
+ String msg = "Invalid file: " + file;
+ if (failOnError) {
+ throw new BuildException(msg);
+ }
+ log(msg, Project.MSG_WARN);
+ return;
+ }
+
+ Project subModule = getProject().createSubProject();
+
+ subModule.setJavaVersionProperty();
+
+ for (int i = 0; i < getProject().getBuildListeners().size(); i++) {
+ BuildListener buildListener = (BuildListener) getProject()
+ .getBuildListeners().elementAt(i);
+ subModule.addBuildListener(buildListener);
+ }
+
+ subModule.setName(file.getName());
+ subModule.setBaseDir(directory);
+
+ subModule.fireSubBuildStarted();
+
+ try {
+ // Emulate an empty project
+ // import task check that projectHelper is at toplevel by checking
+ // the
+ // size of projectHelper.getImportTask()
+ ProjectHelper projectHelper = ProjectHelper.getProjectHelper();
+ File mainscript;
+ try {
+ mainscript = File.createTempFile(
+ EasyAntConstants.EASYANT_TASK_NAME, null);
+ mainscript.deleteOnExit();
+ } catch (IOException e1) {
+ throw new BuildException("Can't create temp file", e1);
+ }
+
+ @SuppressWarnings("unchecked")
+ Vector<File> imports = projectHelper.getImportStack();
+ imports.addElement(mainscript);
+ subModule.addReference(ProjectHelper.PROJECTHELPER_REFERENCE,
+ projectHelper);
+
+ // copy all User properties
+ addAlmostAll(getProject().getUserProperties(), subModule,
+ PropertyType.USER);
+
+ // copy easyantIvyInstance
+ IvyAntSettings ivyAntSettings = IvyInstanceHelper.getEasyAntIvyAntSettings(getProject());
+ subModule.addReference(EasyAntMagicNames.EASYANT_IVY_INSTANCE,
+ ivyAntSettings);
+
+ // buildFile should be in the same directory of buildModule
+ File buildfile = new File(directory,
+ EasyAntConstants.DEFAULT_BUILD_FILE);
+ if (buildfile.exists()) {
+ subModule.setNewProperty(MagicNames.ANT_FILE, buildfile
+ .getAbsolutePath());
+ }
+ subModule.setNewProperty(EasyAntMagicNames.EASYANT_FILE, file
+ .getAbsolutePath());
+
+ // inherit meta.target directory, for shared build repository.
+ String metaTarget = getProject().getProperty("meta.target");
+ if (metaTarget != null) {
+ File metaDir = getProject().resolveFile(metaTarget);
+ subModule.setNewProperty("meta.target", metaDir
+ .getAbsolutePath());
+ }
+
+ // Used to emulate top level target
+ Target topLevel = new Target();
+ topLevel.setName("");
+
+ LoadModule lm = new LoadModule();
+ lm.setBuildModule(file);
+ lm.setBuildFile(buildfile);
+ lm.setTaskName(EasyAntConstants.EASYANT_TASK_NAME);
+ lm.setProject(subModule);
+ lm.setOwningTarget(topLevel);
+ lm.setLocation(new Location(mainscript.toString()));
+ lm.setUseBuildRepository(useBuildRepository);
+ lm.execute();
+
+ filterTargets(subModule);
+ printExecutingTargetMsg(subModule);
+
+ if (targets != null && !targets.isEmpty()) {
+ subModule.executeTargets(targets);
+ if (useBuildRepository) {
+
+ File artifactsDir = subModule.resolveFile(subModule
+ .getProperty("target.artifacts"));
+ if (artifactsDir.isDirectory()) {
+
+ // this property set by LoadModule task when it
+ // configures the build repo
+ String resolver = subModule
+ .getProperty(EasyAntMagicNames.EASYANT_BUILD_REPOSITORY);
+
+ subModule.log("Publishing in build scoped repository",
+ Project.MSG_INFO);
+ // Publish on build scoped repository
+ IvyPublish ivyPublish = new IvyPublish();
+ ivyPublish.setSettingsRef(IvyInstanceHelper.buildProjectIvyReference(subModule));
+ ivyPublish.setResolver(resolver);
+ // TODO: this should be more flexible!
+ ivyPublish
+ .setArtifactspattern("${target.artifacts}/[artifact](-[classifier]).[ext]");
+ // not all sub-build targets will generate ivy
+ // artifacts. we don't want to fail
+ // a successful build just because there's nothing to
+ // publish.
+ ivyPublish.setWarnonmissing(false);
+ ivyPublish.setHaltonmissing(false);
+ ivyPublish.setProject(subModule);
+ ivyPublish.setOwningTarget(getOwningTarget());
+ ivyPublish.setLocation(getLocation());
+ ivyPublish.setOverwrite(overwrite);
+ ivyPublish.execute();
+ } else {
+ subModule.log("Skipping publish because "
+ + artifactsDir.getPath()
+ + " is not a directory", Project.MSG_VERBOSE);
+ }
+ }
+ } else {
+ subModule
+ .log(
+ "Skipping sub-project build because no matching targets were found",
+ Project.MSG_VERBOSE);
+ }
+ subModule.fireSubBuildFinished(null);
+ } catch (BuildException e) {
+ subModule.fireSubBuildFinished(e);
+ throw e;
+ }
+
+ }
+
+ /**
+ * Filter the active set of targets to only those defined in the given
+ * project.
+ */
+ private void filterTargets(Project subProject) {
+ Set<?> keys = subProject.getTargets().keySet();
+ for (Iterator<String> it = targets.iterator(); it.hasNext();) {
+ String target = it.next();
+ if (!keys.contains(target) && target.trim().length() > 0) {
+ subProject.log("Skipping undefined target '" + target + "'",
+ Project.MSG_VERBOSE);
+ it.remove();
+ }
+ }
+ }
+
+ /**
+ * Print a message when executing the target
+ *
+ * @param subProject
+ * a subproject where the log will be printed
+ */
+ private void printExecutingTargetMsg(Project subProject) {
+ final String HEADER = "======================================================================";
+ StringBuilder sb = new StringBuilder();
+ sb.append(HEADER).append(StringUtils.LINE_SEP);
+ sb.append("Executing ").append(targets).append(" on ").append(
+ subProject.getName());
+ sb.append(StringUtils.LINE_SEP).append(HEADER);
+ subProject.log(sb.toString());
+ }
+
+ /**
+ * Copies all properties from the given table to the new project - omitting
+ * those that have already been set in the new project as well as properties
+ * named basedir or ant.file.
+ *
+ * @param props
+ * properties <code>Hashtable</code> to copy to the new project.
+ * @param the
+ * type of property to set (a plain Ant property, a user property
+ * or an inherited property).
+ * @since Ant 1.8.0
+ */
+ private void addAlmostAll(Hashtable<?, ?> props, Project subProject,
+ PropertyType type) {
+ Enumeration<?> e = props.keys();
+ while (e.hasMoreElements()) {
+ String key = e.nextElement().toString();
+ if (MagicNames.PROJECT_BASEDIR.equals(key)
+ || MagicNames.ANT_FILE.equals(key)) {
+ // basedir and ant.file get special treatment in execute()
+ continue;
+ }
+
+ String value = props.get(key).toString();
+ if (type == PropertyType.PLAIN) {
+ // don't re-set user properties, avoid the warning message
+ if (subProject.getProperty(key) == null) {
+ // no user property
+ subProject.setNewProperty(key, value);
+ }
+ } else if (type == PropertyType.USER) {
+ subProject.setUserProperty(key, value);
+ } else if (type == PropertyType.INHERITED) {
+ subProject.setInheritedProperty(key, value);
+ }
+ }
+ }
+
+ private static final class PropertyType {
+ private PropertyType() {
+ }
+
+ private static final PropertyType PLAIN = new PropertyType();
+ private static final PropertyType INHERITED = new PropertyType();
+ private static final PropertyType USER = new PropertyType();
+ }
+
+ /**
+ * The target to call on the different sub-builds. Set to "" to execute the
+ * default target.
+ *
+ * @param target
+ * the target
+ * <p>
+ */
+ // REVISIT: Defaults to the target name that contains this task if not
+ // specified.
+ public void setTarget(String target) {
+ setTargets(new TargetList(target));
+ }
+
+ /**
+ * The targets to call on the different sub-builds.
+ *
+ * @param target
+ * a list of targets to execute
+ */
+ public void setTargets(TargetList targets) {
+ this.targets = targets;
+ }
+
+ /**
+ * Set the buildpath to be used to find sub-projects.
+ *
+ * @param s
+ * an Ant Path object containing the buildpath.
+ */
+ public void setBuildpath(Path s) {
+ getBuildpath().append(s);
+ }
+
+ /**
+ * Gets the implicit build path, creating it if <code>null</code>.
+ *
+ * @return the implicit build path.
+ */
+ private Path getBuildpath() {
+ if (buildpath == null) {
+ buildpath = new Path(getProject());
+ }
+ return buildpath;
+ }
+
+ /**
+ * Buildpath to use, by reference.
+ *
+ * @param r
+ * a reference to an Ant Path object containing the buildpath.
+ */
+ public void setBuildpathRef(Reference r) {
+ createBuildpath().setRefid(r);
+ }
+
+ /**
+ * Creates a nested build path, and add it to the implicit build path.
+ *
+ * @return the newly created nested build path.
+ */
+ public Path createBuildpath() {
+ return getBuildpath().createPath();
+ }
+
+ /**
+ * Enable/ disable verbose log messages showing when each sub-build path is
+ * entered/ exited. The default value is "false".
+ *
+ * @param on
+ * true to enable verbose mode, false otherwise (default).
+ */
+ public void setVerbose(boolean on) {
+ this.verbose = on;
+ }
+
+ /**
+ * Sets whether to fail with a build exception on error, or go on.
+ *
+ * @param failOnError
+ * the new value for this boolean flag.
+ */
+ public void setFailonerror(boolean failOnError) {
+ this.failOnError = failOnError;
+ }
+
+ /**
+ * Sets whether a submodule should use build repository or not
+ *
+ * @param useBuildRepository
+ * the new value for this boolean flag
+ */
+ public void setUseBuildRepository(boolean useBuildRepository) {
+ this.useBuildRepository = useBuildRepository;
+ }
+
+ /**
+ * Set whether publish operations for the
+ * {@link #setUseBuildRepository(boolean) build-scoped repository} should
+ * overwrite existing artifacts. Defaults to <code>true</code> if
+ * unspecified.
+ */
+ public void setOverwrite(boolean overwrite) {
+ this.overwrite = overwrite;
+ }
+
+ /**
+ * A Vector or target names, which can be constructed from a simple
+ * comma-separated list of values.
+ */
+ public static class TargetList extends Vector<String> {
+ private static final long serialVersionUID = 2302999727821991487L;
+
+ public TargetList(String commaSeparated) {
+ this(commaSeparated.split(","));
+ }
+
+ public TargetList(String... targets) {
+ for (String target : targets)
+ add(target);
+ }
+ }
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/findclasspath/AbstractFindClassPathStrategy.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/findclasspath/AbstractFindClassPathStrategy.java?rev=1073371&r1=1073370&r2=1073371&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/findclasspath/AbstractFindClassPathStrategy.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/findclasspath/AbstractFindClassPathStrategy.java Tue Feb 22 15:55:55 2011
@@ -28,118 +28,118 @@ import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
public abstract class AbstractFindClassPathStrategy extends DataType {
- public String pathid;
- protected Path path;
- private AbstractFindClassPathStrategy nextStrategy;
-
-
- public boolean check() {
- boolean result=doCheck();
- if (!result) {
- if (getNextStrategy()== null) {
- return false;
- } else {
- return getNextStrategy().check();
- }
-
- } else {
- return true;
- }
-
- }
-
- protected abstract boolean doCheck();
-
- /**
- * Utilitary method to load cachepath
- *
- * @param organisation
- * organisation name
- * @param module
- * module name
- * @param revision
- * revision number
- * @param conf
- * configuration name
- * @param ivyRef
- * ivy instance reference
- */
- protected void loadCachePath(String organisation, String module,
- String revision, String conf, Reference ivyRef) {
- StringBuilder sb = new StringBuilder();
- sb.append("Building classpath (").append(getPathid()).append(")");
- sb.append(" with ");
- sb.append(organisation).append("#").append(module).append(";").append(
- revision);
- sb.append(" conf=").append(conf);
- log(sb.toString(), Project.MSG_DEBUG);
- IvyCachePath pluginCachePath = new IvyCachePath();
- pluginCachePath.setOrganisation(organisation);
- pluginCachePath.setModule(module);
- pluginCachePath.setRevision(revision);
- pluginCachePath.setConf(conf);
- pluginCachePath.setPathid(getPathid());
- pluginCachePath.setLog(LogOptions.LOG_DOWNLOAD_ONLY);
- pluginCachePath.setInline(true);
-
- pluginCachePath.setSettingsRef(ivyRef);
- initTask(pluginCachePath).execute();
-
- }
-
- /**
- * Utilitary method to build the classpath
- *
- * @return a path
- */
- protected Path getPath() {
- if (path == null) {
- path = new Path(getProject());
- path.setPath(getPathid());
- path.setLocation(getLocation());
-
- }
- return path;
- }
-
- /**
- * Utilitary method to configure a task with the current one
- * @param task task to configure
- * @return the configured task
- */
- protected Task initTask(Task task) {
- task.setLocation(getLocation());
- task.setProject(getProject());
- //task.setTaskName(getTaskName());
- //task.setOwningTarget(getOwningTarget());
- return task;
- }
-
- /**
- * Get a reference of the project ivy instance
- * @return a reference of the project ivy instance
- */
- protected Reference getProjectIvyReference() {
- return IvyInstanceHelper.buildProjectIvyReference(getProject());
- }
-
- public String getPathid() {
- return pathid;
- }
-
- public void setPathid(String pathid) {
- this.pathid = pathid;
- }
-
- public AbstractFindClassPathStrategy getNextStrategy() {
- return nextStrategy;
- }
-
- public void setNextStrategy(AbstractFindClassPathStrategy nextStrategy) {
- this.nextStrategy = nextStrategy;
- }
-
-
+ public String pathid;
+ protected Path path;
+ private AbstractFindClassPathStrategy nextStrategy;
+
+
+ public boolean check() {
+ boolean result=doCheck();
+ if (!result) {
+ if (getNextStrategy()== null) {
+ return false;
+ } else {
+ return getNextStrategy().check();
+ }
+
+ } else {
+ return true;
+ }
+
+ }
+
+ protected abstract boolean doCheck();
+
+ /**
+ * Utilitary method to load cachepath
+ *
+ * @param organisation
+ * organisation name
+ * @param module
+ * module name
+ * @param revision
+ * revision number
+ * @param conf
+ * configuration name
+ * @param ivyRef
+ * ivy instance reference
+ */
+ protected void loadCachePath(String organisation, String module,
+ String revision, String conf, Reference ivyRef) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Building classpath (").append(getPathid()).append(")");
+ sb.append(" with ");
+ sb.append(organisation).append("#").append(module).append(";").append(
+ revision);
+ sb.append(" conf=").append(conf);
+ log(sb.toString(), Project.MSG_DEBUG);
+ IvyCachePath pluginCachePath = new IvyCachePath();
+ pluginCachePath.setOrganisation(organisation);
+ pluginCachePath.setModule(module);
+ pluginCachePath.setRevision(revision);
+ pluginCachePath.setConf(conf);
+ pluginCachePath.setPathid(getPathid());
+ pluginCachePath.setLog(LogOptions.LOG_DOWNLOAD_ONLY);
+ pluginCachePath.setInline(true);
+
+ pluginCachePath.setSettingsRef(ivyRef);
+ initTask(pluginCachePath).execute();
+
+ }
+
+ /**
+ * Utilitary method to build the classpath
+ *
+ * @return a path
+ */
+ protected Path getPath() {
+ if (path == null) {
+ path = new Path(getProject());
+ path.setPath(getPathid());
+ path.setLocation(getLocation());
+
+ }
+ return path;
+ }
+
+ /**
+ * Utilitary method to configure a task with the current one
+ * @param task task to configure
+ * @return the configured task
+ */
+ protected Task initTask(Task task) {
+ task.setLocation(getLocation());
+ task.setProject(getProject());
+ //task.setTaskName(getTaskName());
+ //task.setOwningTarget(getOwningTarget());
+ return task;
+ }
+
+ /**
+ * Get a reference of the project ivy instance
+ * @return a reference of the project ivy instance
+ */
+ protected Reference getProjectIvyReference() {
+ return IvyInstanceHelper.buildProjectIvyReference(getProject());
+ }
+
+ public String getPathid() {
+ return pathid;
+ }
+
+ public void setPathid(String pathid) {
+ this.pathid = pathid;
+ }
+
+ public AbstractFindClassPathStrategy getNextStrategy() {
+ return nextStrategy;
+ }
+
+ public void setNextStrategy(AbstractFindClassPathStrategy nextStrategy) {
+ this.nextStrategy = nextStrategy;
+ }
+
+
}