Exemplo n.º 1
0
  private String getBuildOutputDirectories(ReactorProject otherProject) {
    StringBuilder sb = new StringBuilder();

    sb.append(otherProject.getOutputDirectory());
    sb.append(',').append(otherProject.getTestOutputDirectory());

    Properties buildProperties = new Properties();
    File file = new File(otherProject.getBasedir(), "build.properties");
    try {
      FileInputStream is = new FileInputStream(file);
      try {
        buildProperties.load(is);
      } finally {
        is.close();
      }

      // TODO plugin package mojo has this same logic, move to a helper
      final String OUTPUT = "output.";
      final String SOURCE = "source.";

      for (Iterator<Object> iterator = buildProperties.keySet().iterator(); iterator.hasNext(); ) {
        String key = (String) iterator.next();
        String[] classesDir = null;
        if (key.startsWith(OUTPUT) && !key.equals("output..")) {
          classesDir = buildProperties.getProperty(key).split(",");
        } else if (key.startsWith(SOURCE) && !key.equals("source..")) {
          String fileName = key.substring(SOURCE.length());
          classesDir =
              new String[] {
                otherProject.getBuildDirectory().getName()
                    + "/"
                    + fileName.substring(0, fileName.length() - 4)
                    + "-classes"
              };
        }
        if (classesDir != null) {
          for (String dir : classesDir) {
            if (sb.length() > 0) sb.append(',');
            sb.append(dir);
          }
        }
      }

    } catch (IOException e) {
      getLog().debug("Exception reading build.properties of " + otherProject.getId(), e);
    }

    return sb.toString();
  }