private void resolvePath(
      List ids,
      List paths,
      boolean mergeWithCore,
      boolean overrideCore,
      Target target,
      boolean flatten) {
    String projectPrefix = "project.";
    String pluginPrefix = "plugin.";
    String propertyPrefix = "property.";

    for (Iterator i = ids.iterator(); i.hasNext(); ) {
      String id = (String) i.next();

      if (id.startsWith(projectPrefix)) {
        String projectPathId = id.substring(projectPrefix.length());
        Assert.isTrue(
            resolvedPaths.get(projectPathId) != null,
            "Project path '" + projectPathId + "' is not defined");
        paths.add(getReslovedProjectPath(projectPathId, mergeWithCore, overrideCore, flatten));
      } else if (id.startsWith(pluginPrefix)) {
        String pluginPathId = id.substring(pluginPrefix.length());
        paths.add(
            getResolvedPluginPath(
                target.getPlugin(), pluginPathId, mergeWithCore, overrideCore, flatten));
      } else if (id.startsWith(propertyPrefix)) {
        String property = id.substring(propertyPrefix.length());
        property = Strings.replace(property, "prefix", target.getPrefix());

        String value = project.getProperties().getProperty(property);

        if (value != null) {
          resolvePath(
              Strings.commaSepList(value), paths, mergeWithCore, overrideCore, target, flatten);
        }
      } else if (id.equals("plugin")) {
        ResolvedPath path = new ResolvedPath();
        path.setId("Plugin:");
        path.add(target.getPlugin().getArtifact());
        paths.add(path);
      } else {
        throw new BuildException(
            "A path group must contain a comma separated list of: plugin | plugin.<pluginpath> | project.<projectpath> | property.<reference to a property containing additional paths>: id="
                + id);
      }
    }
  }
  /**
   * Returns a set of properties for the project. The precedence is: quokka.properties
   * quokka.properties of inherited projects plugin.properties No expansion or ordering of
   * properties is done
   */
  public AnnotatedProperties getProperties() {
    AnnotatedProperties resolvedProperties = new AnnotatedProperties();

    // Add the global defaults
    resolvedProperties.put("quokka.project.targetDir", "${basedir}/target");
    resolvedProperties.put("quokka.project.sourceDir", "${basedir}/src");
    resolvedProperties.put("quokka.project.resourcesDir", "${basedir}/resources");

    // Add artifact related properties
    if (project.getArtifacts().size() > 0) {
      // Add properties common to all (group & version)
      RepoArtifactId artifactId =
          ((Artifact) getProject().getArtifacts().iterator().next()).getId();
      resolvedProperties.put("quokka.project.artifact.group", artifactId.getGroup());
      resolvedProperties.put("quokka.project.artifact.version", artifactId.getVersion().toString());

      // Build up a list of names by type
      Map namesByType = new HashMap();

      for (Iterator i = project.getArtifacts().iterator(); i.hasNext(); ) {
        Artifact artifact = (Artifact) i.next();
        artifactId = artifact.getId();

        List names = (List) namesByType.get(artifactId.getType());

        if (names == null) {
          names = new ArrayList();
          namesByType.put(artifactId.getType(), names);
        }

        names.add(artifactId.getName());
      }

      // Output the names
      for (Iterator i = namesByType.entrySet().iterator(); i.hasNext(); ) {
        Map.Entry entry = (Map.Entry) i.next();
        List names = (List) entry.getValue();
        resolvedProperties.put(
            "quokka.project.artifact.name[" + entry.getKey() + "]",
            Strings.join(names.iterator(), ","));
      }
    }

    // Put the plugin properties in first. Order is not important as plugin properties should be
    // unique to their plugin
    for (Iterator i = resolvedTargets.values().iterator(); i.hasNext(); ) {
      Target target = (Target) i.next();
      AnnotatedProperties targetProperties = target.getDefaultProperties();
      resolvedProperties.putAll(
          applyProfiles(targetProperties, project.getActiveProfiles().getElements()));
    }

    // Put in any properties defined in dependency sets (processed in reverse to ensure high levels
    // override low levels)
    resolveProperties(resolvedProperties, project.getDependencySet());

    resolvedProperties.putAll(
        applyProfiles(project.getProperties(), project.getActiveProfiles().getElements()));

    // Put the project paths as properties
    for (Iterator i = resolvedPaths.entrySet().iterator(); i.hasNext(); ) {
      Map.Entry entry = (Map.Entry) i.next();
      resolvedProperties.put(
          "quokka.project.path." + entry.getKey(),
          toAntPath(getProjectPath((String) entry.getKey(), false, true)).toString());
    }

    return resolvedProperties;
  }