You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "wujek srujek (JIRA)" <ji...@apache.org> on 2016/03/30 22:16:25 UTC

[jira] [Created] (GROOVY-7803) Java annotation with

wujek srujek created GROOVY-7803:
------------------------------------

             Summary: Java annotation with 
                 Key: GROOVY-7803
                 URL: https://issues.apache.org/jira/browse/GROOVY-7803
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.4.6
            Reporter: wujek srujek
            Priority: Critical


The following annotation definition (defines a meta annotation for Spring Boot integration tests
{code:java}
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@SpringApplicationConfiguration(classes = [Configuration, TestConfiguration])
@WebIntegrationTest(randomPort = true)
@ActiveProfiles('integrationTest')
@TestExecutionListeners(
        listeners = FlywayTestExecutionListener,
        mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
@interface ApplicationTest {

}
{code}
fails compilation with the following error messages:
{noformat}
ApplicationTest.groovy: 33: Annotation @org.springframework.boot.test.SpringApplicationConfiguration is not allowed on element ANNOTATION
 @ line 33, column 1.
   @SpringApplicationConfiguration(classes = [Configuration, TestConfiguration])
   ^

ApplicationTest.groovy: 34: Annotation @org.springframework.boot.test.WebIntegrationTest is not allowed on element ANNOTATION
 @ line 34, column 1.
   @WebIntegrationTest(randomPort = true)
   ^

ApplicationTest.groovy: 35: Annotation @org.springframework.test.context.ActiveProfiles is not allowed on element ANNOTATION
 @ line 35, column 1.
   @ActiveProfiles('integrationTest')
   ^

ApplicationTest.groovy: 36: Annotation @org.springframework.test.context.TestExecutionListeners is not allowed on element ANNOTATION
 @ line 36, column 1.
   @TestExecutionListeners(
   ^
{noformat}

(I omitted imports for brevity)

All of the annotations have `@Target(ElementType.TYPE)`, which according to the documentation:
/** Class, interface (including annotation type), or enum declaration */

Apparently, the Groovy compiler doesn't know that TYPE is also expected to work on annotations.

This issue prevent a lot of annotations being written in Groovy.



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