Refine search
public void execute() throws BuildException { if (taskClasspath==null || taskClasspath.size()==0) { throw new BuildException("no classpath given"); } Project project = getProject(); AntClassLoader loader = new AntClassLoader(makeRoot(),true); project.addReference(name,loader); }
/** * Returns a <code>String</code> representing this loader. * @return the path that this classloader has. */ @Override public String toString() { return "AntClassLoader[" + getClasspath() + "]"; }
/** {@inheritDoc}. */ @Override public boolean eval() throws BuildException { if (classname == null) { throw new BuildException("No classname defined"); } ClassLoader preLoadClass = loader; try { Class<?> clazz = loadClass(classname); if (method != null) { return isMethodFound(clazz); } if (field != null) { return isFieldFound(clazz); } throw new BuildException("Neither method nor field defined"); } finally { if (preLoadClass != loader && loader != null) { loader.cleanup(); loader = null; } } }
target = Class.forName(classname); } else { loader = project.createClassLoader(classpath); loader.setParent(project.getCoreLoader()); loader.setParentFirst(false); loader.addJavaLibraries(); loader.setIsolated(true); loader.setThreadContextLoader(); loader.forceLoadClass(classname); target = Class.forName(classname, true, loader); throw new BuildException( "Could not find %s. Make sure you have it in your classpath", classname); throw new BuildException("Could not find main() method in %s", classname); throw new BuildException( "main() method in %s is not declared static", classname); project.registerThreadTask(thread, currentThreadTask); } finally { if (loader != null) { loader.resetThreadContextLoader(); loader.cleanup(); loader = null;
return getIncludeantruntime() ? getClass().getClassLoader() : new AntClassLoader(new RootLoader(EMPTY_URL_ARRAY, null), getProject(), getClasspath()); antLoader.addPathElement(cpEntry); } catch (BuildException e) { log.warn("The classpath entry " + cpEntry + " is not a valid Java resource");
throw new BuildException( "Unable to find BSF classes for scripting"); fixLoader.addPathComponent(bsfSource); fixLoader.addLoaderPackageRoot(BSF_PACKAGE); fixLoader.addPathComponent( LoaderUtils.getResourceSource( fixLoader, LoaderUtils.classNameToResource(BSF_SCRIPT_RUNNER))); fixLoader.addLoaderPackageRoot(UTIL_OPTIONAL_PACKAGE);
final ClassLoader loader = new AntClassLoader(getProject(), classpath); throw new BuildException(String.format(Locale.ROOT, "Unable to create Root Module: " + "config {%s}, classpath {%s}.", config, classpath), ex);
public void execute() throws BuildException { if (basedir == null) { throw new BuildException("A base directory must be specified."); throw new BuildException("A build directory must be specified."); getProject().log("[ENUNCIATE] Using enunciate configuration at " + this.configFile.getAbsolutePath()); ExpandProperties reader = new ExpandProperties(new FileReader(this.configFile)); reader.setProject(getProject()); String[] filenames = this.classpath.list(); List<File> cp = new ArrayList<File>(filenames.length); for (String filename : filenames) { AntClassLoader loader = new AntClassLoader(Enunciate.class.getClassLoader(), getProject(), this.classpath, true); Thread.currentThread().setContextClassLoader(loader); String[] filenames = this.sourcepath.list(); List<File> cp = new ArrayList<File>(filenames.length); for (String filename : filenames) { throw new BuildException(e);
public void execute() throws BuildException { if (basedir == null) { throw new BuildException("A base directory must be specified."); proxy.setRuntimeClasspath(classpath.toString()); AntClassLoader loader = new AntClassLoader(Enunciate.class.getClassLoader(), getProject(), this.classpath, true); proxy.setBuildClasspath(loader.getClasspath()); Thread.currentThread().setContextClassLoader(loader); ArrayList<DeploymentModule> modules = new ArrayList<DeploymentModule>(); Iterator<DeploymentModule> discoveredModules = ServiceLoader.load(DeploymentModule.class, loader).iterator(); getProject().log("Loading modules from the specified classpath...."); while (discoveredModules.hasNext()) { DeploymentModule discoveredModule = (DeploymentModule) discoveredModules.next(); getProject().log("Discovered module " + discoveredModule.getName()); modules.add(discoveredModule); getProject().log("Loading config " + this.configFile); ExpandProperties reader = new ExpandProperties(new FileReader(this.configFile)); reader.setProject(getProject()); throw new BuildException(e); throw new BuildException(e);
void setupForkCommand(String className) { ClassLoader loader = this.getClass().getClassLoader(); while (loader != null && !(loader instanceof AntClassLoader)) { loader = loader.getParent(); } String antcp = loader != null //taskedef cp ? ((AntClassLoader) loader).getClasspath() //system classloader, ie. env CLASSPATH=... : System.getProperty("java.class.path"); // try to find tools.jar and add it to the cp // so the behaviour on all JDKs is the same // (avoid creating MaskingClassLoader on non-Mac JDKs) File jreHome = new File(System.getProperty("java.home")); File toolsJar = new File(jreHome.getParent(), "lib/tools.jar"); if (toolsJar.exists()) { antcp += File.pathSeparatorChar + toolsJar.getAbsolutePath(); } cmd.createClasspath(getProject()).append(new Path(getProject(), antcp)); cmd.setClassname(className); }
public void execute() { if(configurationTask==null) { throw new BuildException("No configuration specified. <" + getTaskName() + "> must have one of the following: <configuration>, <jpaconfiguration>, <annotationconfiguration> or <jdbcconfiguration>"); Iterator<ExporterTask> iterator = generators.iterator(); AntClassLoader loader = getProject().createClassLoader(classPath); try { ClassLoader classLoader = this.getClass().getClassLoader(); loader.setParent(classLoader ); // if this is not set, classes from the taskdef cannot be found - which is crucial for e.g. annotations. loader.setThreadContextLoader(); loader.resetThreadContextLoader(); loader.cleanup();
if (classpath != null) { cleanup = true; cL = getProject().createClassLoader(classpath); } else { cL = this.getClass().getClassLoader(); throw new BuildException(ex, getLocation()); } finally { FileUtils.close(is); if (cleanup && cL != null) { ((AntClassLoader) cL).cleanup();
if (!fork) { if (classPath != null) macker.setClassLoader(new AntClassLoader(getProject(), classPath, false)); throw new BuildException("nested <classpath> element is required when fork=true"); throw new MackerIsMadException(); if (resultCode != 0) throw new BuildException(MACKER_CHOKED_MESSAGE); printMessageChain(mime); if (angerProperty != null) getProject().setProperty(angerProperty, "true"); if (failOnError) throw new BuildException(MACKER_IS_MAD_MESSAGE); } catch (ListenerException lie) { printMessageChain(lie);
public void execute() throws BuildException { try { Map commandLineOptions = this.fillOptionMap(); ClassLoader conextClassLoader = Thread.currentThread().getContextClassLoader(); AntClassLoader cl = new AntClassLoader(getClass().getClassLoader(), getProject(), classpath == null ? createClasspath() : classpath, false); commandLineOptions.put(Java2WSDLConstants.CLASSPATH_OPTION, new Java2WSDLCommandLineOption(Java2WSDLConstants.CLASSPATH_OPTION, classpath.list())); Thread.currentThread().setContextClassLoader(cl); new Java2WSDLCodegenEngine(commandLineOptions).generate(); Thread.currentThread().setContextClassLoader(conextClassLoader); } catch (Throwable e) { throw new BuildException(e); } }
AntClassLoader cl = new AntClassLoader( getClass().getClassLoader(), getProject(), classpath, false); log("Using CLASSPATH " + cl.getClasspath(), Project.MSG_VERBOSE); ClassUtils.setDefaultClassLoader(cl); url = getProject().resolveFile(url).getAbsolutePath(); } catch (Throwable t){ } else { throw new BuildException("Could not build " + url, e); throw new BuildException("WSDL processing error for " + url +" :\n "+t.getMessage() , t); } finally {
private ResourceLoader setupResourceLoader() { if (classpath == null) { classpath = new Path(project); } /* * 'basedir' is added to the path to make sure that relative paths such * as "<ruleset>resources/custom_ruleset.xml</ruleset>" still work when * ant is invoked from a different directory using "-f" */ classpath.add(new Path(null, project.getBaseDir().toString())); project.log("Using the AntClassLoader: " + classpath, Project.MSG_VERBOSE); // must be true, otherwise you'll get ClassCastExceptions as classes // are loaded twice // and exist in multiple class loaders final boolean parentFirst = true; return new ResourceLoader(new AntClassLoader(Thread.currentThread().getContextClassLoader(), project, classpath, parentFirst)); }
throw new BuildException("Specify an facade to expose"); throw new BuildException("Specify the directory to generate Java classes in"); throw new BuildException("Specify the name to use for lookup"); stubGenerator.setClassGenDir(classGenDir.getAbsolutePath()); stubGenerator.setGenName(genName); stubGenerator.setClasspath(classpath.concatSystemClasspath("ignore").toString()); ClassLoader classLoader = new AntClassLoader(getProject(), classpath); classLoader2 = new AntClassLoader(project, classpath); } else { classLoader2 = this.getClass().getClassLoader();
try { if (classname == null && file == null && resource == null) { throw new BuildException( "At least one of (classname|file|resource) is required", getLocation()); throw new BuildException( "The type attribute is only valid when specifying the file attribute.", getLocation()); classpath.setProject(getProject()); this.loader = getProject().createClassLoader(classpath); loader.cleanup(); loader = null;
String cRef = getClasspathRef(); if (cRef != null) { classPath = (Path) getProject().getReference(cRef); if (classPath == null) { throw new BuildException("The reference " + cRef + " is not set.", getLocation()); acl = new AntClassLoader(cl, getProject(), classPath, true); acl.setThreadContextLoader(); throw e; } catch (Exception e) { throw new BuildException(e, getLocation()); } finally { if (acl != null) { acl.resetThreadContextLoader();
m_helpdocCounters = new HashMap<ResourceBundleDefinition, MutableInteger>(); AntClassLoader classloader = new AntClassLoader( this.getClass().getClassLoader(), getProject(), m_classpath, true ); classloader.setIsolated( false ); Class clazz = classloader.loadClass( class_file ); logMsgIfVerbose( I18N_LOADED_CLASS, clazz ); throw new BuildException( getMsg( I18N_CANNOT_FIND_CLASS, class_file, e.getMessage() ) ); throw new BuildException( getMsg( I18N_CANNOT_APPEND_HELPDOC_TEMPLATE_FOOTER, e.getMessage() ), e );