org.apache.ivy.core.module.descriptor.ExcludeRule Java Examples

The following examples show how to use org.apache.ivy.core.module.descriptor.ExcludeRule. 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: IvyConfigurationProvider.java    From walkmod-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void addArtifact(String groupId, String artifactId, String version) throws Exception {

		artifacts.add(groupId+":"+artifactId+":"+version);

		String[] dep = null;
		dep = new String[] { groupId, artifactId, version };
		if (md == null) {
			md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(dep[0], dep[1] + "-caller",
					"working"));
		}
		DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(dep[0],
				dep[1], dep[2]), false, false, true);
		md.addDependency(dd);
		ExcludeRule er = new DefaultExcludeRule(new ArtifactId(new ModuleId("org.walkmod", "walkmod-core"),
				PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION),
				ExactPatternMatcher.INSTANCE, null);
		dd.addExcludeRule(null, er);
	}
 
Example #2
Source File: IvyConfigurationProvider.java    From walkmod-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void addArtifact(String groupId, String artifactId, String version) throws Exception {

		artifacts.add(groupId+":"+artifactId+":"+version);

		String[] dep = null;
		dep = new String[] { groupId, artifactId, version };
		if (md == null) {
			md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(dep[0], dep[1] + "-caller",
					"working"));
		}
		DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(dep[0],
				dep[1], dep[2]), false, false, true);
		md.addDependency(dd);
		ExcludeRule er = new DefaultExcludeRule(new ArtifactId(new ModuleId("org.walkmod", "walkmod-core"),
				PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION),
				ExactPatternMatcher.INSTANCE, null);
		dd.addExcludeRule(null, er);
	}
 
Example #3
Source File: ModuleVersionSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ExcludeRuleBackedSpec(Iterable<ExcludeRule> excludeRules) {
    for (ExcludeRule rule : excludeRules) {
        if (!(rule.getMatcher() instanceof ExactPatternMatcher)) {
            excludeSpecs.add(new ExcludeRuleSpec(rule));
            continue;
        }
        ModuleId moduleId = rule.getId().getModuleId();
        boolean wildcardGroup = PatternMatcher.ANY_EXPRESSION.equals(moduleId.getOrganisation());
        boolean wildcardModule = PatternMatcher.ANY_EXPRESSION.equals(moduleId.getName());
        if (wildcardGroup && wildcardModule) {
            excludeSpecs.add(new ExcludeRuleSpec(rule));
        } else if (wildcardGroup) {
            excludeSpecs.add(new ModuleNameSpec(moduleId.getName()));
        } else if (wildcardModule) {
            excludeSpecs.add(new GroupNameSpec(moduleId.getOrganisation()));
        } else {
            excludeSpecs.add(new ModuleIdSpec(moduleId));
        }
    }
}
 
Example #4
Source File: AbstractModuleDescriptorParserTester.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
protected void assertDependencyModulesExcludes(DependencyDescriptor dd, String[] confs,
        String[] moduleNames) {
    ExcludeRule[] rules = dd.getExcludeRules(confs);
    assertNotNull(rules);
    assertEquals(moduleNames.length, rules.length);
    for (String moduleName : moduleNames) {
        boolean found = false;
        for (ExcludeRule rule : rules) {
            assertNotNull(rule);
            if (rule.getId().getModuleId().getName().equals(moduleName)) {
                found = true;
                break;
            }
        }
        assertTrue("dependency module exclude not found: " + moduleName, found);
    }
}
 
Example #5
Source File: AbstractModuleDescriptorParserTester.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
protected void assertDependencyArtifactExcludeRules(DependencyDescriptor dd, String[] confs,
        String[] artifactsNames) {
    ExcludeRule[] rules = dd.getExcludeRules(confs);
    assertNotNull(rules);
    assertEquals(artifactsNames.length, rules.length);
    for (String artifactsName : artifactsNames) {
        boolean found = false;
        for (ExcludeRule rule : rules) {
            assertNotNull(rule);
            if (rule.getId().getName().equals(artifactsName)) {
                found = true;
                break;
            }
        }
        assertTrue("dependency exclude not found: " + artifactsName, found);
    }
}
 
Example #6
Source File: XmlModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
protected void addConfiguration(String c) {
    confAware.addConfiguration(c);
    if (state == State.EXCLUDE) {
        // we are adding a configuration to a module wide exclude rule we have nothing
        // special to do here, the rule has already been added to the module descriptor
    } else {
        // we are currently adding a configuration to either an include, exclude or artifact
        // element of a dependency. This means that we have to add this element to the
        // corresponding conf of the current dependency descriptor
        if (confAware instanceof DependencyArtifactDescriptor) {
            dd.addDependencyArtifact(c, (DependencyArtifactDescriptor) confAware);
        } else if (confAware instanceof IncludeRule) {
            dd.addIncludeRule(c, (IncludeRule) confAware);
        } else if (confAware instanceof ExcludeRule) {
            dd.addExcludeRule(c, (ExcludeRule) confAware);
        }
    }
}
 
Example #7
Source File: XmlModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private static void printDependencyExcludeRules(ModuleDescriptor md, PrintWriter out,
        ExcludeRule[] excludes) {
    if (excludes.length > 0) {
        for (ExcludeRule exclude : excludes) {
            out.print(String.format("\t\t\t<exclude org=\"%s\" module=\"%s\" name=\"%s\" type=\"%s\" ext=\"%s\"",
                    XMLHelper.escape(exclude.getId().getModuleId().getOrganisation()),
                    XMLHelper.escape(exclude.getId().getModuleId().getName()),
                    XMLHelper.escape(exclude.getId().getName()),
                    XMLHelper.escape(exclude.getId().getType()),
                    XMLHelper.escape(exclude.getId().getExt())));
            String[] ruleConfs = exclude.getConfigurations();
            if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                out.print(listToPrefixedString(ruleConfs, " conf=\""));
            }
            out.print(" matcher=\"" + XMLHelper.escape(exclude.getMatcher().getName()) + "\"");
            out.println("/>");
        }
    }
}
 
Example #8
Source File: XmlModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private static void printAllExcludes(ModuleDescriptor md, PrintWriter out) {
    ExcludeRule[] excludes = md.getAllExcludeRules();
    if (excludes.length > 0) {
        for (ExcludeRule exclude : excludes) {
            out.print(String.format("\t\t<exclude org=\"%s\" module=\"%s\" artifact=\"%s\" type=\"%s\" ext=\"%s\"",
                    XMLHelper.escape(exclude.getId().getModuleId().getOrganisation()),
                    XMLHelper.escape(exclude.getId().getModuleId().getName()),
                    XMLHelper.escape(exclude.getId().getName()),
                    XMLHelper.escape(exclude.getId().getType()),
                    XMLHelper.escape(exclude.getId().getExt())));
            String[] ruleConfs = exclude.getConfigurations();
            if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                out.print(listToPrefixedString(ruleConfs, " conf=\""));
            }
            out.print(" matcher=\"" + XMLHelper.escape(exclude.getMatcher().getName()) + "\"");
            out.println("/>");
        }
    }
}
 
Example #9
Source File: PomModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private static void printExclusions(ExcludeRule[] exclusions, PrintWriter out, int indent) {
    indent(out, indent * 3);
    out.println("<exclusions>");

    for (ExcludeRule exclusion : exclusions) {
        indent(out, indent * 4);
        out.println("<exclusion>");
        indent(out, indent * 5);
        out.println(
            "<groupId>" + exclusion.getId().getModuleId().getOrganisation() + "</groupId>");
        indent(out, indent * 5);
        out.println(
            "<artifactId>" + exclusion.getId().getModuleId().getName() + "</artifactId>");
        indent(out, indent * 4);
        out.println("</exclusion>");
    }

    indent(out, indent * 3);
    out.println("</exclusions>");
}
 
Example #10
Source File: ModuleVersionSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ExcludeRuleBackedSpec(Iterable<ExcludeRule> excludeRules) {
    for (ExcludeRule rule : excludeRules) {
        if (!(rule.getMatcher() instanceof ExactPatternMatcher)) {
            excludeSpecs.add(new ExcludeRuleSpec(rule));
            continue;
        }
        ModuleId moduleId = rule.getId().getModuleId();
        boolean wildcardGroup = PatternMatcher.ANY_EXPRESSION.equals(moduleId.getOrganisation());
        boolean wildcardModule = PatternMatcher.ANY_EXPRESSION.equals(moduleId.getName());
        if (wildcardGroup && wildcardModule) {
            excludeSpecs.add(new ExcludeRuleSpec(rule));
        } else if (wildcardGroup) {
            excludeSpecs.add(new ModuleNameSpec(moduleId.getName()));
        } else if (wildcardModule) {
            excludeSpecs.add(new GroupNameSpec(moduleId.getOrganisation()));
        } else {
            excludeSpecs.add(new ModuleIdSpec(moduleId));
        }
    }
}
 
Example #11
Source File: ModuleVersionSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ExcludeRuleBackedSpec(Iterable<ExcludeRule> excludeRules) {
    for (ExcludeRule rule : excludeRules) {
        if (!(rule.getMatcher() instanceof ExactPatternMatcher)) {
            excludeSpecs.add(new ExcludeRuleSpec(rule));
            continue;
        }
        ModuleId moduleId = rule.getId().getModuleId();
        boolean wildcardGroup = PatternMatcher.ANY_EXPRESSION.equals(moduleId.getOrganisation());
        boolean wildcardModule = PatternMatcher.ANY_EXPRESSION.equals(moduleId.getName());
        if (wildcardGroup && wildcardModule) {
            excludeSpecs.add(new ExcludeRuleSpec(rule));
        } else if (wildcardGroup) {
            excludeSpecs.add(new ModuleNameSpec(moduleId.getName()));
        } else if (wildcardModule) {
            excludeSpecs.add(new GroupNameSpec(moduleId.getOrganisation()));
        } else {
            excludeSpecs.add(new ModuleIdSpec(moduleId));
        }
    }
}
 
Example #12
Source File: ModuleVersionSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private ExcludeRuleBackedSpec(Iterable<ExcludeRule> excludeRules) {
    for (ExcludeRule rule : excludeRules) {
        if (!(rule.getMatcher() instanceof ExactPatternMatcher)) {
            excludeSpecs.add(new ExcludeRuleSpec(rule));
            continue;
        }
        ModuleId moduleId = rule.getId().getModuleId();
        boolean wildcardGroup = PatternMatcher.ANY_EXPRESSION.equals(moduleId.getOrganisation());
        boolean wildcardModule = PatternMatcher.ANY_EXPRESSION.equals(moduleId.getName());
        if (wildcardGroup && wildcardModule) {
            excludeSpecs.add(new ExcludeRuleSpec(rule));
        } else if (wildcardGroup) {
            excludeSpecs.add(new ModuleNameSpec(moduleId.getName()));
        } else if (wildcardModule) {
            excludeSpecs.add(new GroupNameSpec(moduleId.getOrganisation()));
        } else {
            excludeSpecs.add(new ModuleIdSpec(moduleId));
        }
    }
}
 
Example #13
Source File: AbstractModuleDescriptorBackedMetaData.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void populateExcludeRulesFromDescriptor() {
    excludeRules = new LinkedHashSet<ExcludeRule>();
    for (ExcludeRule excludeRule : moduleDescriptor.getAllExcludeRules()) {
        for (String config : excludeRule.getConfigurations()) {
            if (hierarchy.contains(config)) {
                excludeRules.add(excludeRule);
                break;
            }
        }
    }
}
 
Example #14
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testParentDependencyMgt() throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                        .parseDescriptor(settings,
                            getClass().getResource("test-dependencyMgt.pom"), false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });

    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-parentDependencyMgt.pom"), false);
    assertNotNull(md);
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-parentdep", "1.0"),
        md.getModuleRevisionId());

    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(2, dds.length);
    assertEquals(
        ModuleRevisionId.newInstance("commons-collection", "commons-collection", "1.0.5"),
        dds[0].getDependencyRevisionId());
    assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"),
        dds[1].getDependencyRevisionId());

    ExcludeRule[] excludes = dds[0].getAllExcludeRules();
    assertNotNull(excludes);
    assertEquals(2, excludes.length);
    assertEquals("javax.mail", excludes[0].getId().getModuleId().getOrganisation());
    assertEquals("mail", excludes[0].getId().getModuleId().getName());
    assertEquals("javax.jms", excludes[1].getId().getModuleId().getOrganisation());
    assertEquals("jms", excludes[1].getId().getModuleId().getName());
}
 
Example #15
Source File: ModuleVersionSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a spec that accepts only those module versions that do not match any of the
 */
public static ModuleVersionSpec forExcludes(Collection<ExcludeRule> excludeRules) {
    if (excludeRules.isEmpty()) {
        return ALL_SPEC;
    }
    return new ExcludeRuleBackedSpec(excludeRules);
}
 
Example #16
Source File: ModuleVersionSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a spec that accepts only those module versions that do not match any of the
 */
public static ModuleVersionSpec forExcludes(Collection<ExcludeRule> excludeRules) {
    if (excludeRules.isEmpty()) {
        return ALL_SPEC;
    }
    return new ExcludeRuleBackedSpec(excludeRules);
}
 
Example #17
Source File: ModuleVersionSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a spec that accepts only those module versions that do not match any of the
 */
public static ModuleVersionSpec forExcludes(Collection<ExcludeRule> excludeRules) {
    if (excludeRules.isEmpty()) {
        return ALL_SPEC;
    }
    return new ExcludeRuleBackedSpec(excludeRules);
}
 
Example #18
Source File: AbstractModuleDescriptorBackedMetaData.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void populateExcludeRulesFromDescriptor() {
    excludeRules = new LinkedHashSet<ExcludeRule>();
    for (ExcludeRule excludeRule : moduleDescriptor.getAllExcludeRules()) {
        for (String config : excludeRule.getConfigurations()) {
            if (hierarchy.contains(config)) {
                excludeRules.add(excludeRule);
                break;
            }
        }
    }
}
 
Example #19
Source File: ModuleVersionSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a spec that accepts only those module versions that do not match any of the
 */
public static ModuleVersionSpec forExcludes(Collection<ExcludeRule> excludeRules) {
    if (excludeRules.isEmpty()) {
        return ALL_SPEC;
    }
    return new ExcludeRuleBackedSpec(excludeRules);
}
 
Example #20
Source File: PomModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private static void printDependency(PrintWriter out, int indent, String groupId,
        String artifactId, String version, String type, String classifier, String scope,
        boolean isOptional, boolean isTransitive, ExcludeRule[] excludes) {
    indent(out, indent * 2);
    out.println("<dependency>");
    indent(out, indent * 3);
    out.println("<groupId>" + groupId + "</groupId>");
    indent(out, indent * 3);
    out.println("<artifactId>" + artifactId + "</artifactId>");
    indent(out, indent * 3);
    out.println("<version>" + version + "</version>");
    if (type != null && !"jar".equals(type)) {
        indent(out, indent * 3);
        out.println("<type>" + type + "</type>");
    }
    if (classifier != null) {
        indent(out, indent * 3);
        out.println("<classifier>" + classifier + "</classifier>");
    }
    if (scope != null) {
        indent(out, indent * 3);
        out.println("<scope>" + scope + "</scope>");
    }
    if (isOptional) {
        indent(out, indent * 3);
        out.println("<optional>true</optional>");
    }
    if (!isTransitive) {
        indent(out, indent * 3);
        out.println("<exclusions>");
        indent(out, indent * 4);
        out.println("<exclusion>");
        indent(out, indent * 5);
        out.println("<groupId>*</groupId>");
        indent(out, indent * 5);
        out.println("<artifactId>*</artifactId>");
        indent(out, indent * 4);
        out.println("</exclusion>");
        indent(out, indent * 3);
        out.println("</exclusions>");
    } else if (excludes != null) {
        printExclusions(excludes, out, indent);
    }
    indent(out, indent * 2);
    out.println("</dependency>");
}
 
Example #21
Source File: ModuleVersionSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleVersionSpec forExcludes(ExcludeRule... excludeRules) {
    return forExcludes(Arrays.asList(excludeRules));
}
 
Example #22
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
@Test
public void testOverrideParentVersionPropertyDependencyMgt()
        throws ParseException, IOException {
    settings.setDictatorResolver(new MockResolver() {
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            try {
                ModuleDescriptor moduleDescriptor = PomModuleDescriptorParser.getInstance()
                        .parseDescriptor(settings,
                            getClass().getResource("test-versionPropertyDependencyMgt.pom"),
                            false);
                return new ResolvedModuleRevision(null, null, moduleDescriptor, null);
            } catch (IOException e) {
                throw new AssertionError(e);
            }
        }
    });

    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-overrideParentVersionPropertyDependencyMgt.pom"), false);
    assertNotNull(md);
    assertEquals(ModuleRevisionId.newInstance("org.apache", "test-parentdep", "1.0"),
        md.getModuleRevisionId());

    DependencyDescriptor[] dds = md.getDependencies();
    assertNotNull(dds);
    assertEquals(2, dds.length);
    assertEquals(
        ModuleRevisionId.newInstance("commons-collections", "commons-collections", "3.2.1"),
        dds[0].getDependencyRevisionId());
    assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.1.1"),
        dds[1].getDependencyRevisionId());

    ExcludeRule[] excludes = dds[0].getAllExcludeRules();
    assertNotNull(excludes);
    assertEquals(2, excludes.length);
    assertEquals("javax.mail", excludes[0].getId().getModuleId().getOrganisation());
    assertEquals("mail", excludes[0].getId().getModuleId().getName());
    assertEquals("javax.jms", excludes[1].getId().getModuleId().getOrganisation());
    assertEquals("jms", excludes[1].getId().getModuleId().getName());
}
 
Example #23
Source File: ModuleVersionSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private ExcludeRuleSpec(ExcludeRule rule) {
    this.rule = rule;
}
 
Example #24
Source File: AbstractModuleDescriptorBackedMetaData.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Set<ExcludeRule> getExcludeRules() {
    if (excludeRules == null) {
        populateExcludeRulesFromDescriptor();
    }
    return excludeRules;
}
 
Example #25
Source File: AbstractWorkspaceResolver.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
protected WorkspaceModuleDescriptor createWorkspaceMd(ModuleDescriptor md) {
    DefaultWorkspaceModuleDescriptor newMd = new DefaultWorkspaceModuleDescriptor(
            md.getModuleRevisionId(), "release", null, true);
    newMd.addConfiguration(new Configuration(ModuleDescriptor.DEFAULT_CONFIGURATION));
    newMd.setLastModified(System.currentTimeMillis());

    newMd.setDescription(md.getDescription());
    newMd.setHomePage(md.getHomePage());
    newMd.setLastModified(md.getLastModified());
    newMd.setPublicationDate(md.getPublicationDate());
    newMd.setResolvedPublicationDate(md.getResolvedPublicationDate());
    newMd.setStatus(md.getStatus());

    Configuration[] allConfs = md.getConfigurations();
    for (Artifact af : createWorkspaceArtifacts(md)) {
        if (allConfs.length == 0) {
            newMd.addArtifact(ModuleDescriptor.DEFAULT_CONFIGURATION, af);
        } else {
            for (Configuration conf : allConfs) {
                newMd.addConfiguration(conf);
                newMd.addArtifact(conf.getName(), af);
            }
        }
    }

    for (DependencyDescriptor dependency : md.getDependencies()) {
        newMd.addDependency(dependency);
    }

    for (ExcludeRule excludeRule : md.getAllExcludeRules()) {
        newMd.addExcludeRule(excludeRule);
    }

    newMd.getExtraInfos().addAll(md.getExtraInfos());

    for (License license : md.getLicenses()) {
        newMd.addLicense(license);
    }

    return newMd;
}
 
Example #26
Source File: XmlModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    try {
        if (state == State.DESCRIPTION) {
            // make sure we don't interpret any tag while in description tag
            getBuffer().append("<").append(qName);
            for (int i = 0; i < attributes.getLength(); i++) {
                getBuffer().append(" ");
                getBuffer().append(attributes.getQName(i));
                getBuffer().append("=\"");
                getBuffer().append(attributes.getValue(i));
                getBuffer().append("\"");
            }
            getBuffer().append(">");
        } else if ("ivy-module".equals(qName)) {
            ivyModuleStarted(attributes);
        } else if ("info".equals(qName)) {
            infoStarted(attributes);
        } else if (state == State.INFO && "extends".equals(qName)) {
            extendsStarted(attributes);
        } else if (state == State.INFO && "license".equals(qName)) {
            getMd().addLicense(
                new License(settings.substitute(attributes.getValue("name")), settings
                        .substitute(attributes.getValue("url"))));
        } else if (state == State.INFO && "description".equals(qName)) {
            getMd().setHomePage(settings.substitute(attributes.getValue("homepage")));
            state = State.DESCRIPTION;
            buffer = new StringBuilder();
        } else if (state == State.INFO && "ivyauthor".equals(qName)) {
            // nothing to do, we don't store this
        } else if (state == State.INFO && "repository".equals(qName)) {
            // nothing to do, we don't store this
        } else if (state == State.EXTRA_INFO || state == State.INFO
                && isOtherNamespace(qName)) {
            buffer = new StringBuilder();
            state = State.EXTRA_INFO;
            ExtraInfoHolder extraInfo = new ExtraInfoHolder();
            extraInfo.setName(qName);
            for (int i = 0; i < attributes.getLength(); i++) {
                extraInfo.getAttributes().put(attributes.getQName(i),
                    attributes.getValue(i));
            }
            extraInfoStack.push(extraInfo);
        } else if ("configurations".equals(qName)) {
            configurationStarted(attributes);
        } else if ("publications".equals(qName)) {
            publicationsStarted(attributes);
        } else if ("dependencies".equals(qName)) {
            dependenciesStarted(attributes);
        } else if ("conflicts".equals(qName)) {
            if (!descriptorVersion.startsWith("1.")) {
                Message.deprecated("using conflicts section is deprecated: "
                        + "please use hints section instead. Ivy file URL: "
                        + descriptorURL);
            }
            state = State.CONFLICT;
            checkConfigurations();
        } else if ("artifact".equals(qName)) {
            artifactStarted(qName, attributes);
        } else if ("include".equals(qName) && state == State.DEP) {
            addIncludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEP) {
            addExcludeRule(qName, attributes);
        } else if ("exclude".equals(qName) && state == State.DEPS) {
            state = State.EXCLUDE;
            parseRule(qName, attributes);
            getMd().addExcludeRule((ExcludeRule) confAware);
        } else if ("dependency".equals(qName)) {
            dependencyStarted(attributes);
        } else if ("conf".equals(qName)) {
            confStarted(attributes);
        } else if ("mapped".equals(qName)) {
            dd.addDependencyConfiguration(conf,
                settings.substitute(attributes.getValue("name")));
        } else if ("conflict".equals(qName) && state == State.DEPS
                || "manager".equals(qName) && state == State.CONFLICT) {
            managerStarted(attributes, state == State.CONFLICT ? "name" : "manager");
        } else if ("override".equals(qName) && state == State.DEPS) {
            mediationOverrideStarted(attributes);
        } else if ("include".equals(qName) && state == State.CONF) {
            includeConfStarted(attributes);
        } else if (validate && state != State.EXTRA_INFO && state != State.DESCRIPTION) {
            addError("unknown tag " + qName);
        }
    } catch (Exception ex) {
        if (ex instanceof SAXException) {
            throw (SAXException) ex;
        }
        throw new SAXException("Problem occurred while parsing ivy file: "
                + ex.getMessage(), ex);
    }
}
 
Example #27
Source File: XmlModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
protected static void printDependency(ModuleDescriptor md, DependencyDescriptor dep,
        PrintWriter out) {
    final ModuleRevisionId dependencyRevisionId = dep.getDependencyRevisionId();
    out.print(String.format("<dependency org=\"%s\" name=\"%s\"",
            XMLHelper.escape(dependencyRevisionId.getOrganisation()),
            XMLHelper.escape(dependencyRevisionId.getName())));
    if (dependencyRevisionId.getBranch() != null) {
        out.print(" branch=\"" + XMLHelper.escape(dependencyRevisionId.getBranch()) + "\"");
    }
    out.print(" rev=\"" + XMLHelper.escape(dependencyRevisionId.getRevision()) + "\"");
    final ModuleRevisionId dynamicConstraintDependencyRevisionId =
            dep.getDynamicConstraintDependencyRevisionId();
    if (!dynamicConstraintDependencyRevisionId.equals(dependencyRevisionId)) {
        if (dynamicConstraintDependencyRevisionId.getBranch() != null) {
            out.print(" branchConstraint=\""
                    + XMLHelper.escape(dynamicConstraintDependencyRevisionId.getBranch())
                    + "\"");
        }
        out.print(" revConstraint=\""
                + XMLHelper.escape(dynamicConstraintDependencyRevisionId.getRevision())
                + "\"");
    }
    if (dep.isForce()) {
        out.print(" force=\"" + dep.isForce() + "\"");
    }
    if (dep.isChanging()) {
        out.print(" changing=\"" + dep.isChanging() + "\"");
    }
    if (!dep.isTransitive()) {
        out.print(" transitive=\"" + dep.isTransitive() + "\"");
    }
    StringBuilder sb = new StringBuilder();
    for (String modConf : dep.getModuleConfigurations()) {
        if (sb.length() > 0) {
            sb.append(";");
        }
        sb.append(XMLHelper.escape(modConf)).append(
                listToPrefixedString(dep.getDependencyConfigurations(modConf), "->"));
    }
    out.print(" conf=\"" + sb + "\"");

    printExtraAttributes(dep, out, " ");

    DependencyArtifactDescriptor[] depArtifacts = dep.getAllDependencyArtifacts();
    if (depArtifacts.length > 0) {
        out.println(">");
    }
    printDependencyArtefacts(md, out, depArtifacts);

    IncludeRule[] includes = dep.getAllIncludeRules();
    if (includes.length > 0 && depArtifacts.length == 0) {
        out.println(">");
    }
    printDependencyIncludeRules(md, out, includes);

    ExcludeRule[] excludes = dep.getAllExcludeRules();
    if (excludes.length > 0 && includes.length == 0 && depArtifacts.length == 0) {
        out.println(">");
    }
    printDependencyExcludeRules(md, out, excludes);
    if (includes.length + excludes.length + depArtifacts.length == 0) {
        out.println("/>");
    } else {
        out.println("\t\t</dependency>");
    }
}
 
Example #28
Source File: ModuleVersionSpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleVersionSpec forExcludes(ExcludeRule... excludeRules) {
    return forExcludes(Arrays.asList(excludeRules));
}
 
Example #29
Source File: ModuleVersionSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ModuleVersionSpec forExcludes(ExcludeRule... excludeRules) {
    return forExcludes(Arrays.asList(excludeRules));
}
 
Example #30
Source File: ModuleVersionSpec.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private ExcludeRuleSpec(ExcludeRule rule) {
    this.rule = rule;
}