Exemplo n.º 1
0
    @SuppressWarnings("unchecked")
    public List<IvyModuleInfo> call() throws Throwable {
      File ws = new File(workspace);
      FileSet ivyFiles = Util.createFileSet(ws, ivyFilePattern, ivyFileExcludePattern);
      final PrintStream logger = listener.getLogger();

      Ivy ivy = getIvy(logger);
      HashMap<ModuleDescriptor, String> moduleDescriptors = new HashMap<ModuleDescriptor, String>();
      for (String ivyFilePath : ivyFiles.getDirectoryScanner().getIncludedFiles()) {
        final File ivyFile = new File(ws, ivyFilePath);

        ModuleDescriptor module =
            (ModuleDescriptor)
                ivy.execute(
                    new IvyCallback() {
                      public Object doInIvyContext(Ivy ivy, IvyContext context) {
                        try {
                          return ModuleDescriptorParserRegistry.getInstance()
                              .parseDescriptor(
                                  ivy.getSettings(),
                                  ivyFile.toURI().toURL(),
                                  ivy.getSettings().doValidate());
                        } catch (MalformedURLException e) {
                          logger.println("The URL is malformed : " + ivyFile);
                          return null;
                        } catch (ParseException e) {
                          logger.println("Parsing error while reading the ivy file " + ivyFile);
                          return null;
                        } catch (IOException e) {
                          logger.println("I/O error while reading the ivy file " + ivyFile);
                          return null;
                        }
                      }
                    });
        moduleDescriptors.put(module, ivyFilePath.replace('\\', '/'));
      }

      List<IvyModuleInfo> infos = new ArrayList<IvyModuleInfo>();
      List<ModuleDescriptor> sortedModuleDescriptors =
          ivy.sortModuleDescriptors(moduleDescriptors.keySet(), SortOptions.DEFAULT);
      for (ModuleDescriptor moduleDescriptor : sortedModuleDescriptors) {
        infos.add(new IvyModuleInfo(moduleDescriptor, moduleDescriptors.get(moduleDescriptor)));
      }

      if (verbose) {
        for (IvyModuleInfo moduleInfo : infos) {
          logger.printf(
              "Discovered module %s at %s.\n",
              moduleInfo.displayName, moduleInfo.relativePathToDescriptor);
        }
      }

      return infos;
    }
  public void doExecute() throws BuildException {
    if (organisation == null) {
      throw new BuildException("no organisation provided for ivy listmodules task");
    }
    if (module == null) {
      throw new BuildException("no module name provided for ivy listmodules task");
    }
    if (revision == null) {
      throw new BuildException("no revision provided for ivy listmodules task");
    }
    if (property == null) {
      throw new BuildException("no property provided for ivy listmodules task");
    }
    if (value == null) {
      throw new BuildException("no value provided for ivy listmodules task");
    }

    Ivy ivy = getIvyInstance();
    IvySettings settings = ivy.getSettings();

    SearchEngine searcher = new SearchEngine(settings);
    PatternMatcher patternMatcher = settings.getMatcher(matcher);

    ModuleRevisionId[] mrids;
    if (resolver == null) {
      mrids =
          searcher.listModules(
              ModuleRevisionId.newInstance(organisation, module, branch, revision), patternMatcher);
    } else {
      DependencyResolver depResolver = settings.getResolver(resolver);
      if (depResolver == null) {
        throw new BuildException("Unknown resolver: " + resolver);
      }
      mrids =
          searcher.listModules(
              depResolver,
              ModuleRevisionId.newInstance(organisation, module, branch, revision),
              patternMatcher);
    }

    for (int i = 0; i < mrids.length; i++) {
      String name = IvyPatternHelper.substitute(settings.substitute(property), mrids[i]);
      String value = IvyPatternHelper.substitute(settings.substitute(this.value), mrids[i]);
      getProject().setProperty(name, value);
    }
  }
 /**
  * Return true if this module match the DependencyDescriptor with the given versionMatcher. If
  * this module has no version defined, then true is always returned.
  */
 public boolean match(DependencyDescriptor descriptor, VersionMatcher versionMatcher) {
   ModuleDescriptor md = module;
   return md.getResolvedModuleRevisionId().getRevision() == null
       || md.getResolvedModuleRevisionId().getRevision().equals(Ivy.getWorkingRevision())
       || versionMatcher.accept(descriptor.getDependencyRevisionId(), md);
   // Checking md.getResolvedModuleRevisionId().getRevision().equals(Ivy.getWorkingRevision()
   // allow to consider any local non resolved ivy.xml
   // as a valid module.
 }
  public void testUpdate() throws Exception {
    /*
     * For updated file to be equals to updated.xml, we have to fix the line separator to the
     * one used in updated.xml, in order for this test to works in all platforms (default line
     * separator used in updater being platform dependent
     */
    XmlModuleDescriptorUpdater.LINE_SEPARATOR = "\n";
    File dest = new File("build/updated-test.xml");
    dest.deleteOnExit();
    Map resolvedRevisions = new HashMap();
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), "2.5");
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule6", "trunk", "latest.integration"),
        "6.3");

    Map resolvedBranches = new HashMap();
    resolvedBranches.put(ModuleRevisionId.newInstance("yourorg", "yourmodule3", "3.1"), "branch1");
    resolvedBranches.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), null);

    GregorianCalendar cal = new GregorianCalendar();
    cal.set(2005, 2, 22, 14, 32, 54);

    Ivy ivy = Ivy.newInstance();
    ivy.setVariable("myvar", "myconf1");
    XmlModuleDescriptorUpdater.update(
        XmlModuleUpdaterTest.class.getResource("test-update.xml"),
        dest,
        getUpdateOptions(ivy.getSettings(), resolvedRevisions, "release", "mynewrev", cal.getTime())
            .setResolvedBranches(resolvedBranches));

    assertTrue(dest.exists());
    String expected =
        FileUtil.readEntirely(
            new BufferedReader(
                new InputStreamReader(
                    XmlModuleUpdaterTest.class.getResourceAsStream("updated.xml"))));
    String updated = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)));
    assertEquals(expected, updated);
  }
Exemplo n.º 5
0
  // ---------------------------------------------------------------------------
  public void doMakeAction(Rule rule) throws TablesawException {
    System.out.println("Ivy retrieving dependencies.");
    try {
      ModuleDescriptor md = m_resolveRule.getReport().getModuleDescriptor();

      Ivy ivy = m_resolveRule.getIvyInstance();

      String pattern;

      if (m_useWorkingDir && m_make.getWorkingDirectory() != null) {
        pattern = m_make.getWorkingDirectory().getPath();
        pattern += "/" + m_retrievePattern;
      } else pattern = m_retrievePattern;

      if (m_make.isVerbose()) System.out.println("Ivy retrieve pattern: " + pattern);

      ivy.retrieve(md.getModuleRevisionId(), pattern, m_retreiveOptions);
    } catch (IOException ioe) {
      throw new TablesawException(ioe);
    }
  }
  private List listDependencyTokenValues(String att, Map otherAttValues) {
    List ret = new ArrayList();
    Ivy ivy = getIvy();
    if (ivy != null) {
      replaceToken(otherAttValues, "org", IvyPatternHelper.ORGANISATION_KEY);
      replaceToken(otherAttValues, "name", IvyPatternHelper.MODULE_KEY);
      replaceToken(otherAttValues, "rev", IvyPatternHelper.REVISION_KEY);

      if (!otherAttValues.containsKey(IvyPatternHelper.BRANCH_KEY)) {
        otherAttValues.put(IvyPatternHelper.BRANCH_KEY, ivy.getSettings().getDefaultBranch());
      }

      String stdAtt = standardiseDependencyAttribute(att);
      otherAttValues.remove(stdAtt);
      String[] revs = ivy.listTokenValues(stdAtt, otherAttValues);
      if (revs != null) {
        ret.addAll(Arrays.asList(revs));
      }
    }
    return ret;
  }
 public ResolvedConfiguration resolve(
     Configuration configuration, Ivy ivy, ModuleDescriptor moduleDescriptor) {
   Clock clock = new Clock();
   ResolveOptions resolveOptions = createResolveOptions(configuration);
   ResolveReport resolveReport;
   try {
     resolveReport = ivy.resolve(moduleDescriptor, resolveOptions);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
   logger.debug("Timing: Ivy resolve took {}", clock.getTime());
   return new ResolvedConfigurationImpl(resolveReport, configuration);
 }
Exemplo n.º 8
0
    /**
     * @return the Ivy instance based on the {@link #ivyConfName}
     * @throws AbortException
     * @throws ParseException
     * @throws IOException
     */
    public Ivy getIvy(PrintStream logger) throws AbortException {
      Message.setDefaultLogger(new IvyMessageImpl());

      File settingsLoc = (ivySettingsFile == null) ? null : new File(ivySettingsFile);

      if ((settingsLoc != null) && (!settingsLoc.exists())) {
        throw new AbortException(
            Messages.IvyModuleSetBuild_NoSuchIvySettingsFile(settingsLoc.getAbsolutePath()));
      }

      ArrayList<File> propertyFiles = new ArrayList<File>();
      if (StringUtils.isNotBlank(ivySettingsPropertyFiles)) {
        for (String file : StringUtils.split(ivySettingsPropertyFiles, ',')) {
          File propertyFile = new File(workspaceProper, file.trim());
          if (!propertyFile.exists()) {
            propertyFile = new File(file.trim());
            if (!propertyFile.isAbsolute() || !propertyFile.exists()) {
              throw new AbortException(Messages.IvyModuleSetBuild_NoSuchPropertyFile(file));
            }
          }
          propertyFiles.add(propertyFile);
        }
      }

      try {
        IvySettings ivySettings = new IvySettings();
        for (File file : propertyFiles) {
          ivySettings.loadProperties(file);
        }
        if (settingsLoc != null) {
          ivySettings.load(settingsLoc);
          if (verbose)
            logger.println("Configured Ivy using custom settings " + settingsLoc.getAbsolutePath());
        } else {
          ivySettings.loadDefault();
          if (verbose) logger.println("Configured Ivy using default 2.1 settings");
        }
        if (ivyBranch != null) {
          ivySettings.setDefaultBranch(ivyBranch);
        }
        return Ivy.newInstance(ivySettings);
      } catch (Exception e) {
        logger.println("Error while reading the default Ivy 2.1 settings: " + e.getMessage());
        logger.println(e.getStackTrace());
      }
      return null;
    }
  public void testVariableReplacement() throws Exception {
    /*
     * For updated file to be equals to updated.xml, we have to fix the line separator to the
     * one used in updated.xml, in order for this test to works in all platforms (default line
     * separator used in updater being platform dependent
     */
    XmlModuleDescriptorUpdater.LINE_SEPARATOR = "\n";
    File dest = new File("build/updated-test2.xml");
    dest.deleteOnExit();
    Map resolvedRevisions = new HashMap();
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), "2.5");
    resolvedRevisions.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule6", "trunk", "latest.integration"),
        "6.3");

    Map resolvedBranches = new HashMap();
    resolvedBranches.put(ModuleRevisionId.newInstance("yourorg", "yourmodule3", "3.1"), "branch1");
    resolvedBranches.put(
        ModuleRevisionId.newInstance("yourorg", "yourmodule2", "branch1", "2+"), null);

    GregorianCalendar cal = new GregorianCalendar();
    cal.set(2005, 2, 22, 14, 32, 54);

    Ivy ivy = Ivy.newInstance();
    ivy.setVariable("myorg", "myorg");
    ivy.setVariable("mymodule", "mymodule");
    ivy.setVariable("myrev", "myrev");
    ivy.setVariable("mystatus", "integration");
    ivy.setVariable("mypubdate", "20050322143254");
    ivy.setVariable("mylicense", "MyLicense");
    ivy.setVariable("mylicenseurl", "http://www.my.org/mymodule/mylicense.html");
    ivy.setVariable("myorgurl", "http://www.myorg.org/");
    ivy.setVariable("ivyrep", "ivyrep");
    ivy.setVariable("ivyrepurl", "http://www.jayasoft.fr/org/ivyrep/");
    ivy.setVariable("ivyreppattern", "[organisation]/[module]/ivy-[revision].xml");
    ivy.setVariable("ivys", "true");
    ivy.setVariable("artifacts", "false");
    ivy.setVariable("homepage", "http://www.my.org/mymodule/");
    ivy.setVariable("includefile", "imported-configurations-with-mapping.xml");
    ivy.setVariable("mydesc", "desc 1");
    ivy.setVariable("visibility", "public");
    ivy.setVariable("myvar", "myconf1");
    ivy.setVariable("deprecated", "20050115");
    ivy.setVariable("myartifact1", "myartifact1");
    ivy.setVariable("mytype", "jar");
    ivy.setVariable("mymodule2", "mymodule2");
    ivy.setVariable("mymodule2rev", "2.0");
    ivy.setVariable("changing", "true");
    ivy.setVariable("transitive", "false");
    ivy.setVariable("targetconf", "yourconf1");
    ivy.setVariable("art9-1", "yourartifact9-1");
    ivy.setVariable("conf3", "myconf3");
    ivy.setVariable("includename", "your.*");
    ivy.setVariable("includeext", "xml");
    ivy.setVariable("excludename", "toexclude");
    ivy.setVariable("excludemodule", "*servlet*");
    ivy.setVariable("excludematcher", "glob");
    ivy.setVariable("excludeorg", "acme");
    ivy.setVariable("excludeartifact", "test");
    ivy.setVariable("excludetype", "source");
    ivy.setVariable("yourorg", "yourorg");
    ivy.setVariable("yourmodule", ".*");
    ivy.setVariable("all", "all");
    ivy.setVariable("regexp", "regexp");
    ivy.setVariable("theirrev", "1.0, 1.1");

    XmlModuleDescriptorUpdater.update(
        XmlModuleUpdaterTest.class.getResource("test-update-withvar.xml"),
        dest,
        getUpdateOptions(ivy.getSettings(), resolvedRevisions, "release", "mynewrev", cal.getTime())
            .setResolvedBranches(resolvedBranches));

    assertTrue(dest.exists());
    String expected =
        FileUtil.readEntirely(
            new BufferedReader(
                new InputStreamReader(
                    XmlModuleUpdaterTest.class.getResourceAsStream("updated.xml"))));
    String updated = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)));
    assertEquals(expected, updated);
  }
Exemplo n.º 10
0
  public IvyModuleDescriptorModel(IvyModelSettings settings) {
    super(settings);

    // ivy-module
    IvyTag ivyTag = new IvyTag("ivy-module", "root tag of ivy file");
    ivyTag.setDoc("Root tag of any ivy-file.");
    ivyTag.addAttribute(
        new IvyTagAttribute(
            "version",
            "The version of the ivy file specification \n"
                + "should be '2.0' with current version of ivy",
            true));
    addTag(ivyTag);

    IValueProvider defaultOrganizationProvider =
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            return new String[] {getSettings().getDefaultOrganization()};
          }
        };
    IValueProvider defaultOrganizationURLProvider =
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            return new String[] {getSettings().getDefaultOrganizationURL()};
          }
        };

    // info
    IvyTagAttribute orgTagAttribute =
        new IvyTagAttribute(
            "organisation", "the name of the organisation that is the owner of this module.", true);
    orgTagAttribute.setValueProvider(defaultOrganizationProvider);
    IvyTagAttribute statusTagAttribute =
        new IvyTagAttribute("status", "the status of this module.");
    statusTagAttribute.setValueProvider(new ListValueProvider(getDefault("status")));
    IvyTagAttribute pubTagAttribute =
        new IvyTagAttribute(
            "publication",
            "the date of publication of this module. \n"
                + "It should be given in this format: yyyyMMddHHmmss");
    pubTagAttribute.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            return new String[] {Ivy.DATE_FORMAT.format(new Date())};
          }
        });
    IvyTagAttribute moduleTagAttribute =
        new IvyTagAttribute("module", "the name of the module described by this ivy file.", true);
    IValueProvider projectNameValueProvider =
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            return new String[] {ivyFile.getProjectName()};
          }
        };
    moduleTagAttribute.setValueProvider(projectNameValueProvider);
    IvyTag info =
        new IvyTag(
            "info",
            "gives general information about the described module",
            new IvyTagAttribute[] {
              orgTagAttribute,
              moduleTagAttribute,
              new IvyTagAttribute("branch", "the branch of this module."),
              new IvyTagAttribute("revision", "the revision of this module."),
              statusTagAttribute,
              pubTagAttribute
            });
    addTag(info);

    // extends
    IvyTag extend = new IvyTag("extends", "gives information about the parent module");
    IvyTagAttribute parentOrgAtt =
        new IvyTagAttribute(
            "organisation", "the name of the organisation of the parent module.", false);
    parentOrgAtt.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            List ret = listDependencyTokenValues(att.getName(), ivyFile);
            ret.add(getSettings().getDefaultOrganization());
            String org = ((IvyModuleDescriptorFile) ivyFile).getOrganisation();
            if (org != null) {
              ret.add(org);
            }
            return (String[]) ret.toArray(new String[ret.size()]);
          }
        });
    extend.addAttribute(parentOrgAtt);
    IvyTagAttribute parentModuleAtt =
        new IvyTagAttribute("module", "the module name of the parent module", true);
    parentModuleAtt.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            List ret = listDependencyTokenValues(att.getName(), ivyFile);
            return (String[]) ret.toArray(new String[ret.size()]);
          }
        });
    extend.addAttribute(parentModuleAtt);
    IvyTagAttribute parentRevAtt =
        new IvyTagAttribute("revision", "the revision of the parent module");
    extend.addAttribute(parentRevAtt);
    addTag(extend);
    info.addChildIvyTag(extend);

    // license
    IvyTag child =
        new IvyTag("license", "gives information about the licenses of the described module");
    child.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the license. \n"
                + "Try to respect spelling when using a classical license.",
            true,
            new ListValueProvider(getDefault("license"))));
    child.addAttribute(new IvyTagAttribute("url", "an url pointing to the license text.", false));
    addTag(child);
    info.addChildIvyTag(child);
    child = new IvyTag("ivyauthor", "describes who has contributed to write the ivy file");
    child.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the author, as a person or a company.",
            true,
            defaultOrganizationProvider));
    child.addAttribute(
        new IvyTagAttribute(
            "url",
            "an url pointing to where the author can be reached.",
            false,
            defaultOrganizationURLProvider));
    addTag(child);
    info.addChildIvyTag(child);
    child =
        new IvyTag("repository", "describes on which public repositories this module can be found");
    child.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the repository. \n"
                + "Try to respect spelling for common repositories (ibiblio, ivyrep, ...)",
            true,
            new IValueProvider() {
              public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
                return new String[] {"ibiblio", "ivyrep"};
              }
            }));
    child.addAttribute(
        new IvyTagAttribute(
            "url",
            "an url pointing to the repository.",
            true,
            new IValueProvider() {
              public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
                Map allAttsValues = ivyFile.getAllAttsValues();
                if (allAttsValues != null) {
                  String name = (String) allAttsValues.get("name");
                  if ("ibiblio".equals(name)) {
                    return new String[] {"http://www.ibiblio.org/maven/"};
                  } else if ("ivyrep".equals(name)) {
                    return new String[] {"http://www.jayasoft.fr/org/ivyrep/"};
                  }
                }
                return null;
              }
            }));
    IvyTagAttribute reppatternTagAttribute =
        new IvyTagAttribute("pattern", "an ivy pattern to find modules on this repository", false);
    reppatternTagAttribute.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            Map allAttsValues = ivyFile.getAllAttsValues();
            if (allAttsValues != null) {
              String name = (String) allAttsValues.get("name");
              if ("ibiblio".equals(name)) {
                return new String[] {"[module]/[type]s/[artifact]-[revision].[ext]"};
              } else if ("ivyrep".equals(name)) {
                return new String[] {"[organisation]/[module]/[artifact]-[revision].[ext]"};
              }
            }
            return null;
          }
        });
    child.addAttribute(reppatternTagAttribute);
    child.addAttribute(
        new IvyBooleanTagAttribute(
            "ivys", "true if ivy file can be found on this repository", false));
    child.addAttribute(
        new IvyBooleanTagAttribute(
            "artifacts", "true if module artifacts can be found on this repository", false));
    addTag(child);
    info.addChildIvyTag(child);
    child = new IvyTag("description", "gives general description about the module");
    child.addAttribute(
        new IvyTagAttribute(
            "homepage",
            "the url of the homepage of the module",
            false,
            defaultOrganizationURLProvider));
    addTag(child);
    info.addChildIvyTag(child);
    ivyTag.addChildIvyTag(info);

    // configurations
    IvyTag configurations = new IvyTag("configurations", "container for configuration elements");
    IvyTag conf = new IvyTag("conf", "declares a configuration of this module");
    conf.addAttribute(new IvyTagAttribute("name", "the name of the declared configuration", true));
    conf.addAttribute(
        new IvyTagAttribute(
            "description", "a short description for the declared configuration", false));
    IvyTagAttribute visibilityTagAttribute =
        new IvyTagAttribute(
            "visibility",
            "the visibility of the declared configuration.\n"
                + "'public' means that this configuration can be used by other modules, \n"
                + "while 'private' means that this configuration is used only in the\n"
                + "module itself, and is not exposed to other modules",
            false);
    visibilityTagAttribute.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            return new String[] {"public", "private"};
          }
        });
    conf.addAttribute(visibilityTagAttribute);
    IvyTagAttribute confExtTagAttribute =
        new IvyTagAttribute(
            "extends",
            "a comma separated list of configurations of this module \n"
                + "that the current configuration extends",
            false);
    IValueProvider masterConfsValueProvider =
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            StringBuffer base = new StringBuffer();
            String qualifier = ivyFile.getAttributeValueQualifier();
            int comma = qualifier.lastIndexOf(",") + 1;
            base.append(qualifier.substring(0, comma));
            qualifier = qualifier.substring(comma);
            while (qualifier.length() > 0 && qualifier.charAt(0) == ' ') {
              base.append(' ');
              qualifier = qualifier.substring(1);
            }
            String[] confs = ((IvyModuleDescriptorFile) ivyFile).getConfigurationNames();
            for (int i = 0; i < confs.length; i++) {
              confs[i] = base + confs[i];
            }
            return confs;
          }
        };
    IValueProvider masterConfValueProvider =
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            return ((IvyModuleDescriptorFile) ivyFile).getConfigurationNames();
          }
        };
    confExtTagAttribute.setValueProvider(masterConfsValueProvider);
    conf.addAttribute(confExtTagAttribute);
    IvyTagAttribute deprecatedTagAttribute =
        new IvyTagAttribute(
            "deprecated",
            "indicates that this conf has been deprecated \n"
                + "by giving the date of the deprecation. \n"
                + "It should be given in this format: yyyyMMddHHmmss",
            false);
    deprecatedTagAttribute.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            return new String[] {Ivy.DATE_FORMAT.format(new Date())};
          }
        });
    conf.addAttribute(deprecatedTagAttribute);
    configurations.addChildIvyTag(conf);
    List allConf = new ArrayList();
    allConf.add(conf);
    addTag(conf.getName(), allConf);
    ivyTag.addChildIvyTag(configurations);
    addTag(configurations);

    // configurations
    IvyTag publications = new IvyTag("publications", "container for published artifact elements");
    IvyTag artifact = new IvyTag("artifact", "declares a published artifact for this module");
    artifact.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the published artifact. This name must not include revision.",
            true,
            projectNameValueProvider));
    artifact.addAttribute(
        new IvyTagAttribute(
            "type",
            "the type of the published artifact. \n"
                + "It's usually its extension, but not necessarily. \n"
                + "For instance, ivy files are of type 'ivy' but have 'xml' extension",
            true,
            new ListValueProvider(getDefault("type"))));
    artifact.addAttribute(
        new IvyTagAttribute(
            "ext",
            "the extension of the published artifact",
            false,
            new ListValueProvider(getDefault("ext"))));
    artifact.addAttribute(
        new IvyTagAttribute(
            "conf",
            "comma separated list of public configurations in which this artifact\n"
                + "is published. '*' wildcard can be used to designate all public\n"
                + "configurations of this module",
            false,
            masterConfsValueProvider));
    IvyTag conf2 =
        new IvyTag("conf", "indicates a public configuration in which this artifact is published");
    conf2.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of a module public configuration in which this artifact\n"
                + "is published. '*' wildcard can be used to designate all\n"
                + "public configurations of this module",
            true,
            masterConfValueProvider));
    allConf.add(conf2);
    artifact.addChildIvyTag(conf2);
    publications.addChildIvyTag(artifact);
    addTag(publications);
    addTag(artifact);
    ivyTag.addChildIvyTag(publications);

    // dependencies
    IvyTag dependencies = new IvyTag("dependencies", "container for dependency elements");
    // dependency
    IvyTag dependency =
        new IvyTag("dependency", "declares a dependency for this module") {
          public String[] getPossibleValuesForAttribute(String att, IvyFile ivyfile) {
            String[] r = super.getPossibleValuesForAttribute(att, ivyfile);
            if (r == null) { // listing can be used even for extra attributes
              List ret = listDependencyTokenValues(att, ivyfile);
              return (String[]) ret.toArray(new String[ret.size()]);
            } else {
              return r;
            }
          }
        };
    IvyTagAttribute orgAtt =
        new IvyTagAttribute("org", "the name of the organisation of the dependency.", false);
    orgAtt.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            List ret = listDependencyTokenValues(att.getName(), ivyFile);
            ret.add(getSettings().getDefaultOrganization());
            String org = ((IvyModuleDescriptorFile) ivyFile).getOrganisation();
            if (org != null) {
              ret.add(org);
            }
            return (String[]) ret.toArray(new String[ret.size()]);
          }
        });
    dependency.addAttribute(orgAtt);
    IvyTagAttribute module = new IvyTagAttribute("name", "the module name of the dependency", true);
    module.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            List ret = listDependencyTokenValues(att.getName(), ivyFile);
            return (String[]) ret.toArray(new String[ret.size()]);
          }
        });
    dependency.addAttribute(module);
    IvyTagAttribute branch =
        new IvyTagAttribute(
            "branch", "the branch of the dependency. \nDo not set if not needed.", false);
    branch.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            List ret = listDependencyTokenValues(att.getName(), ivyFile);
            return (String[]) ret.toArray(new String[ret.size()]);
          }
        });
    dependency.addAttribute(branch);
    IvyTagAttribute rev =
        new IvyTagAttribute(
            "rev",
            "the revision of the dependency. \n"
                + "Use 'latest.integration' to get the latest version of the dependency. \n"
                + "You can also end the revision asked with a '+' to get the latest"
                + " matching revision.",
            true);
    rev.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            List ret = listDependencyTokenValues(att.getName(), ivyFile);
            ret.add("latest.integration");
            return (String[]) ret.toArray(new String[ret.size()]);
          }
        });
    dependency.addAttribute(rev);
    dependency.addAttribute(
        new IvyBooleanTagAttribute(
            "force",
            "a boolean to give an indication to conflict manager \n"
                + "that this dependency should be forced to this revision",
            false));
    dependency.addAttribute(
        new IvyBooleanTagAttribute(
            "transitive",
            "a boolean indicating if this dependency should be resolved transitively or not",
            false));
    IvyTagAttribute confAtt =
        new IvyTagAttribute("conf", "an inline mapping configuration spec", false);
    dependency.addAttribute(confAtt);
    confAtt.setValueProvider(
        new IValueProvider() {
          public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
            String qualifier = ivyFile.getAttributeValueQualifier();
            int index = qualifier.lastIndexOf(';') + 1;
            StringBuffer base = new StringBuffer(qualifier.substring(0, index));
            qualifier = qualifier.substring(index);
            int arrowIndex = qualifier.indexOf("->");
            if (arrowIndex > -1) {
              // we are looking for a dep conf
              String org = ((IvyModuleDescriptorFile) ivyFile).getDependencyOrganisation();
              Map otherAttValues = ivyFile.getAllAttsValues();
              if (org != null
                  && otherAttValues != null
                  && otherAttValues.get("name") != null
                  && otherAttValues.get("rev") != null) {
                otherAttValues.remove("org");
                String branch = (String) otherAttValues.remove("branch");
                otherAttValues.remove("conf");
                otherAttValues.remove("force");
                otherAttValues.remove("transitive");
                otherAttValues.remove("changing");
                return getDependencyConfs(
                    org,
                    (String) otherAttValues.remove("name"),
                    branch,
                    (String) otherAttValues.remove("rev"),
                    otherAttValues,
                    qualifier,
                    base,
                    arrowIndex);
              }

            } else {
              // we are looking for a master conf
              return getMasterConfs(ivyFile, qualifier, base, arrowIndex);
            }

            return null;
          }

          private String[] getMasterConfs(
              IvyFile ivyFile, String qualifier, StringBuffer base, int arrowIndex) {
            // search for word after last comma
            int comma = qualifier.lastIndexOf(",") + 1;
            base.append(qualifier.substring(0, comma));
            qualifier = qualifier.substring(comma);
            while (qualifier.length() > 0 && qualifier.charAt(0) == ' ') {
              base.append(' ');
              qualifier = qualifier.substring(1);
            }
            String[] confs = ((IvyModuleDescriptorFile) ivyFile).getConfigurationNames();
            for (int i = 0; i < confs.length; i++) {
              confs[i] = base + confs[i];
            }
            List ret = new ArrayList(Arrays.asList(confs));
            ret.add("*");
            return (String[]) ret.toArray(new String[ret.size()]);
          }

          private String[] getDependencyConfs(
              String org,
              String name,
              String branch,
              String rev,
              Map otherAtts,
              String qualifier,
              StringBuffer base,
              int arrowIndex) {
            Ivy ivy = getIvy();
            if (ivy == null) {
              return null;
            }
            base.append(qualifier.substring(0, arrowIndex + 2));
            qualifier = qualifier.substring(arrowIndex + 2);
            // search for word after last comma
            int comma = qualifier.lastIndexOf(",") + 1;
            base.append(qualifier.substring(0, comma));
            qualifier = qualifier.substring(comma);
            while (qualifier.length() > 0 && qualifier.charAt(0) == ' ') {
              base.append(' ');
              qualifier = qualifier.substring(1);
            }
            ResolveData data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
            ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, branch, rev, otherAtts);
            DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(mrid, false);
            try {
              DependencyResolver resolver = ivy.getSettings().getResolver(mrid);
              if (resolver == null) {
                return null;
              }
              ResolvedModuleRevision dep = resolver.getDependency(ddd, data);
              if (dep == null) {
                return null;
              }
              String[] confs = dep.getDescriptor().getConfigurationsNames();
              for (int i = 0; i < confs.length; i++) {
                confs[i] = base + confs[i];
              }
              List ret = new ArrayList(Arrays.asList(confs));
              ret.add("*");
              return (String[]) ret.toArray(new String[ret.size()]);
            } catch (ParseException e) {
              getSettings().logError("The dependencies of " + mrid + " could not be parsed", e);
              return null;
            }
          }
        });
    IvyTag conf3 = new IvyTag("conf", "defines configuration mapping has sub element");
    conf3.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the master configuration to map. \n"
                + "'*' wildcard can be used to designate all configurations of this module",
            true,
            masterConfValueProvider));
    conf3.addAttribute(
        new IvyTagAttribute(
            "mapped",
            "a comma separated list of dependency configurations \n"
                + "to which this master configuration should be mapped",
            false,
            new IValueProvider() {
              public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
                Ivy ivy = getIvy();
                int[] indexes = ivyFile.getParentTagIndex();
                if (indexes != null && ivy != null) {
                  Map otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1);
                  String org =
                      ((IvyModuleDescriptorFile) ivyFile).getDependencyOrganisation(otherAttValues);
                  if (org != null
                      && otherAttValues != null
                      && otherAttValues.get("name") != null
                      && otherAttValues.get("rev") != null) {
                    StringBuffer base = new StringBuffer();
                    String qualifier = ivyFile.getAttributeValueQualifier();
                    // search for word after last comma
                    int comma = qualifier.lastIndexOf(",") + 1;
                    base.append(qualifier.substring(0, comma));
                    qualifier = qualifier.substring(comma);
                    while (qualifier.length() > 0 && qualifier.charAt(0) == ' ') {
                      base.append(' ');
                      qualifier = qualifier.substring(1);
                    }
                    ResolveData data =
                        new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
                    ModuleRevisionId mrid =
                        ModuleRevisionId.newInstance(
                            org,
                            (String) otherAttValues.get("name"),
                            (String) otherAttValues.get("rev"));
                    DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(mrid, false);
                    try {
                      String[] confs =
                          ivy.getSettings()
                              .getResolver(mrid)
                              .getDependency(ddd, data)
                              .getDescriptor()
                              .getConfigurationsNames();
                      for (int i = 0; i < confs.length; i++) {
                        confs[i] = base + confs[i];
                      }
                      List ret = new ArrayList(Arrays.asList(confs));
                      ret.add("*");
                      return (String[]) ret.toArray(new String[ret.size()]);
                    } catch (ParseException e) {
                      getSettings()
                          .logError("The dependencies of " + mrid + " could not be parsed", e);
                      return new String[] {"*"};
                    }
                  }
                }
                return new String[] {"*"};
              }
            }));
    allConf.add(conf3);
    IvyTag mapped =
        new IvyTag("mapped", "map dependency configurations for this master configuration");
    mapped.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the dependency configuration mapped. \n"
                + "'*' wildcard can be used to designate all configurations of this module",
            true,
            new IValueProvider() {
              public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) {
                Ivy ivy = getIvy();
                int[] indexes = ivyFile.getParentTagIndex();
                if (indexes == null || ivy == null) {
                  return new String[] {"*"};
                }
                indexes = ivyFile.getParentTagIndex(indexes[0]);
                if (indexes == null) {
                  return new String[] {"*"};
                }
                Map otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1);
                String org =
                    ((IvyModuleDescriptorFile) ivyFile).getDependencyOrganisation(otherAttValues);
                if (org == null
                    || otherAttValues == null
                    || otherAttValues.get("name") == null
                    || otherAttValues.get("rev") == null) {
                  return new String[] {"*"};
                }
                ResolveData data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions());
                ModuleRevisionId mrid =
                    ModuleRevisionId.newInstance(
                        org,
                        (String) otherAttValues.get("name"),
                        (String) otherAttValues.get("rev"));
                DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(mrid, false);
                try {
                  String[] confs =
                      ivy.getSettings()
                          .getResolver(mrid)
                          .getDependency(ddd, data)
                          .getDescriptor()
                          .getConfigurationsNames();
                  List ret = new ArrayList(Arrays.asList(confs));
                  ret.add("*");
                  return (String[]) ret.toArray(new String[ret.size()]);
                } catch (ParseException e) {
                  getSettings().logError("The dependencies of " + mrid + " could not be parsed", e);
                }
                return new String[] {"*"};
              }
            }));
    conf3.addChildIvyTag(mapped);
    addTag(mapped);

    String[] matcherNames = new String[0];
    Ivy ivy = getIvy();
    if (ivy != null) {
      matcherNames = (String[]) ivy.getSettings().getMatcherNames().toArray(new String[0]);
    }
    ListValueProvider matcherNamesProvider = new ListValueProvider(matcherNames);

    IvyTag artifact2 =
        new IvyTag(
            "artifact",
            "defines artifacts restriction \n"
                + "use only if you do not control dependency ivy file");
    artifact2.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of an artifact of the \n"
                + "dependency module to add to the include list, \n"
                + "or a regexp matching this name",
            false));
    artifact2.addAttribute(
        new IvyTagAttribute(
            "type",
            "the type of the artifact of the \n"
                + "dependency module to add to the include list, \n"
                + "or a regexp matching this name",
            false,
            new ListValueProvider(getDefault("type"))));
    artifact2.addAttribute(
        new IvyTagAttribute(
            "ext",
            "the extension of the artifact of the \n"
                + "dependency module to add to the include list, \n"
                + "or a regexp matching this name",
            false,
            new ListValueProvider(getDefault("ext"))));
    artifact2.addAttribute(
        new IvyTagAttribute(
            "url",
            "an url where this artifact can be found \n"
                + "if it isn't present at the standard \n"
                + "location in the repository",
            false));
    artifact2.addAttribute(
        new IvyTagAttribute(
            "conf",
            "comma separated list of the master configurations \n"
                + "in which this artifact should be included. \n"
                + "'*' wildcard can be used to designate all configurations of this module",
            false,
            masterConfsValueProvider));
    IvyTag conf4 = new IvyTag("conf", "configuration in which the artifact should be included");
    conf4.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the master configuration in which \n"
                + "the enclosing artifact should be included",
            true,
            masterConfValueProvider));
    allConf.add(conf4);
    artifact2.addChildIvyTag(conf4);
    addTag(artifact2);
    IvyTag include =
        new IvyTag(
            "include",
            "defines artifacts restriction \n"
                + "use only if you do not control dependency ivy file");
    include.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of an artifact of the \n"
                + "dependency module to add to the include list, \n"
                + "or a regexp matching this name",
            false));
    include.addAttribute(
        new IvyTagAttribute(
            "type",
            "the type of the artifact of the \n"
                + "dependency module to add to the include list, \n"
                + "or a regexp matching this name",
            false,
            new ListValueProvider(getDefault("type"))));
    include.addAttribute(
        new IvyTagAttribute(
            "ext",
            "the extension of the artifact of the \n"
                + "dependency module to add to the include list, \n"
                + "or a regexp matching this name",
            false,
            new ListValueProvider(getDefault("ext"))));
    include.addAttribute(
        new IvyTagAttribute(
            "matcher",
            "the matcher to use to match the modules to include",
            false,
            matcherNamesProvider));
    include.addAttribute(
        new IvyTagAttribute(
            "conf",
            "comma separated list of the master configurations \n"
                + "in which this artifact should be included. \n"
                + "'*' wildcard can be used to designate all configurations of this module",
            false,
            masterConfsValueProvider));
    IvyTag conf5 = new IvyTag("conf", "configuration in which the artifact should be included");
    conf5.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the master configuration in which \n"
                + "the enclosing artifact should be included",
            true,
            masterConfValueProvider));
    include.addChildIvyTag(conf5);
    addTag(include);
    allConf.add(conf5);
    IvyTag exclude =
        new IvyTag(
            "exclude",
            "defines artifacts restriction \n"
                + "use only if you do not control dependency ivy file");
    exclude.addAttribute(
        new IvyTagAttribute(
            "org",
            "the organisation of the dependency \n"
                + "module or artifact to exclude, \n"
                + "or a pattern matching this organisation",
            false));
    exclude.addAttribute(
        new IvyTagAttribute(
            "module",
            "the name of the dependency \n"
                + "module or the artifact to exclude, \n"
                + "or a pattern matching this module name",
            false));
    exclude.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of an artifact of the \n"
                + "dependency module to add to the exclude list, \n"
                + "or a pattern matching this name",
            false));
    exclude.addAttribute(
        new IvyTagAttribute(
            "type",
            "the type of the artifact of the \n"
                + "dependency module to add to the exclude list, \n"
                + "or a pattern matching this name",
            false,
            new ListValueProvider(getDefault("type"))));
    exclude.addAttribute(
        new IvyTagAttribute(
            "ext",
            "the extension of the artifact of the \n"
                + "dependency module to add to the exclude list, \n"
                + "or a pattern matching this name",
            false,
            new ListValueProvider(getDefault("ext"))));
    exclude.addAttribute(
        new IvyTagAttribute(
            "matcher",
            "the matcher to use to match the modules to include",
            false,
            matcherNamesProvider));
    exclude.addAttribute(
        new IvyTagAttribute(
            "conf",
            "comma separated list of the master configurations \n"
                + "in which this artifact should be excluded. \n"
                + "'*' wildcard can be used to designate all configurations of"
                + " this module",
            false,
            masterConfsValueProvider));
    IvyTag conf6 = new IvyTag("conf", "configuration in which the artifact should be excluded");
    conf6.addAttribute(
        new IvyTagAttribute(
            "name",
            "the name of the master configuration in which \n"
                + "the enclosing artifact should be excluded",
            true,
            masterConfValueProvider));
    allConf.add(conf6);
    exclude.addChildIvyTag(conf6);
    addTag(exclude);
    dependency.addChildIvyTag(conf3);
    dependency.addChildIvyTag(artifact2);
    dependency.addChildIvyTag(include);
    dependency.addChildIvyTag(exclude);
    dependencies.addChildIvyTag(dependency);
    ivyTag.addChildIvyTag(dependencies);
    addTag(dependency);
    addTag(dependencies);

    // dependencies

    IvyTag conflicts = new IvyTag("conflicts", "conflicts managers definition section");
    IvyTag manager = new IvyTag("manager", "declares a conflict manager for this module");
    manager.addAttribute(
        new IvyTagAttribute(
            "org",
            "the name, or a regexp matching the name of organisation \n"
                + "to which this conflict manager should apply",
            false));
    manager.addAttribute(
        new IvyTagAttribute(
            "module",
            "the name, or a regexp matching the name of module \n"
                + "to which this conflict manager should apply",
            false));
    manager.addAttribute(
        new IvyTagAttribute("name", "the name of the conflict manager to use", false));
    manager.addAttribute(
        new IvyTagAttribute(
            "rev",
            "a comma separated list of revisions this conflict manager should select",
            false));
    manager.addAttribute(
        new IvyTagAttribute(
            "matcher",
            "the matcher to use to match the modules for which \n"
                + "the conflict manager should be used",
            false));
    conflicts.addChildIvyTag(manager);
    ivyTag.addChildIvyTag(conflicts);
    addTag(conflicts);
    addTag(manager);
  }