Java Code Examples for org.apache.ivy.util.Message#setDefaultLogger()

The following examples show how to use org.apache.ivy.util.Message#setDefaultLogger() . 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: IvyPublishTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    cleanTestDir();
    cleanRep();
    createCache();
    project = TestHelper.newProject();
    project.init();
    project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
    project.setProperty("build", "build/test/publish");

    publish = new IvyPublish();
    publish.setProject(project);
    System.setProperty("ivy.cache.dir", cache.getAbsolutePath());

    Message.setDefaultLogger(new DefaultMessageLogger(10));
}
 
Example 2
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveSameFileConflict() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.4/ivys/ivy-1.0.1.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[artifact]-[revision].[ext]";
    MockMessageLogger mockLogger = new MockMessageLogger();
    Message.setDefaultLogger(mockLogger);
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.2", "mod1.2",
        "jar", "jar", "default")).exists());
    mockLogger.assertLogDoesntContain("conflict on");
}
 
Example 3
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test(expected = RuntimeException.class)
public void testRetrieveDifferentArtifactsOfSameModuleToSameFile() throws Exception {
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org2/mod2.2/ivys/ivy-0.5.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[module].[ext]";
    MockMessageLogger mockLogger = new MockMessageLogger();
    Message.setDefaultLogger(mockLogger);
    try {
        ivy.retrieve(md.getModuleRevisionId(),
            getRetrieveOptions().setDestArtifactPattern(pattern));
    } finally {
        mockLogger.assertLogDoesntContain("multiple artifacts");
    }
}
 
Example 4
Source File: PackagerResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    Message.setDefaultLogger(new DefaultMessageLogger(99));

    settings = new IvySettings();
    ResolveEngine 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);

    // Create work space with build and resource cache directories
    workdir = new File("build/test/PackagerResolverTest");
    builddir = new File(workdir, "build");
    cachedir = new File(workdir, "resources");
    cleanupTempDirs();
    if (!builddir.mkdirs() || !cachedir.mkdirs()) {
        throw new Exception("can't create directories under " + workdir);
    }
}
 
Example 5
Source File: DefaultIvyContextManager.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Ivy getIvy() {
    lock.lock();
    try {
        if (!cached.isEmpty()) {
            return cached.removeFirst();
        }
        if (!messageAdapterAttached) {
            Message.setDefaultLogger(new IvyLoggingAdaper());
            messageAdapterAttached = true;
        }
    } finally {
        lock.unlock();
    }
    return Ivy.newInstance(new IvySettings());
}
 
Example 6
Source File: DefaultIvyContextManager.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Ivy getIvy() {
    lock.lock();
    try {
        if (!cached.isEmpty()) {
            return cached.removeFirst();
        }
        if (!messageAdapterAttached) {
            Message.setDefaultLogger(new IvyLoggingAdaper());
            messageAdapterAttached = true;
        }
    } finally {
        lock.unlock();
    }
    return Ivy.newInstance(new IvySettings());
}
 
Example 7
Source File: DefaultIvyContextManager.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Ivy getIvy() {
    lock.lock();
    try {
        if (!cached.isEmpty()) {
            return cached.removeFirst();
        }
        if (!messageAdapterAttached) {
            Message.setDefaultLogger(new IvyLoggingAdaper());
            messageAdapterAttached = true;
        }
    } finally {
        lock.unlock();
    }
    return Ivy.newInstance(new IvySettings());
}
 
Example 8
Source File: DefaultIvyContextManager.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Ivy getIvy() {
    lock.lock();
    try {
        if (!cached.isEmpty()) {
            return cached.removeFirst();
        }
        if (!messageAdapterAttached) {
            Message.setDefaultLogger(new IvyLoggingAdaper());
            messageAdapterAttached = true;
        }
    } finally {
        lock.unlock();
    }
    return Ivy.newInstance(new IvySettings());
}
 
Example 9
Source File: OSGiManifestParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_WARN));

    settings = new IvySettings();
    // prevent test from polluting local cache
    settings.setDefaultCache(new File("build/cache"));
}
 
Example 10
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    ivy = Ivy.newInstance();
    ivy.configure(new File("test/repositories/ivysettings.xml"));
    TestHelper.createCache();
    Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_INFO));
}
 
Example 11
Source File: XmlModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_WARN));

    this.settings = new IvySettings();
    // prevent test from polluting local cache
    settings.setDefaultCache(new File("build/cache"));
}
 
Example 12
Source File: LogTriggerTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testMessage() {
    trigger.setMessage("msg: ${organisation} ${module} ${revision}");

    MockMessageLogger mockLogger = new MockMessageLogger();
    Message.setDefaultLogger(mockLogger);
    trigger.progress(ev);

    mockLogger.assertLogInfoContains("msg: o A 1");
}
 
Example 13
Source File: IvyConfigurationProvider.java    From walkmod-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void applyVerbose() {
	if(verbose) {
		Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_INFO));
	} else {
		Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_ERR));
	}
}
 
Example 14
Source File: IvyConfigurationProvider.java    From walkmod-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void applyVerbose() {
	if(verbose) {
		Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_INFO));
	} else {
		Message.setDefaultLogger(new DefaultMessageLogger(Message.MSG_ERR));
	}
}
 
Example 15
Source File: XmlModuleDescriptorParserTest.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
@Test
public void testExtendsAll() throws Exception {
    Message.setDefaultLogger(new DefaultMessageLogger(99));

    // default extends type is 'all' when no extendsType attribute is specified.
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("test-extends-all.xml"), true);
    assertNotNull(md);

    assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
    assertEquals("mymodule", md.getModuleRevisionId().getName());
    assertEquals("myrev", md.getModuleRevisionId().getRevision());
    assertEquals("integration", md.getStatus());

    // verify that the parent description was merged.
    assertEquals("Parent module description.", md.getDescription());

    // verify that the parent and child configurations were merged together.
    final Configuration[] expectedConfs = {new Configuration("default"),
            new Configuration("conf1"), new Configuration("conf2")};
    assertNotNull(md.getConfigurations());
    assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));

    // verify parent and child dependencies were merged together.
    DependencyDescriptor[] deps = md.getDependencies();
    assertNotNull(deps);
    assertEquals(2, deps.length);

    assertEquals(Collections.singletonList("default"),
        Arrays.asList(deps[0].getModuleConfigurations()));
    ModuleRevisionId dep = deps[0].getDependencyRevisionId();
    assertEquals("myorg", dep.getModuleId().getOrganisation());
    assertEquals("mymodule1", dep.getModuleId().getName());
    assertEquals("1.0", dep.getRevision());

    assertEquals(Arrays.asList("conf1", "conf2"),
        Arrays.asList(deps[1].getModuleConfigurations()));
    dep = deps[1].getDependencyRevisionId();
    assertEquals("myorg", dep.getModuleId().getOrganisation());
    assertEquals("mymodule2", dep.getModuleId().getName());
    assertEquals("2.0", dep.getRevision());

    // verify only child publications are present
    Artifact[] artifacts = md.getAllArtifacts();
    assertNotNull(artifacts);
    assertEquals(1, artifacts.length);
    assertEquals("mymodule", artifacts[0].getName());
    assertEquals("jar", artifacts[0].getType());
}
 
Example 16
Source File: MavenResolver.java    From IJava with MIT License 3 votes vote down vote up
/**
 * Create an ivy instance with the specified verbosity. The instance is relatively plain.
 *
 * @param verbosity the verbosity level.
 *                  <ol start="0">
 *                  <li>ERROR</li>
 *                  <li>WANRING</li>
 *                  <li>INFO</li>
 *                  <li>VERBOSE</li>
 *                  <li>DEBUG</li>
 *                  </ol>
 *
 * @return the fresh ivy instance.
 */
private Ivy createDefaultIvyInstance(int verbosity) {
    MessageLogger logger = new DefaultMessageLogger(verbosity);

    // Set the default logger since not all things log to the ivy instance.
    Message.setDefaultLogger(logger);
    Ivy ivy = new Ivy();

    ivy.getLoggerEngine().setDefaultLogger(logger);
    ivy.setSettings(new IvySettings());
    ivy.bind();

    return ivy;
}