public URL getResource(String name) { return delegate.getResource(name); }
private URL getSourceFile(String name, String extension) { String filename = name.replace('.', '/') + "." + extension; URL ret = getResource(filename); if (isFile(ret) && getFileForUrl(ret, filename) == null) return null; return ret; }
public void testCodeSource() throws IOException, CompilationFailedException { URL script = loader.getResource("groovy/ArrayTest.groovy"); try { new GroovyCodeSource(script); } catch (RuntimeException re) { assertEquals("Could not construct a GroovyCodeSource from a null URL", re.getMessage()); } }
/** * Search for classes using ASM decompiler */ private LookupResult findDecompiled(String name, CompilationUnit compilationUnit, GroovyClassLoader loader) { ClassNode node = ClassHelper.make(name); if (node.isResolved()) { return new LookupResult(null, node); } DecompiledClassNode asmClass = null; String fileName = name.replace('.', '/') + ".class"; URL resource = loader.getResource(fileName); if (resource != null) { try { asmClass = new DecompiledClassNode(AsmDecompiler.parseClass(resource), new AsmReferenceResolver(this, compilationUnit)); if (!asmClass.getName().equals(name)) { // this may happen under Windows because getResource is case insensitive under that OS! asmClass = null; } } catch (IOException e) { // fall through and attempt other search strategies } } if (asmClass != null) { if (isFromAnotherClassLoader(loader, fileName)) { return tryAsScript(name, compilationUnit, asmClass); } return new LookupResult(null, asmClass); } return null; }
public URL getResource(String name) { return delegate.getResource(name); }
public URL getResource(String name) { return delegate.getResource(name); }
public URL getResource(String name) { return delegate.getResource(name); }
public URL getResource(String name) { return delegate.getResource(name); }
/** * Groovy calls this method to locate .groovy script files, * so during the development it's important to check the * resource path before target/classes. */ @Override public URL getResource(String name) { // allow the resource path to take precedence when loading script if(MetaClassLoader.debugLoader!=null) { URL res = MetaClassLoader.debugLoader.loader.getResource(name); if(res!=null) return res; } return super.getResource(name); } };
private URL superGetResource(String name) { if(name.startsWith(Script.class.getPackage().getName().replace('.', '/') + '/')) return Script.class.getClassLoader().getResource(name); return super.getResource(name); }
@Override protected boolean canAdd() { for (String path : paths) { try { if (DependencyCustomizer.this.loader.getResource(path) == null) { return false; } return true; } catch (Exception ex) { // swallow exception and continue } } return DependencyCustomizer.this.canAdd(); } };
@Override protected boolean canAdd() { for (String path : paths) { try { if (DependencyCustomizer.this.loader.getResource(path) != null) { return true; } return false; } catch (Exception ex) { // swallow exception and continue } } return DependencyCustomizer.this.canAdd(); } };
private URL getSourceFile(String name, String extension) { String filename = name.replace('.', '/') + "." + extension; URL ret = getResource(filename); if (isFile(ret) && getFileForUrl(ret, filename) == null) return null; return ret; }
private URL getSourceFile(String name) { String filename = name.replace('.', '/') + config.getDefaultScriptExtension(); URL ret = getResource(filename); if (ret != null && ret.getProtocol().equals("file")) { String fileWithoutPackage = filename; if (fileWithoutPackage.indexOf('/') != -1) { int index = fileWithoutPackage.lastIndexOf('/'); fileWithoutPackage = fileWithoutPackage.substring(index + 1); } File path = new File(decodeFileName(ret.getFile())).getParentFile(); if (path.exists() && path.isDirectory()) { File file = new File(path, fileWithoutPackage); if (file.exists()) { // file.exists() might be case insensitive. Let's do // case sensitive match for the filename File parent = file.getParentFile(); String[] files = parent.list(); for (int j = 0; j < files.length; j++) { if (files[j].equals(fileWithoutPackage)) return ret; } } } //file does not exist! return null; } return ret; }
private URL getSourceFile(String name) { String filename = name.replace('.', '/') + config.getDefaultScriptExtension(); URL ret = getResource(filename); if (ret != null && ret.getProtocol().equals("file")) { String fileWithoutPackage = filename; if (fileWithoutPackage.indexOf('/') != -1) { int index = fileWithoutPackage.lastIndexOf('/'); fileWithoutPackage = fileWithoutPackage.substring(index + 1); } File path = new File(decodeFileName(ret.getFile())).getParentFile(); if (path.exists() && path.isDirectory()) { File file = new File(path, fileWithoutPackage); if (file.exists()) { // file.exists() might be case insensitive. Let's do // case sensitive match for the filename File parent = file.getParentFile(); String[] files = parent.list(); for (int j = 0; j < files.length; j++) { if (files[j].equals(fileWithoutPackage)) return ret; } } } //file does not exist! return null; } return ret; }
private URL getSourceFile(String name) { String filename = name.replace('.', '/') + config.getDefaultScriptExtension(); URL ret = getResource(filename); if (isFile(ret) && getFileForUrl(ret,filename)==null) return null; return ret; }