Browse Source

TOOLS: Always trigger the metadata generation.

pull/567/head
Philippe Liard 15 years ago
committed by Mihaela Rosca
parent
commit
2ddc9a5531
4 changed files with 0 additions and 45 deletions
  1. +0
    -35
      tools/java/common/src/com/google/i18n/phonenumbers/tools/FileUtils.java
  2. +0
    -6
      tools/java/java-build/src/com/google/i18n/phonenumbers/tools/BuildMetadataProtoFromXml.java
  3. +0
    -4
      tools/java/java-build/src/com/google/i18n/phonenumbers/tools/GenerateAreaCodeData.java
  4. BIN
      tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar

+ 0
- 35
tools/java/common/src/com/google/i18n/phonenumbers/tools/FileUtils.java View File

@ -18,10 +18,7 @@
package com.google.i18n.phonenumbers.tools; package com.google.i18n.phonenumbers.tools;
import java.io.Closeable; import java.io.Closeable;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/** /**
* Helper class containing methods designed to ease file manipulation and generation. * Helper class containing methods designed to ease file manipulation and generation.
@ -52,36 +49,4 @@ public class FileUtils {
close(closeable); close(closeable);
} }
} }
/**
* Returns true if the provided output file/directory is older than the provided input
* file/directory. The last modification time of a directory is the maximum last
* modification time of its children. It assumes the provided output directory only contains
* generated files.
*/
public static boolean isGenerationRequired(File inputFile, File outputDir) {
if (!outputDir.exists()) {
return true;
}
return getLastModificationTime(inputFile) > getLastModificationTime(outputDir);
}
/**
* Gets the modification time of the most recently modified file contained in a directory.
*/
private static long getLastModificationTime(File file) {
if (!file.isDirectory()) {
return file.lastModified();
}
long maxModificationTime = 0;
for (File child : file.listFiles()) {
long modificationTime = getLastModificationTime(child);
if (modificationTime > maxModificationTime) {
maxModificationTime = modificationTime;
}
}
return maxModificationTime;
}
} }

+ 0
- 6
tools/java/java-build/src/com/google/i18n/phonenumbers/tools/BuildMetadataProtoFromXml.java View File

@ -90,12 +90,6 @@ public class BuildMetadataProtoFromXml extends Command {
boolean forTesting = args[3].equals("true"); boolean forTesting = args[3].equals("true");
boolean liteBuild = args.length > 4 && args[4].equals("true"); boolean liteBuild = args.length > 4 && args[4].equals("true");
if (!FileUtils.isGenerationRequired(
new File(inputFile),
new File(outputDir, new File(META_DATA_FILE_PREFIX).getParent()))) {
System.out.println("Metadata code up-to-date.");
return true;
}
String filePrefix; String filePrefix;
if (forTesting) { if (forTesting) {
filePrefix = outputDir + TEST_META_DATA_FILE_PREFIX; filePrefix = outputDir + TEST_META_DATA_FILE_PREFIX;


+ 0
- 4
tools/java/java-build/src/com/google/i18n/phonenumbers/tools/GenerateAreaCodeData.java View File

@ -239,10 +239,6 @@ public class GenerateAreaCodeData extends Command {
* @throws FileNotFoundException * @throws FileNotFoundException
*/ */
public void run() throws FileNotFoundException, IOException { public void run() throws FileNotFoundException, IOException {
if (!FileUtils.isGenerationRequired(inputPath, outputPath)) {
LOGGER.log(Level.INFO, "Geocoding data up-to-date.");
return;
}
List<Pair<File, File>> inputOutputMappings = createInputOutputFileMappings(); List<Pair<File, File>> inputOutputMappings = createInputOutputFileMappings();
SortedMap<Integer, Set<String>> availableDataFiles = new TreeMap<Integer, Set<String>>(); SortedMap<Integer, Set<String>> availableDataFiles = new TreeMap<Integer, Set<String>>();


BIN
tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar View File


Loading…
Cancel
Save