/* (non-Javadoc)
   * @see org.apache.tools.ant.Task#execute()
   */
  public void execute() throws BuildException {
    if (this.source == null) {
      throw new BuildException(
          "no source is set - please specify the properties file using the \"source\" attribute.");
    }
    if (!this.source.exists()) {
      throw new BuildException(
          "source "
              + this.source.getAbsolutePath()
              + " does not exist. Please check your \"source\" attribute.");
    }

    try {
      Map sourceMap = FileUtil.readProperties(getSource());
      DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
      String date = " (" + dateFormat.format(new Date()) + ")";
      Object[] keys = sourceMap.keySet().toArray();
      for (int i = 0; i < keys.length; i++) {
        Object key = keys[i];
        String value = (String) sourceMap.get(key);
        value += date;
        sourceMap.put(key, value);
      }
      FileUtil.writePropertiesFile(getTarget(), sourceMap);
    } catch (IOException e) {
      e.printStackTrace();
      throw new BuildException(e.toString());
    }
  }
Example #2
0
 /**
  * Copies all third party binary libraries to the cache.
  *
  * @param binaryBaseDir the base dir of the cache
  * @return true when at least one library had to be written again
  * @throws IOException when a file could not be read or written
  * @throws FileNotFoundException when a file was not found
  */
 public boolean copyToCache(File binaryBaseDir) throws FileNotFoundException, IOException {
   File idsFile = new File(binaryBaseDir, "library-ids.txt");
   if (idsFile.exists()) {
     Map idsMap = FileUtil.readPropertiesFile(idsFile);
     this.integerIdGenerator.setIdsMap(idsMap);
   }
   LibrarySetting[] libs = getLibraries();
   boolean updated = false;
   for (int i = 0; i < libs.length; i++) {
     LibrarySetting lib = libs[i];
     int id = this.integerIdGenerator.getId(lib.getPath(this.environment), true);
     updated |= lib.copyToCache(binaryBaseDir, Integer.toString(id), this.environment);
   }
   if (this.integerIdGenerator.hasChanged()) {
     Map idsMap = this.integerIdGenerator.getIdsMap();
     FileUtil.writePropertiesFile(idsFile, idsMap);
   }
   return updated;
 }
Example #3
0
 /**
  * Helper method to find all files to post compile in a given directory and all its
  * subdirectories.
  *
  * @param classesDir the directory that contains all compiled classes
  * @param filter the filter to apply on the file names, or null
  * @return an array list of file names
  */
 protected ArrayList findFiles(File classesDir, FilenameFilter filter) {
   ArrayList list = new ArrayList();
   String[] files = FileUtil.filterDirectory(classesDir, ".class", true);
   if (filter != null) {
     for (int i = 0; i < files.length; i++) {
       if (filter.accept(classesDir, files[i])) {
         list.add(files[i]);
       }
     }
   } else {
     for (int i = 0; i < files.length; i++) {
       list.add(files[i]);
     }
   }
   return list;
 }