(Re)Compiles the given source. This method starts the compilation of a given source, if the source has changed since the class was created. For this isSourceNewer is called. @param source the source pointer for the compilation @param className the name of the class to be generated @param oldClas
(final URL source, final String className, final Class oldClass)
| 763 | * @see #isSourceNewer(URL, Class) |
| 764 | */ |
| 765 | protected Class recompile(final URL source, final String className, final Class oldClass) throws CompilationFailedException, IOException { |
| 766 | if (source != null) { |
| 767 | // found a source, compile it if newer |
| 768 | if (oldClass == null || isSourceNewer(source, oldClass)) { |
| 769 | String name = source.toExternalForm(); |
| 770 | |
| 771 | sourceCache.remove(name); |
| 772 | |
| 773 | if (isFile(source)) { |
| 774 | try { |
| 775 | return parseClass(new GroovyCodeSource(new File(source.toURI()), sourceEncoding)); |
| 776 | } catch (URISyntaxException e) { |
| 777 | // do nothing and fall back to the other version |
| 778 | } |
| 779 | } |
| 780 | return parseClass(new InputStreamReader(URLStreams.openUncachedStream(source), sourceEncoding), name); |
| 781 | } |
| 782 | } |
| 783 | return oldClass; |
| 784 | } |
| 785 | |
| 786 | /** |
| 787 | * Gets the time stamp of a given class. For groovy |
no test coverage detected