protected Set<String> getChangedFiles() {

		// If there is no status file to compare against then always run the
		// generator
		File statusFile = getStatusFile();
		if (statusFile == null) {
			return null;
		}
		final long statusFileLastModified = statusFile.lastModified();
		final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		if (isVerbose()) {
			getLog().info("Last code generator execution: " + df.format(new Date(statusFileLastModified)));
		}

		// Create list of files to check - start with project pom.xml and
		// generator config files
		List<File> filesToCheck = new ArrayList<File>();
		filesToCheck.add(new File(project.getBasedir(), "pom.xml"));

		// Now add generator config files
		FileSet generatorFileSet = new FileSet();
		generatorFileSet.setDirectory(project.getBasedir() + "/src/main/resources/generator");
		generatorFileSet.addInclude("*");
		filesToCheck.addAll(toFileList(generatorFileSet));

		// Finally add files from configured filesets in 'checkFileSets'
		for (FileSet fs : checkFileSets) {
			filesToCheck.addAll(toFileList(fs));
		}

		// Check files for modification
		Set<String> changedFiles = new HashSet<String>();
		for (File checkFile : filesToCheck) {
			if (!checkFile.isAbsolute()) {
				checkFile = new File(project.getBasedir(), checkFile.getPath());
			}
			final boolean isModified = checkFile.lastModified() > statusFileLastModified;
			if (isModified) {
				changedFiles.add(checkFile.getAbsolutePath());
			}
			if (isVerbose()) {
				getLog().info(
						"File '" + checkFile.getAbsolutePath() + "': " + (isModified ? "outdated" : "up-to-date")
								+ " (" + " " + df.format(new Date(checkFile.lastModified())) + ")");
			}
		}

		// Print info of result
		if (changedFiles.size() == 1) {
			String fileName = changedFiles.iterator().next();
			if (fileName.startsWith(project.getBasedir().getAbsolutePath())) {
				fileName = fileName.substring(project.getBasedir().getAbsolutePath().length() + 1);
			}
			final String message = MessageFormat.format("\"{0}\" has been modified since last generator "
					+ "run at {1}", fileName, df.format(new Date(statusFileLastModified)));
			getLog().info(message);
		} else if (changedFiles.size() > 1) {
			final String message = MessageFormat.format("{0} checked resources have been modified since "
					+ "last generator run at {1}", changedFiles.size(), df.format(new Date(statusFileLastModified)));
			getLog().info(message);
		} else {
			getLog().info("Everything is up-to-date - no generator run is needed");
		}
		return changedFiles;
	}
protected Set < String > getChangedFiles ( ) { File statusFile = getStatusFile ( ) ; if ( statusFile == null ) { return null ; } final long statusFileLastModified = statusFile . lastModified ( ) ; final SimpleDateFormat df = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; if ( isVerbose ( ) ) { getLog ( ) . info ( "Last code generator execution: " + df . format ( new Date ( statusFileLastModified ) ) ) ; } List < File > filesToCheck = new ArrayList < File > ( ) ; filesToCheck . add ( new File ( project . getBasedir ( ) , "pom.xml" ) ) ; FileSet generatorFileSet = new FileSet ( ) ; generatorFileSet . setDirectory ( project . getBasedir ( ) + "/src/main/resources/generator" ) ; generatorFileSet . addInclude ( "*" ) ; filesToCheck . addAll ( toFileList ( generatorFileSet ) ) ; for ( FileSet fs : checkFileSets ) { filesToCheck . addAll ( toFileList ( fs ) ) ; } Set < String > changedFiles = new HashSet < String > ( ) ; for ( File checkFile : filesToCheck ) { if ( ! checkFile . isAbsolute ( ) ) { checkFile = new File ( project . getBasedir ( ) , checkFile . getPath ( ) ) ; } final boolean isModified = checkFile . lastModified ( ) > statusFileLastModified ; if ( isModified ) { changedFiles . add ( checkFile . getAbsolutePath ( ) ) ; } if ( isVerbose ( ) ) { getLog ( ) . info ( "File '" + checkFile . getAbsolutePath ( ) + "': " + ( isModified ? "outdated" : "up-to-date" ) + " (" + " " + df . format ( new Date ( checkFile . lastModified ( ) ) ) + ")" ) ; } } if ( changedFiles . size ( ) == 1 ) { String fileName = changedFiles . iterator ( ) . next ( ) ; if ( fileName . startsWith ( project . getBasedir ( ) . getAbsolutePath ( ) ) ) { fileName = fileName . substring ( project . getBasedir ( ) . getAbsolutePath ( ) . length ( ) + 1 ) ; } final String message = MessageFormat . format ( "\"{0}\" has been modified since last generator " + "run at {1}" , fileName , df . format ( new Date ( statusFileLastModified ) ) ) ; getLog ( ) . info ( message ) ; } else if ( changedFiles . size ( ) > 1 ) { final String message = MessageFormat . format ( "{0} checked resources have been modified since " + "last generator run at {1}" , changedFiles . size ( ) , df . format ( new Date ( statusFileLastModified ) ) ) ; getLog ( ) . info ( message ) ; } else { getLog ( ) . info ( "Everything is up-to-date - no generator run is needed" ) ; } return changedFiles ; }
Returns a list with file names from the <code>checkFileSets</code>
parameter that have been modified since previous generator run. Empty if
no files changed or <code>null</code> if there is no status file to
compare against, i.e. always run the generator.