org.apache.tools.ant.types.Parameter Java Examples

The following examples show how to use org.apache.tools.ant.types.Parameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModuleStateSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testModuleRejectedIfNotEager() throws Exception {
    File cfg = new File(new File(getWorkDir(), "config"), "Modules");
    cfg.mkdirs();
    assertTrue("Created", cfg.isDirectory());
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar("org.my.module", new String[0], m);
    
    File trackingFile = new File(cfg, "org-my-module.xml");
    try (FileWriter w = new FileWriter(trackingFile)) {
        w.write(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                        "<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"\n" +
                        "                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">\n" +
                        "<module name=\"org.my.module\">\n" +
                        "    <param name=\"autoload\">true</param>\n" +
                        "    <param name=\"eager\">false</param>\n" +
                        "    <param name=\"jar\">modules/org-openide-awt.jar</param>\n" +
                        "    <param name=\"reloadable\">false</param>\n" +
                        "    <param name=\"specversion\">7.4.0.1</param>\n" +
                        "</module>\n"
        );
    }

    Parameter p = new Parameter();
    p.setName("acceptEager");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("acceptAutoload");
    p2.setValue("false");
    selector.setParameters(new Parameter[] { p, p2 });
    
    assertFalse("module not accepted", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example #2
Source File: ModuleStateSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testModuleAcceptedIfEager() throws Exception {
    File cfg = new File(new File(getWorkDir(), "config"), "Modules");
    cfg.mkdirs();
    assertTrue("Created", cfg.isDirectory());

    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module/1");
    File aModule = generateJar("org.my.module", new String[0], m);

    File trackingFile = new File(cfg, "org-my-module.xml");
    try (FileWriter w = new FileWriter(trackingFile)) {
        w.write(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                        "<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"\n" +
                        "                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">\n" +
                        "<module name=\"org.my.module\">\n" +
                        "    <param name=\"autoload\">false</param>\n" +
                        "    <param name=\"eager\">true</param>\n" +
                        "    <param name=\"jar\">modules/org-openide-awt.jar</param>\n" +
                        "    <param name=\"reloadable\">false</param>\n" +
                        "    <param name=\"specversion\">7.4.0.1</param>\n" +
                        "</module>\n"
        );
    }

    Parameter p = new Parameter();
    p.setName("acceptEager");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("acceptAutoload");
    p2.setValue("false");
    selector.setParameters(new Parameter[] { p, p2 });

    assertTrue("module accepted", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example #3
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCanExcludeAModule() throws Exception {
    Parameter p = new Parameter();
    p.setName("excludeModules");
    p.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    assertFalse("Refused", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example #4
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCanExcludeOSGiWithAttributes() throws Exception {
    Parameter p = new Parameter();
    p.setName("excludeModules");
    p.setValue("org.eclipse.core.jobs");
    selector.setParameters(new Parameter[] { p });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("Bundle-SymbolicName", "org.eclipse.core.jobs; singleton:=true");
    File aModule = generateJar(new String[0], m);
    assertFalse("Refused", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example #5
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCanShowOnlyExcludedModules() throws Exception {
    Parameter p = new Parameter();
    p.setName("excluded");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("excludeModules");
    p2.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p, p2 });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    assertTrue("Now we are accepting only excluded modules", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
Example #6
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testIsSelectedForNotAModuleIsStillFalseEvenWeAcceptOnlyExcludedModules() throws IOException {
    Parameter p = new Parameter();
    p.setName("excluded");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("excludeModules");
    p2.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p, p2 });
    
    
    File noModule = generateJar(new String[0], createManifest ());
    assertFalse("Not acceptable", selector.isSelected(getWorkDir(), noModule.toString(), noModule));
}
 
Example #7
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testCanExcludeACluster() throws Exception {
    Parameter p = new Parameter();
    p.setName("includeClusters");
    p.setValue("nonexistent");
    selector.setParameters(new Parameter[] { p });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    new File(getWorkDir(), "update_tracking").mkdir();
    assertFalse("Refused", selector.isSelected(getWorkDir().getParentFile(), aModule.toString(), aModule));
}
 
Example #8
Source File: ModuleStateSelector.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void verifySettings() {
    Parameter[] arr = getParameters();
    if (arr == null) {
        return;
    }
    
    for (Parameter p : arr) {
        if ("acceptAutoload".equals(p.getName())) {
            acceptAutoload = Boolean.valueOf(p.getValue());
            continue;
        }
        if ("acceptEager".equals(p.getName())) {
            acceptEager = Boolean.valueOf(p.getValue());
            continue;
        }
        if ("acceptEnabled".equals(p.getName())) {
            acceptEnabled = Boolean.valueOf(p.getValue());
            continue;
        }
        if ("acceptDisabled".equals(p.getName())) {
            acceptDisabled = Boolean.valueOf(p.getValue());
            continue;
        }
        setError("Unknown parameter: " + p.getName());
    }
}
 
Example #9
Source File: OperatorClientTask.java    From development with Apache License 2.0 5 votes vote down vote up
protected Map<String, String> createArguments() {
    final Map<String, String> args = new HashMap<String, String>();
    for (Parameter p : parameters) {
        args.put(p.getName(), p.getValue());
    }
    return args;
}
 
Example #10
Source File: OperatorClientTaskTest.java    From development with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateArguments() {
    final Parameter parameter = new Parameter();
    parameter.setName("key");
    parameter.setValue("value");
    task.addParameter(parameter);

    final Map<String, String> expected = Collections.singletonMap("key",
            "value");
    assertEquals(expected, task.createArguments());
}
 
Example #11
Source File: CompileTask.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Converts {@code <define/>} nested elements into Compiler {@code @define}
 * replacements. Note: unlike project properties, {@code <define/>} elements
 * do not need to be named starting with the replacement prefix.
 */
private void convertDefineParameters(CompilerOptions options) {
  for (Parameter p : defineParams) {
    String key = p.getName();
    Object value = p.getValue();

    if (!setDefine(options, key, value)) {
      log("Unexpected @define value for name=" + key + "; value=" + value);
    }
  }
}
 
Example #12
Source File: ModuleSelectorTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void doParsingOfUpdateTrackingFiles(int parents) throws Exception {
    File updateTracking = new File(getWorkDir(), "update-tracking");
    updateTracking.mkdirs();
    assertTrue("Created", updateTracking.isDirectory());
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    
    File trackingFile = new File(updateTracking, "org-my-module.xml");
    try (FileWriter w = new FileWriter(trackingFile)) {
        w.write(
                "<?xml version='1.0' encoding='UTF-8'?>\n" +
                        "<module codename='org.apache.tools.ant.module/3'>\n" +
                        "<module_version specification_version='3.22' origin='installer' last='true' install_time='1124194231878'>\n" +
                        "<file name='ant/bin/ant' crc='1536373800'/>\n" +
                        "<file name='ant/bin/ant.bat' crc='3245456472'/>\n" +
                        "<file name='ant/bin/ant.cmd' crc='3819623376'/>\n" +
                        "<file name='ant/bin/antRun' crc='2103827286'/>\n" +
                        "<file name='ant/bin/antRun.bat' crc='2739687679'/>\n" +
                        "<file name='ant/bin/antRun.pl' crc='3955456526'/>\n" +
                        "    </module_version>\n" +
                        "</module>\n"
        );
    }

    StringBuilder sb = new StringBuilder();
    sb.append(trackingFile.getPath());
    
    while (--parents > 0) {
        File x = new File(getWorkDir(), parents + ".xml");
        try (FileWriter xw = new FileWriter(x)) {
            xw.write(
                    "<?xml version='1.0' encoding='UTF-8'?>\n" +
                            "<module codename='" + x + "/3'>\n" +
                                    "<module_version specification_version='3.22' origin='installer' last='true' install_time='1124194231878'>\n" +
                                    "    </module_version>\n" +
                                    "</module>\n"
            );
        }
        
        sb.insert(0, File.pathSeparator);
        sb.insert(0, x.getPath());
    }
    
    Parameter p = new Parameter();
    p.setName("updateTrackingFiles");
    p.setValue(sb.toString());
    selector.setParameters(new Parameter[] { p });
    
    assertTrue("module accepted", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
    assertTrue("its file as well", selector.isSelected(getWorkDir(), "ant/bin/ant.bat", new File(aModule.getParent(), "ant/bin/ant.bat")));
    assertTrue("also the tracking file is accepted", selector.isSelected(getWorkDir(), "update-tracking/" + trackingFile.getName(), trackingFile));
}
 
Example #13
Source File: ModuleSelector.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void verifySettings() {
    if (includeClusters != null) {
        return;
    }
    
    includeClusters = new HashSet<>();
    excludeClusters = new HashSet<>();
    excludeModules = new HashSet<>();
    
    Parameter[] arr = getParameters();
    if (arr == null) {
        return;
    }
    
    for (Parameter p : arr) {
        if ("excludeModules".equals(p.getName())) {
            parse(p.getValue(), excludeModules);
            log("Will excludeModules: " + excludeModules, Project.MSG_VERBOSE);
            continue;
        }
        if ("includeClusters".equals(p.getName())) {
            parse(p.getValue(), includeClusters);
            log("Will includeClusters: " + includeClusters, Project.MSG_VERBOSE);
            continue;
        }
        if ("excludeClusters".equals(p.getName())) {
            parse(p.getValue(), excludeClusters);
            log("Will excludeClusters: " + excludeClusters, Project.MSG_VERBOSE);
            continue;
        }
        if ("excluded".equals(p.getName())) {
            acceptExcluded = Boolean.parseBoolean(p.getValue());
            log("Will acceptExcluded: " + acceptExcluded, Project.MSG_VERBOSE);
            continue;
        }
        if ("updateTrackingFiles".equals(p.getName())) {
            fileToOwningModule = new HashMap<>();
            try {
                readUpdateTracking(getProject(), p.getValue(), fileToOwningModule);
            } catch (IOException | ParserConfigurationException | SAXException ex) {
                throw new BuildException(ex);
            }
            log("Will accept these files: " + fileToOwningModule.keySet(), Project.MSG_VERBOSE);
            continue;
        }
        setError("Unknown parameter: " + p.getName());
    }
}
 
Example #14
Source File: OperatorClientTask.java    From development with Apache License 2.0 4 votes vote down vote up
public void addParameter(Parameter parameter) {
    this.parameters.add(parameter);
}
 
Example #15
Source File: TcasesTask.java    From tcases with MIT License 4 votes vote down vote up
/**
 * Adds a transform parameter.
 */
public void addConfiguredParam( Parameter param)
  {
  options_.getTransformParams().put( param.getName(), param.getValue());
  }
 
Example #16
Source File: CompileTask.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@code <define/>} nested element. Supports name and value
 * attributes.
 */
public Parameter createDefine() {
  Parameter param = new Parameter();
  defineParams.add(param);
  return param;
}