Package com.google.gwt.dev.cfg

Examples of com.google.gwt.dev.cfg.ModuleDef$LibraryDependencyEdge


  /**
   * Make sure that a cycle doesn't cause an infinite loop.
   */
  public void testCycle() {
    // This is what you'd get with a conditional <set-property value="false">
    ModuleDef md = new ModuleDef("testCycle");
    Properties props = md.getProperties();

    {
      BindingProperty prop = props.createBinding("A");
      prop.addDefinedValue(prop.getRootCondition(), "a1");
      prop.addDefinedValue(prop.getRootCondition(), "a2");

      prop.addDefinedValue(new ConditionWhenPropertyIs("B", "b3"), "a3");
    }

    {
      BindingProperty prop = props.createBinding("B");
      prop.addDefinedValue(prop.getRootCondition(), "b1");
      prop.addDefinedValue(prop.getRootCondition(), "b2");

      prop.addDefinedValue(new ConditionWhenPropertyIs("A", "a3"), "b3");
    }

    try {
      new PropertyPermutations(props, md.getActiveLinkerNames());
      fail();
    } catch (IllegalStateException e) {
      // OK
    }
  }
View Full Code Here


      // OK
    }
  }

  public void testOneDimensionPerm() {
    ModuleDef md = new ModuleDef("testOneDimensionPerm");
    Properties props = md.getProperties();

    {
      BindingProperty prop = props.createBinding("debug");
      prop.addDefinedValue(prop.getRootCondition(), "false");
      prop.addDefinedValue(prop.getRootCondition(), "true");
    }

    // Permutations and their values are in stable alphabetical order.
    //
    PropertyPermutations perms = new PropertyPermutations(md.getProperties(),
        md.getActiveLinkerNames());
    String[] perm;
    Iterator<String[]> iter = perms.iterator();

    assertTrue(iter.hasNext());
    perm = iter.next();
View Full Code Here

    perm = iter.next();
    assertEquals("true", perm[0]);
  }

  public void testOneDimensionPermWithCollapse() {
    ModuleDef md = new ModuleDef("testOneDimensionPerm");
    Properties props = md.getProperties();

    {
      BindingProperty prop = props.createBinding("debug");
      prop.addDefinedValue(prop.getRootCondition(), "false");
      prop.addDefinedValue(prop.getRootCondition(), "true");
      prop.addCollapsedValues("true", "false");
    }

    // Permutations and their values are in stable alphabetical order.
    //
    PropertyPermutations perms = new PropertyPermutations(md.getProperties(),
        md.getActiveLinkerNames());

    List<PropertyPermutations> collapsed = perms.collapseProperties();
    assertEquals("size", 1, collapsed.size());
    perms = collapsed.get(0);
View Full Code Here

    perm = iter.next();
    assertEquals("true", perm[0]);
  }

  public void testTwoDimensionPerm() {
    ModuleDef md = new ModuleDef("testTwoDimensionPerm");
    Properties props = md.getProperties();

    {
      BindingProperty prop = props.createBinding("user.agent");
      prop.addDefinedValue(prop.getRootCondition(), "moz");
      prop.addDefinedValue(prop.getRootCondition(), "ie6");
      prop.addDefinedValue(prop.getRootCondition(), "opera");
    }

    {
      BindingProperty prop = props.createBinding("debug");
      prop.addDefinedValue(prop.getRootCondition(), "false");
      prop.addDefinedValue(prop.getRootCondition(), "true");
    }

    // String[]s and their values are in stable alphabetical order.
    //
    PropertyPermutations perms = new PropertyPermutations(md.getProperties(),
        md.getActiveLinkerNames());
    String[] perm;
    Iterator<String[]> iter = perms.iterator();

    assertTrue(iter.hasNext());
    perm = iter.next();
View Full Code Here

    assertEquals("true", perm[0]);
    assertEquals("opera", perm[1]);
  }

  public void testTwoDimensionPermWithCollapse() {
    ModuleDef md = new ModuleDef("testTwoDimensionPerm");
    Properties props = md.getProperties();

    {
      BindingProperty prop = props.createBinding("user.agent");
      prop.addDefinedValue(prop.getRootCondition(), "moz");
      prop.addDefinedValue(prop.getRootCondition(), "ie6");
      prop.addDefinedValue(prop.getRootCondition(), "opera");
      prop.addCollapsedValues("moz", "ie6", "opera");
    }

    {
      BindingProperty prop = props.createBinding("debug");
      prop.addDefinedValue(prop.getRootCondition(), "false");
      prop.addDefinedValue(prop.getRootCondition(), "true");
    }

    // String[]s and their values are in stable alphabetical order.
    //
    PropertyPermutations perms = new PropertyPermutations(md.getProperties(),
        md.getActiveLinkerNames());

    List<PropertyPermutations> collapsed = perms.collapseProperties();
    assertEquals("size", 2, collapsed.size());

    Iterator<String[]> it = collapsed.get(0).iterator();
View Full Code Here

    assertEquals(Arrays.asList("true", "opera"), Arrays.asList(it.next()));
    assertFalse(it.hasNext());
  }

  public void testTwoDimensionPermWithExpansion() {
    ModuleDef md = new ModuleDef("testTwoDimensionsWithExpansion");
    Properties props = md.getProperties();

    {
      BindingProperty prop = props.createBinding("user.agent");
      prop.addDefinedValue(prop.getRootCondition(), "moz");
      prop.addDefinedValue(prop.getRootCondition(), "ie6");
      prop.addDefinedValue(prop.getRootCondition(), "ie8");
      prop.addDefinedValue(prop.getRootCondition(), "opera");
    }

    {
      BindingProperty prop = props.createBinding("stackTraces");
      prop.addDefinedValue(prop.getRootCondition(), "false");
      prop.addDefinedValue(prop.getRootCondition(), "true");
      // <set-property name="stackTraces" value="false" />
      prop.setValues(prop.getRootCondition(), "false");

      /*
       * <set-property name="stackTraces" value="true,false"> <when user.agent
       * is ie6 or ie 8> </set-property>
       */
      ConditionAny cond = new ConditionAny();
      cond.getConditions().add(new ConditionWhenPropertyIs("user.agent", "ie6"));
      cond.getConditions().add(new ConditionWhenPropertyIs("user.agent", "ie8"));
      prop.setValues(cond, "true", "false");
    }

    validateTwoDimensionPerm(props, md.getActiveLinkerNames());
  }
View Full Code Here

    validateTwoDimensionPerm(props, md.getActiveLinkerNames());
  }

  public void testTwoDimensionPermWithExtension() {
    // This is what you'd get with a conditional <extend-property>
    ModuleDef md = new ModuleDef("testTwoDimensionsWithConditions");
    Properties props = md.getProperties();

    {
      BindingProperty prop = props.createBinding("user.agent");
      prop.addDefinedValue(prop.getRootCondition(), "moz");
      prop.addDefinedValue(prop.getRootCondition(), "ie6");
      prop.addDefinedValue(prop.getRootCondition(), "ie8");
      prop.addDefinedValue(prop.getRootCondition(), "opera");
    }

    {
      BindingProperty prop = props.createBinding("stackTraces");
      prop.addDefinedValue(prop.getRootCondition(), "false");

      ConditionAny cond = new ConditionAny();
      cond.getConditions().add(new ConditionWhenPropertyIs("user.agent", "ie6"));
      cond.getConditions().add(new ConditionWhenPropertyIs("user.agent", "ie8"));

      prop.addDefinedValue(cond, "true");
    }

    validateTwoDimensionPerm(props, md.getActiveLinkerNames());
  }
View Full Code Here

    validateTwoDimensionPerm(props, md.getActiveLinkerNames());
  }

  public void testTwoDimensionPermWithRestriction() {
    // This is what you'd get with a conditional <set-property value="false">
    ModuleDef md = new ModuleDef("testTwoDimensionsWithRestriction");
    Properties props = md.getProperties();

    {
      BindingProperty prop = props.createBinding("user.agent");
      prop.addDefinedValue(prop.getRootCondition(), "moz");
      prop.addDefinedValue(prop.getRootCondition(), "ie6");
      prop.addDefinedValue(prop.getRootCondition(), "ie8");
      prop.addDefinedValue(prop.getRootCondition(), "opera");
    }

    {
      BindingProperty prop = props.createBinding("stackTraces");
      prop.addDefinedValue(prop.getRootCondition(), "false");
      prop.addDefinedValue(prop.getRootCondition(), "true");

      ConditionAny cond = new ConditionAny();
      cond.getConditions().add(new ConditionWhenPropertyIs("user.agent", "moz"));
      cond.getConditions().add(
          new ConditionWhenPropertyIs("user.agent", "opera"));

      prop.setValues(cond, "false");
    }

    validateTwoDimensionPerm(props, md.getActiveLinkerNames());
  }
View Full Code Here

  }

  void compileForWebMode(String moduleName, String userAgentString)
      throws UnableToCompleteException {
    // Never fresh during JUnit.
    ModuleDef module = ModuleDefLoader.loadFromClassPath(getTopLogger(),
        moduleName, false);
    if (userAgentString != null) {
      Properties props = module.getProperties();
      Property userAgent = props.find("user.agent");
      if (userAgent instanceof BindingProperty) {
        ((BindingProperty) userAgent).setAllowedValues(userAgentString);
      }
    }
View Full Code Here

  }

  public boolean run(TreeLogger logger) throws UnableToCompleteException {
    for (String moduleName : options.getModuleNames()) {
      File compilerWorkDir = options.getCompilerWorkDir(moduleName);
      ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, moduleName);

      File precompilationFile = new File(compilerWorkDir,
          Precompile.PRECOMPILATION_FILENAME);
      if (!precompilationFile.exists()) {
        logger.log(TreeLogger.ERROR, "File not found '"
            + precompilationFile.getAbsolutePath()
            + "'; please run Precompile first");
        return false;
      }

      Precompilation precompilation;
      try {
        precompilation = Util.readFileAsObject(precompilationFile,
            Precompilation.class);
      } catch (ClassNotFoundException e) {
        logger.log(TreeLogger.ERROR, "Unable to deserialize '"
            + precompilationFile.getAbsolutePath() + "'", e);
        return false;
      }
      Permutation[] perms = precompilation.getPermutations();
      File[] resultFiles = new File[perms.length];
      for (int i = 0; i < perms.length; ++i) {
        resultFiles[i] = CompilePerms.makePermFilename(compilerWorkDir,
            perms[i].getId());
        if (!resultFiles[i].exists()) {
          logger.log(TreeLogger.ERROR, "File not found '"
              + precompilationFile.getAbsolutePath()
              + "'; please compile all permutations");
          return false;
        }
      }

      TreeLogger branch = logger.branch(TreeLogger.INFO, "Linking module "
          + module.getName());
      StandardLinkerContext linkerContext = new StandardLinkerContext(branch,
          module, precompilation.getUnifiedAst().getOptions());
      ArtifactSet artifacts = doLink(branch, linkerContext, precompilation,
          resultFiles);
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.cfg.ModuleDef$LibraryDependencyEdge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.