org.apache.ivy.core.settings.IvySettings Java Examples

The following examples show how to use org.apache.ivy.core.settings.IvySettings. 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: XmlModuleDescriptorWriterTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testExtraInfosFromMaven() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(),
        PomModuleDescriptorParserTest.class
                .getResource("test-versionPropertyDependencyMgt.pom"), false);
    XmlModuleDescriptorWriter.write(md, LICENSE, dest);

    assertTrue(dest.exists());
    String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)))
            .replaceAll("\r\n", "\n").replace('\r', '\n');
    wrote = wrote.replaceFirst("publication=\"([0-9])*\"", "publication=\"20140429153143\"");
    System.out.println(wrote);

    String expected = readEntirely("test-write-extrainfo-from-maven.xml").replaceAll("\r\n",
        "\n").replace('\r', '\n');
    assertXMLEqual(expected, wrote);
}
 
Example #2
Source File: IvyConfigureTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefault() {
    // by default settings look in the current directory for an ivysettings.xml file...
    // but Ivy itself has one, and we don't want to use it
    configure.getProject().setProperty("ivy.settings.file", "no/settings/will/use/default.xml");
    configure.execute();

    IvySettings settings = getIvyInstance().getSettings();
    assertNotNull(settings.getDefaultResolver());

    DependencyResolver publicResolver = settings.getResolver("public");
    assertNotNull(publicResolver);
    assertTrue(publicResolver instanceof IBiblioResolver);
    IBiblioResolver ibiblio = (IBiblioResolver) publicResolver;
    assertTrue(ibiblio.isM2compatible());
}
 
Example #3
Source File: IvyDeliverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testReplaceBranchInfo() throws Exception {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();

    deliver.setPubrevision("1.2");
    deliver.setPubbranch("BRANCH1");
    deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
    deliver.execute();

    // should have done the ivy delivering
    File deliveredIvyFile = new File("build/test/deliver/ivy-1.2.xml");
    assertTrue(deliveredIvyFile.exists());
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(), deliveredIvyFile.toURI().toURL(), true);
    assertEquals(ModuleRevisionId.newInstance("apache", "resolve-latest", "BRANCH1", "1.2"),
        md.getModuleRevisionId());
}
 
Example #4
Source File: IvyConfigureTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testFile() throws Exception {
    configure.setFile(new File("test/repositories/ivysettings.xml"));

    configure.execute();

    Ivy ivy = getIvyInstance();
    assertNotNull(ivy);
    IvySettings settings = ivy.getSettings();
    assertNotNull(settings);

    assertEquals(new File("build/cache").getAbsoluteFile(), settings.getDefaultCache());
    assertEquals(new File("test/repositories/ivysettings.xml").getAbsolutePath(), settings
            .getVariables().getVariable("ivy.settings.file"));
    assertEquals(
        new File("test/repositories/ivysettings.xml").toURI().toURL().toExternalForm(),
        settings.getVariables().getVariable("ivy.settings.url"));
    assertEquals(new File("test/repositories").getAbsolutePath(), settings.getVariables()
            .getVariable("ivy.settings.dir"));
    assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}
 
Example #5
Source File: XmlModuleUpdaterTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateWithComments() throws Exception {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/"
            + "test-with-comments.xml").toURI().toURL();
    XmlModuleDescriptorUpdater.update(settingsUrl, new BufferedOutputStream(buffer, 1024),
        getUpdateOptions("release", "mynewrev"));

    XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
    ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
        new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
                false), true);

    DependencyDescriptor[] dependencies = updatedMd.getDependencies();
    assertNotNull(dependencies);
    assertEquals(3, dependencies.length);
}
 
Example #6
Source File: DefaultRepositoryCacheManagerTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    File f = File.createTempFile("ivycache", ".dir");
    ivy = new Ivy();
    ivy.configureDefault();
    ivy.getLoggerEngine().setDefaultLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
    IvyContext.pushNewContext().setIvy(ivy);

    IvySettings settings = ivy.getSettings();
    f.delete(); // we want to use the file as a directory, so we delete the file itself
    cacheManager = new DefaultRepositoryCacheManager();
    cacheManager.setSettings(settings);
    cacheManager.setBasedir(f);

    artifact = createArtifact("org", "module", "rev", "name", "type", "ext");

    Artifact originArtifact = createArtifact("org", "module", "rev", "name", "pom.original",
        "pom");
    origin = new ArtifactOrigin(originArtifact, true, "file:/some/where.pom");

    cacheManager.saveArtifactOrigin(originArtifact, origin);
    cacheManager.saveArtifactOrigin(artifact, origin);
}
 
Example #7
Source File: MirroredURLResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    data = new ResolveData(engine, new ResolveOptions());
    TestHelper.createCache();
    settings.setDefaultCache(TestHelper.cache);
    settings.setVariable("test.mirroredurl.mirrorlist-solo.url",
        this.getClass().getResource("mirrorlist-solo.txt").toExternalForm());
    settings.setVariable("test.mirroredurl.mirrorlist-failover.url", this.getClass()
            .getResource("mirrorlist-failover.txt").toExternalForm());
    settings.setVariable("test.mirroredurl.mirrorlist-fail.url",
        this.getClass().getResource("mirrorlist-fail.txt").toExternalForm());
    new XmlSettingsParser(settings).parse(MirroredURLResolverTest.class
            .getResource("mirror-resolver-settings.xml"));
}
 
Example #8
Source File: FixDepsTaskTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testFixedResolve() throws Exception {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-transitive.xml");

    File dest = new File("build/testFixDeps/testTransitivity.xml");
    fixDeps.setToFile(dest);
    fixDeps.execute();

    project.setProperty("ivy.dep.file", dest.getAbsolutePath());
    File dest2 = new File("build/testFixDeps/testTransitivity2.xml");
    fixDeps.setToFile(dest2);
    fixDeps.execute();

    ModuleDescriptor md1 = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(), dest.toURI().toURL(), true);
    ModuleDescriptor md2 = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(), dest2.toURI().toURL(), true);
    assertEquals(md1, md2);
    assertEquals(Arrays.asList(md1.getConfigurations()), Arrays.asList(md2.getConfigurations()));
    assertEquals(toString(Arrays.asList(md1.getDependencies())),
        toString(Arrays.asList(md2.getDependencies())));
}
 
Example #9
Source File: XmlModuleUpdaterTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateWithExcludeConfigurations1() throws Exception {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/"
            + "test-update-excludedconfs1.xml").toURI().toURL();
    XmlModuleDescriptorUpdater.update(settingsUrl, buffer,
        getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] {"myconf2"}));

    XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
    ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
        new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
                false), true);

    // test the number of configurations
    Configuration[] configs = updatedMd.getConfigurations();
    assertNotNull("Configurations shouldn't be null", configs);
    assertEquals("Number of configurations incorrect", 3, configs.length);

    // test that the correct configuration has been removed
    assertNull("myconf2 hasn't been removed", updatedMd.getConfiguration("myconf2"));

    // test that the other configurations aren't removed
    assertNotNull("myconf1 has been removed", updatedMd.getConfiguration("myconf1"));
    assertNotNull("myconf3 has been removed", updatedMd.getConfiguration("myconf3"));
    assertNotNull("myconf4 has been removed", updatedMd.getConfiguration("myconf4"));
}
 
Example #10
Source File: XmlModuleUpdaterTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateWithExcludeConfigurations4() throws Exception {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/"
            + "test-update-excludedconfs4.xml").toURI().toURL();
    XmlModuleDescriptorUpdater.update(settingsUrl, buffer,
        getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] {"myconf2"}));

    XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
    ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
        new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
                false), true);

    // test the number of configurations
    Artifact[] artifacts = updatedMd.getAllArtifacts();
    assertNotNull("Published artifacts shouldn't be null", artifacts);
    assertEquals("Number of published artifacts incorrect", 4, artifacts.length);

    // test that the correct configuration has been removed
    for (Artifact current : artifacts) {
        List<String> currentConfs = Arrays.asList(current.getConfigurations());
        assertTrue("myconf2 hasn't been removed for artifact " + current.getName(),
            !currentConfs.contains("myconf2"));
    }
}
 
Example #11
Source File: SettingsParser.java    From restcommander with Apache License 2.0 6 votes vote down vote up
/**
 * Look for an "include" property containing a list of yaml descriptors and load their repositories.
 */
private void parseIncludes(IvySettings settings, Map data) throws Oops {
    if (data.containsKey("include") && data.get("include") != null) {
        if (data.get("include") instanceof List) {
            List<?> includes = (List)data.get("include");
            if (includes != null) {
                for (Object inc : includes) {
                    File include = new File(substitute(inc.toString()));
                    new SettingsParser(logger).parse(settings, include); // Load found descriptors
                }
            }
        } else {
            throw new Oops("\"include\" property must be a list");
        }
    }
}
 
Example #12
Source File: LibVersionsCheckTask.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void setupIvy() {
  IvySettings ivySettings = new IvySettings();
  try {
    ivySettings.setVariable("common.build.dir", commonBuildDir.getAbsolutePath());
    ivySettings.setVariable("ivy.exclude.types", "source|javadoc");
    ivySettings.setVariable("ivy.resolution-cache.dir", ivyResolutionCacheDir.getAbsolutePath());
    ivySettings.setVariable("ivy.lock-strategy", ivyLockStrategy);
    ivySettings.setVariable("ivysettings.xml", getProject().getProperty("ivysettings.xml")); // nested settings file
    ivySettings.setBaseDir(commonBuildDir);
    ivySettings.setDefaultConflictManager(new NoConflictManager());
    ivy = Ivy.newInstance(ivySettings);
    ivy.configure(topLevelIvySettingsFile);
  } catch (Exception e) {
    throw new BuildException("Exception reading " + topLevelIvySettingsFile.getPath() + ": " + e.toString(), e);
  }
}
 
Example #13
Source File: IvyPublishTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoDeliver() throws IOException, ParseException {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();

    publish.setPubrevision("1.3");
    publish.setResolver("1");
    publish.setSrcivypattern("build/test/publish/ivy-1.3.xml");

    FileUtil.copy(new File("test/java/org/apache/ivy/ant/ivy-publish.xml"), new File(
            "build/test/publish/ivy-1.3.xml"), null);

    File art = new File("build/test/publish/resolve-latest-1.3.jar");
    FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), art, null);
    publish.execute();

    // should have published the files with "1" resolver
    assertTrue(new File("test/repositories/1/apache/resolve-latest/ivys/ivy-1.3.xml").exists());
    assertTrue(new File("test/repositories/1/apache/resolve-latest/jars/resolve-latest-1.3.jar")
            .exists());

    // the published ivy version should be ok (ok in ivy-publish file)
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(),
        new File("test/repositories/1/apache/resolve-latest/ivys/ivy-1.3.xml").toURI().toURL(),
        false);
    assertEquals("1.3", md.getModuleRevisionId().getRevision());

    // should not have done delivery (replace dynamic revisions with static ones)
    assertEquals("latest.integration", md.getDependencies()[0].getDependencyRevisionId()
            .getRevision());
}
 
Example #14
Source File: PomModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private IvySettings createIvySettingsForParentLicenseTesting(final String parentPomFileName, final String parentOrgName,
                                                             final String parentModuleName) throws Exception {
    final URL parentPomURL = this.getClass().getResource(parentPomFileName);
    assertNotNull("Could not find " + parentPomFileName, parentPomURL);
    final PomReader parentPomReader = new PomReader(parentPomURL, new URLResource(parentPomURL));
    final License[] parentLicenses = parentPomReader.getLicenses();
    assertNotNull("Missing licenses in parent pom " + parentPomFileName, parentLicenses);
    assertEquals("Unexpected number of licenses in parent pom " + parentPomFileName, 1, parentLicenses.length);
    final DependencyResolver dependencyResolver = new MockedDependencyResolver() {
        @Override
        protected ModuleDescriptor getModuleDescriptor(DependencyDescriptor dependencyDescriptor) {
            final String depOrg = dependencyDescriptor.getDependencyId().getOrganisation();
            final String depModuleName = dependencyDescriptor.getDependencyId().getName();
            if (depOrg.equals(parentOrgName) && depModuleName.equals(parentModuleName)) {
                final DefaultModuleDescriptor moduleDescriptor = DefaultModuleDescriptor.newDefaultInstance(dependencyDescriptor.getDependencyRevisionId());
                for (final License license : parentLicenses) {
                    moduleDescriptor.addLicense(license);
                }
                return moduleDescriptor;
            } else {
                return super.getModuleDescriptor(dependencyDescriptor);
            }
        }
    };
    final IvySettings ivySettings = new IvySettings();
    ivySettings.setDictatorResolver(dependencyResolver);

    return ivySettings;
}
 
Example #15
Source File: FixDepsTaskTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimple() throws Exception {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");

    File dest = new File("build/testFixDeps/testSimple.xml");
    fixDeps.setToFile(dest);
    fixDeps.execute();

    assertTrue(dest.exists());
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(), dest.toURI().toURL(), true);
    assertEquals("apache", md.getModuleRevisionId().getOrganisation());
    assertEquals("resolve-simple", md.getModuleRevisionId().getName());
    assertEquals("1.0", md.getModuleRevisionId().getRevision());
    assertEquals("release", md.getStatus());

    assertEquals(1, md.getConfigurations().length);
    assertEquals("default", md.getConfigurations()[0].getName());
    assertEquals(0, md.getConfigurations()[0].getExtends().length);

    assertEquals(1, md.getDependencies().length);
    assertEquals("org1", md.getDependencies()[0].getDependencyId().getOrganisation());
    assertEquals("mod1.2", md.getDependencies()[0].getDependencyId().getName());
    assertFalse(md.getDependencies()[0].isChanging());
    assertTrue(md.getDependencies()[0].isForce());
    assertFalse(md.getDependencies()[0].isTransitive());
    assertEquals("2.0", md.getDependencies()[0].getDependencyRevisionId().getRevision());
}
 
Example #16
Source File: LatestCompatibleConflictManager.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void blackListIncompatibleCallerAndRestartResolveIfPossible(IvySettings settings,
        IvyNode parent, IvyNode selected, IvyNode evicted) {
    Stack<IvyNode> callerStack = new Stack<>();
    callerStack.push(evicted);
    Collection<IvyNodeBlacklist> toBlacklist = blackListIncompatibleCaller(
        settings.getVersionMatcher(), parent, selected, evicted, callerStack);
    if (toBlacklist != null) {
        final StringBuilder blacklisted = new StringBuilder();
        for (IvyNodeBlacklist blacklist : toBlacklist) {
            if (blacklisted.length() > 0) {
                blacklisted.append(" ");
            }
            IvyNode blacklistedNode = blacklist.getBlacklistedNode();
            blacklistedNode.blacklist(blacklist);
            blacklisted.append(blacklistedNode);
        }

        String rootModuleConf = parent.getData().getReport().getConfiguration();
        evicted.markEvicted(new EvictionData(rootModuleConf, parent, this, Collections
                .singleton(selected), "with blacklisting of " + blacklisted));

        if (settings.debugConflictResolution()) {
            Message.debug("evicting " + evicted + " by "
                    + evicted.getEvictedData(rootModuleConf));
        }
        throw new RestartResolveProcess("trying to handle incompatibilities between "
                + selected + " and " + evicted);
    }
}
 
Example #17
Source File: XmlModuleDescriptorWriterTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testExtends() throws Exception {
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(),
        XmlModuleDescriptorWriterTest.class.getResource("test-extends-all.xml"), false);
    XmlModuleDescriptorWriter.write(md, LICENSE, dest);

    assertTrue(dest.exists());
    String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest))).replaceAll(
        "\r\n?", "\n");
    String expected = readEntirely("test-write-extends.xml").replaceAll("\r\n?", "\n");
    assertEquals(expected, wrote);
}
 
Example #18
Source File: DualResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);
}
 
Example #19
Source File: IvyPublishTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testForceDeliver() throws IOException, ParseException {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();

    publish.setPubrevision("1.3");
    publish.setResolver("1");
    publish.setSrcivypattern("build/test/publish/ivy-1.3.xml");
    publish.setForcedeliver(true);

    FileUtil.copy(new File("test/java/org/apache/ivy/ant/ivy-latest.xml"), new File(
            "build/test/publish/ivy-1.3.xml"), null);

    File art = new File("build/test/publish/resolve-latest-1.3.jar");
    FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), art, null);
    publish.execute();

    // should have published the files with "1" resolver
    assertTrue(new File("test/repositories/1/apache/resolve-latest/ivys/ivy-1.3.xml").exists());
    assertTrue(new File("test/repositories/1/apache/resolve-latest/jars/resolve-latest-1.3.jar")
            .exists());

    // should have updated published ivy version
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(),
        new File("test/repositories/1/apache/resolve-latest/ivys/ivy-1.3.xml").toURI().toURL(),
        false);
    assertEquals("1.3", md.getModuleRevisionId().getRevision());
}
 
Example #20
Source File: IvyDeliverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testReplaceBranch() throws Exception {
    IvyConfigure settings = new IvyConfigure();
    settings.setProject(project);
    settings.execute();
    // change the default branch to use
    IvyAntSettings.getDefaultInstance(settings).getConfiguredIvyInstance(settings)
            .getSettings().setDefaultBranch("BRANCH1");

    // resolve a module dependencies
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();

    // deliver this module
    deliver.setPubrevision("1.2");
    deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml");
    deliver.execute();

    // should have done the ivy delivering, including setting the branch according to the
    // configured default
    File deliveredIvyFile = new File("build/test/deliver/ivy-1.2.xml");
    assertTrue(deliveredIvyFile.exists());
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(), deliveredIvyFile.toURI().toURL(), true);
    assertEquals(ModuleRevisionId.newInstance("apache", "resolve-latest", "1.2"),
        md.getModuleRevisionId());
    DependencyDescriptor[] dds = md.getDependencies();
    assertEquals(1, dds.length);
    assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "BRANCH1", "2.2"),
        dds[0].getDependencyRevisionId());
    assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "latest.integration"),
        dds[0].getDynamicConstraintDependencyRevisionId());
}
 
Example #21
Source File: PomModuleDescriptorWriterTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testDependenciesWithClassifier() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(), getClass().getResource("test-dependencies-with-classifier.pom"),
        false);
    PomModuleDescriptorWriter.write(md, dest, getWriterOptions());
    assertTrue(dest.exists());

    String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)))
            .replaceAll("\r\n", "\n").replace('\r', '\n');
    String expected = readEntirely("test-write-dependencies-with-classifier.xml").replaceAll(
        "\r\n", "\n").replace('\r', '\n');
    assertEquals(expected, wrote);
}
 
Example #22
Source File: ChainVersionMatcher.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the settings this matcher will use, and set to the matcher in the chain which implements
 * {@link IvySettingsAware}.
 *
 * @param settings
 *            the settings to use in the whole chain. Must not be null.
 */
public void setSettings(IvySettings settings) {
    super.setSettings(settings);
    for (VersionMatcher matcher : matchers) {
        if (matcher instanceof IvySettingsAware) {
            ((IvySettingsAware) matcher).setSettings(settings);
        }
    }
}
 
Example #23
Source File: IvyConfigureTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that if the Ivy settings file <code>include</code>s another file as
 * <code>optional</code>, then the absence of that file doesn't lead to failures
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testOptionalFileInclude() throws Exception {
    final File ivySettingsXml = new File("test/repositories/ivysettings-optional-file-include.xml");
    final Ivy ivy = new Ivy();
    ivy.configure(ivySettingsXml);
    final IvySettings ivySettings = ivy.getSettings();
    // just test that it indeed parsed fine
    assertTrue("Unexpected number of resolvers in Ivy settings", ivySettings.getResolvers().isEmpty());
    final List<Status> statuses = ivySettings.getStatusManager().getStatuses();
    assertEquals("Unexpected number of custom status in parsed Ivy settings", 1, statuses.size());
    assertEquals("Custom status not found in the parsed Ivy settings", "ivy-1555", statuses.get(0).getName());
}
 
Example #24
Source File: IvyPublishTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoDeliverWithBranch() throws IOException, ParseException {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();

    publish.setUpdate(true);
    publish.setPubrevision("1.3");
    publish.setPubbranch("BRANCH1");
    publish.setResolver("1");
    publish.setSrcivypattern("build/test/publish/ivy-1.3.xml");

    FileUtil.copy(new File("test/java/org/apache/ivy/ant/ivy-publish.xml"), new File(
            "build/test/publish/ivy-1.3.xml"), null);

    File art = new File("build/test/publish/resolve-latest-1.3.jar");
    FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), art, null);
    publish.execute();

    // should have published the files with "1" resolver
    assertTrue(new File("test/repositories/1/apache/resolve-latest/ivys/ivy-1.3.xml").exists());
    assertTrue(new File("test/repositories/1/apache/resolve-latest/jars/resolve-latest-1.3.jar")
            .exists());

    // the published ivy version should be ok (ok in ivy-publish file)
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(),
        new File("test/repositories/1/apache/resolve-latest/ivys/ivy-1.3.xml").toURI().toURL(),
        false);
    assertEquals("BRANCH1", md.getModuleRevisionId().getBranch());
    assertEquals("1.3", md.getModuleRevisionId().getRevision());

    // should not have done delivery (replace dynamic revisions with static ones)
    assertEquals("latest.integration", md.getDependencies()[0].getDependencyRevisionId()
            .getRevision());
}
 
Example #25
Source File: IvyInternalDepResolver.java    From jeka with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an <code>IvySettings</code> to the specified repositories.
 */
private static IvySettings ivySettingsOf(JkRepoSet resolveRepos) {
    final IvySettings ivySettings = new IvySettings();
    IvyTranslations.populateIvySettingsWithRepo(ivySettings, resolveRepos);
    ivySettings.setDefaultCache(JkLocator.getJekaRepositoryCache().toFile());
    return ivySettings;
}
 
Example #26
Source File: IvyTask.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected String getProperty(String value, IvySettings ivy, String name) {
    if (value == null) {
        return getProperty(ivy, name);
    }
    value = ivy.substitute(value);
    Message.debug("parameter found as attribute value: " + name + "=" + value);
    return value;
}
 
Example #27
Source File: IBiblioResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    data = new ResolveData(engine, new ResolveOptions());
    TestHelper.createCache();
    settings.setDefaultCache(TestHelper.cache);
}
 
Example #28
Source File: IvyOverride.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
void addOverride(DefaultModuleDescriptor md, IvySettings settings) {
    String matcherName = (matcher == null) ? PatternMatcher.EXACT : matcher;
    String orgPattern = (org == null) ? PatternMatcher.ANY_EXPRESSION : org;
    String modulePattern = (module == null) ? PatternMatcher.ANY_EXPRESSION : module;
    md.addDependencyDescriptorMediator(new ModuleId(orgPattern, modulePattern),
        settings.getMatcher(matcherName), new OverrideDependencyDescriptorMediator(branch, rev));
}
 
Example #29
Source File: IvyPublishTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testPublishNotAllConfigs() throws IOException, ParseException {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();

    publish.setPubrevision("1.2");
    publish.setResolver("1");
    publish.setConf("compile");
    publish.setUpdate(true);
    File art = new File("build/test/publish/resolve-simple-1.2.jar");
    FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), art, null);
    publish.execute();

    // should have do the ivy delivering
    assertTrue(new File("build/test/publish/ivy-1.2.xml").exists());

    // should have published the files with "1" resolver
    assertTrue(new File("test/repositories/1/apache/resolve-simple/ivys/ivy-1.2.xml").exists());
    assertTrue(new File("test/repositories/1/apache/resolve-simple/jars/resolve-simple-1.2.jar")
            .exists());

    // should have updated published ivy version
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(),
        new File("test/repositories/1/apache/resolve-simple/ivys/ivy-1.2.xml").toURI().toURL(),
        false);
    assertEquals("1.2", md.getModuleRevisionId().getRevision());

    // should only contain the default configuration
    String[] configs = md.getConfigurationsNames();
    assertEquals("Number of configurations not correct", 1, configs.length);
    assertEquals("Compile configuration not present", "compile", configs[0]);
}
 
Example #30
Source File: XmlModuleDescriptorWriterTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testDependencies() throws Exception {
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(),
        XmlModuleDescriptorWriterTest.class.getResource("test-dependencies.xml"), true);
    XmlModuleDescriptorWriter.write(md, LICENSE, dest);

    assertTrue(dest.exists());
    String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)))
            .replaceAll("\r\n", "\n").replace('\r', '\n');
    String expected = readEntirely("test-write-dependencies.xml").replaceAll("\r\n", "\n")
            .replace('\r', '\n');
    assertEquals(expected, wrote);
}