private CompilationState createCompilationState(ModuleDef moduleDef, CompilerContext compilerContext) throws UnableToCompleteException { TreeLogger treeLogger = GwtTreeLogger.get(); return moduleDef.getCompilationState(treeLogger, compilerContext); }
private static boolean maybeOverrideConfig(ModuleDef module, String propName, String newValue) { ConfigurationProperty config = module.getProperties().findConfigProp(propName); if (config != null) { config.setValue(newValue); return true; } return false; }
compilerContext = compilerContextBuilder.module(module).build(); for (String path : module.getServletPaths()) { String servletClass = module.findServletForPath(path); path = '/' + module.getName() + path; if (!servletClass.equals(loadedServletsByPath.get(path))) { try { TreeLogger.WARN, "Failed to load servlet class '" + servletClass + "' declared in '" + module.getName() + "'", e); Linker l = module.getActivePrimaryLinker().newInstance(); StandardLinkerContext context = new StandardLinkerContext( getTopLogger(), module, compilerContext.getPublicResourceOracle(), JsOutputOption.PRETTY); if (!l.supportsDevModeInJunit(context)) { if (module.getLinker("std") != null) { module.addLinker("std");
moduleDef.clearEntryPoints(); moduleDef.addEntryPointTypeName(LogConfiguration.class.getName()); moduleDef.addEntryPointTypeName(GWTRunner.class.getName()); ConfigurationProperty moduleNameProp = moduleDef.getProperties().createConfiguration( "junit.moduleName", false); moduleNameProp.setValue(syntheticModuleName);
protected PropertyOracle getPropertyOracle() { if (propertyOracle == null) { PropertyCombinations permutations = new PropertyCombinations(moduleDef.getProperties(), moduleDef.getActiveLinkerNames()); SortedSet<ConfigurationProperty> configPropSet = moduleDef.getProperties().getConfigurationProperties(); ConfigurationProperty[] configProps = configPropSet.toArray(new ConfigurationProperty[configPropSet.size()]); BindingProperty[] orderedProperties = permutations.getOrderedProperties(); WithProperties withProperties = GwtTestDataHolder.get().getCurrentWithProperties(); String[] processedProperties; if (withProperties != null) { processedProperties = replaceOrderedPropertyValues(orderedProperties, permutations.getOrderedPropertyValues(0), withProperties); } else { processedProperties = permutations.getOrderedPropertyValues(0); } propertyOracle = new StaticPropertyOracle(orderedProperties, processedProperties, configProps); } return propertyOracle; }
for (BindingProperty bindingProperty : moduleDef.getProperties().getBindingProperties()) { bindingProperty.resetGeneratedValues(); if (IFrameLinker.class.isAssignableFrom(moduleDef.getActivePrimaryLinker())) { moduleDef.addLinker("xsiframe"); Class<? extends Linker> linker = moduleDef.getActivePrimaryLinker(); if (!CrossSiteIframeLinker.class.isAssignableFrom(linker)) { logger.log(TreeLogger.ERROR, if (moduleDef.deactivateLinker("precompress")) { logger.log(TreeLogger.WARN, "Deactivated PrecompressLinker"); moduleDef.getName()); SourceHandler.sourceMapLocationTemplate(moduleDef.getName()));
module.getCompilationState(compileLogger, compilerContext); outputModuleName.set(module.getName()); } finally { compileLogger.log(TreeLogger.Type.INFO, "Module setup completed in " + elapsedTime + " ms"); return new Result(compileDir, module.getName(), null);
String newModuleName = module.getName(); outputModuleName.set(newModuleName); new PropertyCombinations(module.getProperties(), module.getActiveLinkerNames()); List<PropertyCombinations> permutationPropertySets = propertyCombinations.collapseProperties(); if (options.isIncrementalCompileEnabled() && permutationPropertySets.size() > 1) {
public void onModuleReady(ModuleSpace readySpace) throws UnableToCompleteException { this.space = readySpace; Event moduleSpaceHostReadyEvent = SpeedTracerLogger.start(DevModeEventType.MODULE_SPACE_HOST_READY); try { // Establish an environment for JavaScript property providers to run. // ModuleSpacePropertyOracle propOracle = new ModuleSpacePropertyOracle( module.getProperties(), module.getActiveLinkerNames(), readySpace); // Set up the rebind oracle for the module. // It has to wait until now because we need to inject javascript. // Deque<Rule> rules = module.getRules(); PrecompileTaskOptionsImpl options = new PrecompileTaskOptionsImpl(); options.setGenDir(genDir); CompilerContext compilerContext = new CompilerContext.Builder().module(module).options( options).build(); StandardGeneratorContext genCtx = new StandardGeneratorContext(compilerContext, compilationState, new ArtifactSet(), false); // Only enable generator result caching if we have a valid rebindCache genCtx.setGeneratorResultCachingEnabled(rebindCache != null); rebindOracle = new StandardRebindOracle2(propOracle, rules, genCtx); rebindOracle.setRebindCache(rebindCache); } finally { moduleSpaceHostReadyEvent.end(); } }
void compileForWebMode(ModuleDef module, Set<String> userAgents) throws UnableToCompleteException { if (userAgents != null && !userAgents.isEmpty()) { Properties props = module.getProperties(); Property userAgent = props.find("user.agent"); if (userAgent instanceof BindingProperty) { BindingProperty bindingProperty = (BindingProperty) userAgent; bindingProperty.setRootGeneratedValues(userAgents.toArray(new String[0])); } } if (!Compiler.maybeRestrictProperties(getTopLogger(), module, options.getProperties())) { throw new UnableToCompleteException(); } if (options.isClosureCompilerFormatEnabled()) { module.addLinker("closureHelpers"); } boolean success = false; try { success = new Compiler(options).run(getTopLogger(), module); } catch (Exception e) { getTopLogger().log(Type.ERROR, "Compiler aborted with an exception ", e); } if (!success) { throw new UnableToCompleteException(); } // TODO(scottb): prepopulate currentCompilationState somehow? }
File moduleDir = new File(launcherDir + "/" + module.getName()); if (!moduleDir.isDirectory()) { if (!moduleDir.mkdirs()) { String stub = generateStubNocacheJs(module.getName(), options); final File noCacheJs = new File(moduleDir, module.getName() + ".nocache.js"); Files.write(stub, noCacheJs, Charsets.UTF_8); for (PolicyFile policyFile : compileDir.readRpcPolicyManifest(module.getName())) { String filename = policyFile.getName(); File src = new File(compileDir.getWarDir(), module.getName() + "/" + filename); File dest = new File(moduleDir, filename); Files.copy(src, dest);
public Class<?> getRemoteServiceImplClass(String remoteServicePath) { if (!remoteServicePath.startsWith("/")) { remoteServicePath = "/" + remoteServicePath; } String servletClassName = GwtFactory.get().getModuleDef().findServletForPath( remoteServicePath); if (servletClassName == null) { return null; } try { return Class.forName(servletClassName, true, GwtFactory.get().getClassLoader()); } catch (ClassNotFoundException e) { throw new GwtTestConfigurationException("Cannot find servlet class '" + servletClassName + "' configured for servlet path '" + remoteServicePath + "'"); } }
for (BindingProperty bindingProperty : moduleDef.getProperties().getBindingProperties()) { bindingProperty.resetGeneratedValues(); if (IFrameLinker.class.isAssignableFrom(moduleDef.getActivePrimaryLinker())) { moduleDef.addLinker("xsiframe"); Class<? extends Linker> linker = moduleDef.getActivePrimaryLinker(); if (!CrossSiteIframeLinker.class.isAssignableFrom(linker)) { logger.log(TreeLogger.ERROR, if (moduleDef.deactivateLinker("precompress")) { logger.log(TreeLogger.WARN, "Deactivated PrecompressLinker"); moduleDef.getName()); SourceHandler.sourceMapLocationTemplate(moduleDef.getName()));
module.getCompilationState(compileLogger, compilerContext); outputModuleName.set(module.getName()); } finally { compileLogger.log(TreeLogger.Type.INFO, "Module setup completed in " + elapsedTime + " ms"); return new Result(compileDir, module.getName(), null);
String newModuleName = module.getName(); outputModuleName.set(newModuleName); new PropertyCombinations(module.getProperties(), module.getActiveLinkerNames()); List<PropertyCombinations> permutationPropertySets = propertyCombinations.collapseProperties(); if (options.isIncrementalCompileEnabled() && permutationPropertySets.size() > 1) {
public void onModuleReady(ModuleSpace readySpace) throws UnableToCompleteException { this.space = readySpace; Event moduleSpaceHostReadyEvent = SpeedTracerLogger.start(DevModeEventType.MODULE_SPACE_HOST_READY); try { // Establish an environment for JavaScript property providers to run. // ModuleSpacePropertyOracle propOracle = new ModuleSpacePropertyOracle( module.getProperties(), module.getActiveLinkerNames(), readySpace); // Set up the rebind oracle for the module. // It has to wait until now because we need to inject javascript. // Deque<Rule> rules = module.getRules(); PrecompileTaskOptionsImpl options = new PrecompileTaskOptionsImpl(); options.setGenDir(genDir); CompilerContext compilerContext = new CompilerContext.Builder().module(module).options( options).build(); StandardGeneratorContext genCtx = new StandardGeneratorContext(compilerContext, compilationState, new ArtifactSet(), false); // Only enable generator result caching if we have a valid rebindCache genCtx.setGeneratorResultCachingEnabled(rebindCache != null); rebindOracle = new StandardRebindOracle2(propOracle, rules, genCtx); rebindOracle.setRebindCache(rebindCache); } finally { moduleSpaceHostReadyEvent.end(); } }
moduleDef.clearEntryPoints(); moduleDef.addEntryPointTypeName(LogConfiguration.class.getName()); moduleDef.addEntryPointTypeName(GWTRunner.class.getName()); ConfigurationProperty moduleNameProp = moduleDef.getProperties().createConfiguration( "junit.moduleName", false); moduleNameProp.setValue(syntheticModuleName);
protected PropertyOracle getPropertyOracle() { if (propertyOracle == null) { PropertyCombinations permutations = new PropertyCombinations(moduleDef.getProperties(), moduleDef.getActiveLinkerNames()); SortedSet<ConfigurationProperty> configPropSet = moduleDef.getProperties().getConfigurationProperties(); ConfigurationProperty[] configProps = configPropSet.toArray(new ConfigurationProperty[configPropSet.size()]); BindingProperty[] orderedProperties = permutations.getOrderedProperties(); WithProperties withProperties = GwtTestDataHolder.get().getCurrentWithProperties(); String[] processedProperties; if (withProperties != null) { processedProperties = replaceOrderedPropertyValues(orderedProperties, permutations.getOrderedPropertyValues(0), withProperties); } else { processedProperties = permutations.getOrderedPropertyValues(0); } propertyOracle = new StaticPropertyOracle(orderedProperties, processedProperties, configProps); } return propertyOracle; }
TreeLogger compileLogger) throws UnableToCompleteException { try { String currentModuleName = module.getName(); String stub = LauncherDir.generateStubNocacheJs(module.getName(), options); File noCacheJs = new File(outputDir.getCanonicalPath(), module.getName() + ".nocache.js"); Files.write(stub, noCacheJs, Charsets.UTF_8);
public Class<?> getRemoteServiceImplClass(String remoteServicePath) { if (!remoteServicePath.startsWith("/")) { remoteServicePath = "/" + remoteServicePath; } String servletClassName = GwtFactory.get().getModuleDef().findServletForPath( remoteServicePath); if (servletClassName == null) { return null; } try { return Class.forName(servletClassName, true, GwtFactory.get().getClassLoader()); } catch (ClassNotFoundException e) { throw new GwtTestConfigurationException("Cannot find servlet class '" + servletClassName + "' configured for servlet path '" + remoteServicePath + "'"); } }