public boolean isSourceModified()

in src/main/java/org/apache/maven/plugins/resource/loader/ProjectResourceLoader.java [180:223]


    public boolean isSourceModified( Resource resource )
    {
        /*
         * we assume that the file needs to be reloaded; if we find the original file and it's unchanged, then we'll
         * flip this.
         */
        boolean modified = true;

        String fileName = resource.getName();
        String path = templatePaths.get( fileName );
        File currentFile = null;

        for ( int i = 0; currentFile == null && i < paths.size(); i++ )
        {
            String testPath = paths.get( i );
            File testFile = new File( testPath, fileName );
            if ( testFile.canRead() )
            {
                currentFile = testFile;
            }
        }
        File file = new File( path, fileName );
        if ( currentFile == null || !file.exists() )
        {
            /*
             * noop: if the file is missing now (either the cached file is gone, or the file can no longer be found)
             * then we leave modified alone (it's set to true); a reload attempt will be done, which will either use a
             * new template or fail with an appropriate message about how the file couldn't be found.
             */
        }
        else if ( currentFile.equals( file ) && file.canRead() )
        {
            /*
             * if only if currentFile is the same as file and file.lastModified() is the same as
             * resource.getLastModified(), then we should use the cached version.
             */
            modified = ( file.lastModified() != resource.getLastModified() );
        }

        /*
         * rsvc.debug("isSourceModified for " + fileName + ": " + modified);
         */
        return modified;
    }