maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Geurts <dennis.geu...@gmail.com>
Subject Re: gRE: M2 and annotations
Date Sun, 11 Sep 2005 18:09:19 GMT
It's probably the best to look at Sun's documentation
 APT (Annotation Processing Tool): 
http://java.sun.com/j2se/1.5.0/docs/guide/apt/index.html
 Annotations in general: 
http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html
 Dennis
  p.s. I'm also not experienced myself with annotations to be giving others 
any well-funded advice
but there's something called "retention policy" i.e. you can supply to the 
compiler/ VM whether
it should expose the annotation metadata during runtime or not.
 Seems odd though that one VM (eclipse) does seem to expose it and another 
(maven w/ JUnit) does not.
Could it be that the 'tools.jar' is needed ?? (the APT api can be found in 
com.sun.mirror.* )
  
 On 9/11/05, Kaare Nilsen <kaare.nilsen@gmail.com> wrote: 
> 
> Hi.
> I am compiling with source level of 1.5 by doing this :
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> 
> <artifactId>maven-compiler-plugin</artifactId>
> <configuration>
> <source>1.5</source>
> <target>1.5</target>
> </configuration>
> </plugin>
> 
> But I do not know how to run annotation processor. (I am not that
> experienced with annotations myself, so I did not even know there was 
> one),
> so if anyone know how I do this I would be glad for any tips.
> 
> Best regards
> Kaare Nilseb
> 
> -----Original Message-----
> From: Brett Porter [mailto:brett.porter@gmail.com]
> Sent: 11. september 2005 04:57
> To: Maven Users List
> Subject: Re: M2 and annotations
> 
> I'm not familiar with using Java5 annotations at this point, but I think 
> you
> 
> need to run the annotation processor first, or at least compile with 
> source
> level of 1.5. Have these been done?
> 
> - Brett
> 
> On 9/11/05, Kaare Nilsen <kaare.nilsen@gmail.com> wrote:
> >
> > Hi I have a little problem.
> >
> >
> >
> > I am trying to make a testng plugin for maven2, but I have reached a 
> point
> > where I really don't know what to do.
> >
> > Here is the case:
> >
> >
> >
> > TestNG uses annotations and have an annotation called Test with fully
> > qualified name :" org.testng.annotations.Test"
> >
> > So..
> >
> > Then I have a testclass looking like this .
> >
> >
> >
> > package org.codehaus.mojo.testng;
> >
> > import org.testng.annotations.Test;
> >
> > public class ATest {
> >
> >
> >
> > @Test
> >
> > public void test(){
> >
> > System.out.println("A test is run");
> >
> > }
> >
> >
> >
> >
> >
> > And. Then I do like this:
> >
> >
> >
> > public void execute()
> >
> > throws MojoExecutionException
> >
> > {
> >
> > Object o = loader.loadClass("org.codehaus.mojo.testng.ATest
> > ").newInstance();
> >
> > Method[] met = o.getClass().getMethods();
> >
> > Class annotation = Class.forName("org.testng.annotations.Test");
> >
> > Object thisAnnotation = met[0].getAnnotation((Class<Annotation>)
> > annotation);
> >
> > }
> >
> >
> >
> > So far so good.. But this is what happens.
> >
> > When I run this plugin in eclipse with a junit test. thisAnnotation !=
> > null
> >
> > But when I run this plugin as a part of a maven build thisAnnotation ==
> > null
> >
> >
> >
> > Anyone have a clue of why this happens ?
> >
> >
> >
> > Best regards
> >
> > Kaare Nilsen
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message