You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Mario-Leander Reimer (JIRA)" <ji...@apache.org> on 2015/01/19 22:56:34 UTC

[jira] [Comment Edited] (DELTASPIKE-821) check compatibility with gradle

    [ https://issues.apache.org/jira/browse/DELTASPIKE-821?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14283062#comment-14283062 ] 

Mario-Leander Reimer edited comment on DELTASPIKE-821 at 1/19/15 9:56 PM:
--------------------------------------------------------------------------

Hi John,

thanks for this tip. The problem definitely seems to be a classpath issue when running the tests with Gradle. I tried changing the output folder for the resources directory, so that the beans.xml file ends up in the same folder as the .class files. 
{code}
sourceSets {
    test {
        output.resourcesDir = 'build/classes/test'
    }
    main {
        output.resourcesDir = 'build/classes/main'
    }
}
{code}
Good news: this works for OpenWebBeans. Depending on which META-INF/beans.xml you want to use (main or test) changing the resourcesDir for either sourceSet is enough.

Unfortunately, with Weld I still get the following exception:
{code}
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408: Unsatisfied dependencies for type Logger with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private de.qaware.commons.logging.LoggerProducerTest.logger
{code}


was (Author: mario-leander.reimer):
Hi John,

thanks for this tip. The problem definitely seems to be a classpath issue when running the tests with Gradle. I tried the changing the output folder for the resources directory, so that the beans.xml file ends up in the same folder as the .class files. 
{code}
sourceSets {
    test {
        output.resourcesDir = 'build/classes/test'
    }
    main {
        output.resourcesDir = 'build/classes/main'
    }
}
{code}
Good news: this works for OpenWebBeans. Depending on which META-INF/beans.xml you want to use (main or test) changing the resourcesDir for either sourceSet is enough.

Unfortunately, with Weld I still get the following exception:
{code}
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408: Unsatisfied dependencies for type Logger with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private de.qaware.commons.logging.LoggerProducerTest.logger
{code}

> check compatibility with gradle
> -------------------------------
>
>                 Key: DELTASPIKE-821
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-821
>             Project: DeltaSpike
>          Issue Type: Task
>          Components: TestControl
>    Affects Versions: 1.2.1
>            Reporter: Mario-Leander Reimer
>             Fix For: 1.2.2
>
>         Attachments: cdi-logging.zip
>
>
> When using the DeltaSpike Test-Control module I noticed that unit tests that run perfectly fine with Maven won't run with Gradle at all.
> Let's say you have the following producer method to create a SLF4J Logger instance:
> {code:title=LoggerProducer.java}
> public class LoggerProducer {
>     @Produces
>     @Default
>     public Logger createLogger(final InjectionPoint ip) {
>         Class declaringClass = ip.getMember().getDeclaringClass();
>         return org.slf4j.LoggerFactory.getLogger(declaringClass);
>     }
> }
> {code}
> The test for this is also pretty simple:
> {code:title=LoggerProducerTest.java}
> @RunWith(CdiTestRunner.class)
> public class LoggerProducerTest {
>     @Inject 
>     private Logger logger;
>     @Test
>     public void testCreateLogger() throws Exception {
>         assertThat(logger, is(notNullValue()));
>     }
> }
> {code}
> Weld as well as OpenWebBeans throw an exception when the unit test is executed by Gradle, because no suitable beans seem to be found for injection. I have attached a running demo project so you can see for yourself.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)