Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » APT: Accessing generetad files
APT: Accessing generetad files [message #250172] Wed, 12 December 2007 07:05 Go to next message
Eclipse UserFriend
Originally posted by: Martin.eisengardt.de

Hi everyone.


We are trying to generate some binary files and classes covering
annotations. Our apt processor plugin is doing well.

1) But we cannot include a jar file in our project via project settings.
Eclipse accepts this jar but does not detect any annotation processors. Our
processor won't get called...
If we are installing this plugin (copy it to eclipse plugin directory) and
select this installed plugin Eclipse accepts it and calls our apt processor.
It is not a serious problem. But I planned to share our processor via SVN
and don't want other developers to update it manually (developers seem to
forget those things often *g*).

2) The serious problem: We are generating new sources as well as some binary
files. It's all fine about that and Eclipse shows up java files and binary
files inside ".aptgenerated". Within our framework we need to access
generated classes as well as those binary files.
However it works fine with those classes. They can be accessed. But our
binaries cannot be received via "ClassLoader.getSystemResources()". If I
copy it to another source folder it works. I noticed that Eclipse does not
copy my binary files insode ".aptgenerated" to my output folder. Of course
that's the reason it cannot be read at runtime.
My question: Why?
We create our binary files using FilerLocation.SOURCE_TREE. If we are
creating two files, one at SOURCE_TREE and one at CLASS_TREE it works. It
this a bug or feature? :-)

I am using Eclipse 3.3.1.1 (fall2).


Greetings from Germany

Martin
Re: Accessing generetad files [message #250180 is a reply to message #250172] Wed, 12 December 2007 16:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Martin Eisengardt" <Martin@eisengardt.de> wrote in message
news:fjoiq0$h99$1@build.eclipse.org...

> 1) But we cannot include a jar file in our project via project settings.
> Eclipse accepts this jar but does not detect any annotation processors.
> Our processor won't get called...

Does your jar file contain the
META-INF/services/com.sun.mirror.apt.AnnotationProcessorFact ory file, and do
its contents correctly specify your factory class?


> 2) [...] I noticed that Eclipse does not copy my binary files insode
> ".aptgenerated" to my output folder. Of course that's the reason it cannot
> be read at runtime.
> My question: Why?
> We create our binary files using FilerLocation.SOURCE_TREE. If we are
> creating two files, one at SOURCE_TREE and one at CLASS_TREE it works. It
> this a bug or feature? :-)

Another person also reported recently that text files they created in
..apt_generated weren't copied over to the output. I haven't had a chance to
try it myself. It seems possible that there is something about the way the
directory is defined on the classpath that keeps non-Java files from being
copied? I'll investigate.

-Walter Harley
JDT APT team
Re: Accessing generetad files [message #250183 is a reply to message #250180] Wed, 12 December 2007 20:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Walter Harley" <wharley@bea.com> wrote in message
news:fjpjjq$54v$1@build.eclipse.org...
>> 2) [...] I noticed that Eclipse does not copy my binary files insode
>> ".aptgenerated" to my output folder. Of course that's the reason it
>> cannot be read at runtime.
>> My question: Why?
>> We create our binary files using FilerLocation.SOURCE_TREE. If we are
>> creating two files, one at SOURCE_TREE and one at CLASS_TREE it works. It
>> this a bug or feature? :-)
>
> Another person also reported recently that text files they created in
> .apt_generated weren't copied over to the output. I haven't had a chance
> to try it myself. It seems possible that there is something about the way
> the directory is defined on the classpath that keeps non-Java files from
> being copied? I'll investigate.


I'm not sure either whether it's a bug or a feature. Based on a few hours
of experimentation, the rules that govern what gets copied from source to
output folders seem puzzling. It's probably going to take some time to
track this down.

In the meantime, if you need to generate text or binary files (as opposed to
Java files, that will then be compiled to .class files), you probably need
to generate them into CLASS_TREE.
Re: Accessing generetad files [message #250199 is a reply to message #250183] Thu, 13 December 2007 16:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Walter Harley" <wharley@bea.com> wrote in message
news:fjq16v$1t9$1@build.eclipse.org...
>> Another person also reported recently that text files they created in
>> .apt_generated weren't copied over to the output. I haven't had a chance
>> to try it myself. It seems possible that there is something about the
>> way the directory is defined on the classpath that keeps non-Java files
>> from being copied? I'll investigate.
>
>
> I'm not sure either whether it's a bug or a feature. Based on a few hours
> of experimentation, the rules that govern what gets copied from source to
> output folders seem puzzling. It's probably going to take some time to
> track this down.


I have entered https://bugs.eclipse.org/bugs/show_bug.cgi?id=212939 to track
this issue.

Martin, please comment in that bug if you have a use case that requires you
to generate non-Java folders into the source folder rather than directly
into the output folder.
Re: Accessing generetad files [message #250323 is a reply to message #250180] Thu, 20 December 2007 13:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Martin.eisengardt.de

> Does your jar file contain the
> META-INF/services/com.sun.mirror.apt.AnnotationProcessorFact ory file, and
> do its contents correctly specify your factory class?

That's it. Tank You.

> Another person also reported recently that text files they created in
> .apt_generated weren't copied over to the output. I haven't had a chance
> to try it myself. It seems possible that there is something about the way
> the directory is defined on the classpath that keeps non-Java files from
> being copied? I'll investigate.

OK, Since it is working as intended I will create both binary files. But I
did not see any docs even at suns "getting started with apt". Maybe You
should create some warning at jdt-apt docs. :-)
Re: Accessing generetad files [message #250326 is a reply to message #250323] Thu, 20 December 2007 15:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Martin Eisengardt" <Martin@eisengardt.de> wrote in message
news:fkeb6f$bqe$1@build.eclipse.org...
> OK, Since it is working as intended I will create both binary files. But I
> did not see any docs even at suns "getting started with apt". Maybe You
> should create some warning at jdt-apt docs. :-)

You're right, the information we have available for people who want to write
processors is pretty weak.

I've entered https://bugs.eclipse.org/bugs/show_bug.cgi?id=213636 to address
the web site (been meaning to rewrite that for a few years, but it's a big
chore that only gets bigger), and
https://bugs.eclipse.org/bugs/show_bug.cgi?id=213637 to address the missing
parts of the JDT online help.
Re: Accessing generetad files [message #250338 is a reply to message #250326] Sat, 22 December 2007 13:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: martin.eisengardt.de

OK, I got some new problem.

Currently we try to access some PackageDeclaration and try to read
annotations. We use a simple package-info.java to set this annotation at
package level.
Following code:
for (final String pkgName : this.getAllPackages()) {

final PackageDeclaration pkg = this.env.getPackage(pkgName);

if (pkg != null && pkg.getAnnotation(NClientModule.class) != null) {

debug("Adding dirty package " + pkg);

this.dirtyPackages.add(pkg);

}

}


However method "getAnnotation" always returns null. It is an instance of
PackageDeclarationImplNoBinding. Actually this is a bug because there are
some java classes present in this package. While debugging, I found some
problem. BaseProcessorEnv.getPackages tries to open this package and looks
for compilation types Sometime it will find a regular java class at first
position. But for some packages it will find 20 of them but first of them is
our "package-info.java". This will not return any type and BaseProcessorEnv
will return this dummy declaration. I don't think that this works as
intended, is it? :-)

We will try to do some bugfixing around it but.

Ciao
Martin


"Walter Harley" <wharley@bea.com> schrieb im Newsbeitrag
news:fkejiv$odl$1@build.eclipse.org...
> "Martin Eisengardt" <Martin@eisengardt.de> wrote in message
> news:fkeb6f$bqe$1@build.eclipse.org...
>> OK, Since it is working as intended I will create both binary files. But
>> I did not see any docs even at suns "getting started with apt". Maybe You
>> should create some warning at jdt-apt docs. :-)
>
> You're right, the information we have available for people who want to
> write processors is pretty weak.
>
> I've entered https://bugs.eclipse.org/bugs/show_bug.cgi?id=213636 to
> address the web site (been meaning to rewrite that for a few years, but
> it's a big chore that only gets bigger), and
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=213637 to address the
> missing parts of the JDT online help.
>
Re: Accessing generetad files [message #250347 is a reply to message #250338] Sat, 22 December 2007 18:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: martin.eisengardt.de

> We will try to do some bugfixing around it but.
>

OK, I edited every package-info.java and added "interface dummy{}" to let
them return any type. However this bugfix works for us but it is really evil
hack.
Re: Accessing generetad files [message #250354 is a reply to message #250347] Wed, 26 December 2007 15:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Martin Eisengardt" <martin@eisengardt.de> wrote in message
news:fkk64i$g6r$1@build.eclipse.org...
>
>> We will try to do some bugfixing around it but.
>>
>
> OK, I edited every package-info.java and added "interface dummy{}" to let
> them return any type. However this bugfix works for us but it is really
> evil hack.

Martin, can you enter a bug in Bugzilla, with the necessary information to
reproduce this? It does sound like a bug.
Re: Accessing generetad files [message #250361 is a reply to message #250354] Thu, 27 December 2007 04:04 Go to previous message
Eclipse UserFriend
Originally posted by: martin.eisengardt.de

OK.

Bug 213917. You will have package-info to be the first compilable unit jdt
returns. It's easy to reproduce with empty packages (having only a
package-info.java including some annotation).

"Walter Harley" <wharley@bea.com> schrieb im Newsbeitrag
news:fkud91$io6$1@build.eclipse.org...
> "Martin Eisengardt" <martin@eisengardt.de> wrote in message
> news:fkk64i$g6r$1@build.eclipse.org...
>>
>>> We will try to do some bugfixing around it but.
>>>
>>
>> OK, I edited every package-info.java and added "interface dummy{}" to let
>> them return any type. However this bugfix works for us but it is really
>> evil hack.
>
> Martin, can you enter a bug in Bugzilla, with the necessary information to
> reproduce this? It does sound like a bug.
>
Previous Topic:How to create a composite refactoring plugin myself
Next Topic:Wrong editor selected as default (problem with editor or content type definition?)
Goto Forum:
  


Current Time: Fri Apr 18 10:20:09 EDT 2025

Powered by FUDForum. Page generated in 0.04717 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top