Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » aspects across eclipse projects?
aspects across eclipse projects? [message #42057] Mon, 04 October 2004 16:31 Go to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi again - and sorry for my high NG volume! I seem to keep bumping
into all kinds of problem today...

We are writing some code, that should NOT use static variables since
that may make later multi-threading or "componentization" of the code
more difficult than necessary.
Ah - "a case for AspectJ!" I thought at first but now I am running
into the problem, that AJDT seems to declare warnings only for files
within the same project. Is that so? Since when? I am pretty sure,
that I have written aspects that have worked accross project
boundaries under older AJDT versions (i.e. 1.1.10 and earlier).

I boiled that down to the following tiny example: a classes and an
aspect:

class Test: - has a static and a non-static field and fiddles a bit
with both...
---------------------------
package test;

public class Test
{
public static int a = 2;
public int b;

public Test() {
super();
methodA(a);
}

public void methodA(int x) {
System.out.println("methodA: " + x);
b = x;
a = x*2;
}
}
---------------------------

aspect FlagStatics: should flag accesses to the static field:
---------------------------
package test;

public aspect FlagStatics
{
pointcut allStaticVariableAccesses():
(
get(* test.*.*)
||
set(* test.*.*)
);

declare warning:
allStaticVariableAccesses()
: "Warning: use of static variable";
}
---------------------------

If the above two files reside within the same project things work and
the locations where the static field is set or used are properly
flagged.
If I separate these file into TWO projects, i.e. the file Test.java in
one project, the file FlagStatics.aj in another then no warnings are
emitted, no matter whether I make the first project import the second
or vice versa.

I tried the Java Build Path-s as well as the project references
settings, but couldn't get things to work. How do I apply an aspect
within a project to (an) other project(s)?

Michael
Re: aspects across eclipse projects? [message #42185 is a reply to message #42057] Mon, 04 October 2004 20:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mchapman.uk.ibm.com

Hi Michael,

Thanks for the simple example, it makes it easier to explain. Say you have
Test.java in project A, and FlagStatics.aj in project B, one way to think
of it is as that project B contains your aspect library - aspects which
you want to weave into other code. So you create your aspect library as a
JAR file, by entering a name, say library.jar into the "output jar" field
of the "AspectJ" section of the project's properties page. Now hit the
build button and the library.jar file will be created. Back to project A.
Aspects you want to weave are provided on the aspect path, so simply go to
the "AspectJ Aspect Path" section of project A's properties page, and add
the library.jar from project B, and hit the build button. That should do
the trick - I just followed it through on 1.1.12 to make sure I didn't
miss anything. It should also work the same on 1.2.0 development
builds.

Regards,

Matt.

On Mon, 04 Oct 2004 18:31:46 +0200, Michael Moser wrote:
> Hi again - and sorry for my high NG volume! I seem to keep bumping into
> all kinds of problem today...
>
> We are writing some code, that should NOT use static variables since
> that may make later multi-threading or "componentization" of the code
> more difficult than necessary.
> Ah - "a case for AspectJ!" I thought at first but now I am running into
> the problem, that AJDT seems to declare warnings only for files within
> the same project. Is that so? Since when? I am pretty sure, that I have
> written aspects that have worked accross project boundaries under older
> AJDT versions (i.e. 1.1.10 and earlier).
>
> I boiled that down to the following tiny example: a classes and an
> aspect:

> If the above two files reside within the same project things work and
> the locations where the static field is set or used are properly
> flagged.
> If I separate these file into TWO projects, i.e. the file Test.java in
> one project, the file FlagStatics.aj in another then no warnings are
> emitted, no matter whether I make the first project import the second or
> vice versa.
>
> I tried the Java Build Path-s as well as the project references
> settings, but couldn't get things to work. How do I apply an aspect
> within a project to (an) other project(s)?
>
> Michael
Re: aspects across eclipse projects? [message #42212 is a reply to message #42185] Tue, 05 October 2004 08:58 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi Matt,
thanks for your help. Your described solution worked!

I am only a bit puzzled why one needs to build a .jar file first. In
the described case, the advice doesn't generate any code (it only
contains a "declare warning") so why or what goes into that .jar???

Michael
Re: aspects across eclipse projects? [message #42244 is a reply to message #42212] Tue, 05 October 2004 09:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adrian_colyer.uk.ibm.com

Michael Moser wrote:

> Hi Matt,
> thanks for your help. Your described solution worked!

> I am only a bit puzzled why one needs to build a .jar file first. In
> the described case, the advice doesn't generate any code (it only
> contains a "declare warning") so why or what goes into that .jar???

> Michael

There's been some confusion in general amongst users of AspectJ and AJDT
regarding the difference between classpath, inpath, aspectpath, and what
they all mean. Rather than replying directly in this thread, I've written
a short piece describing the differences and how they work, that you can
find at:

http://www.aspectprogrammer.org/blogs/adrian/2004/10/three_p aths_sta.html

Hope it helps to clarify things a little.
Regards, Adrian.
Re: aspects across eclipse projects? [message #42265 is a reply to message #42212] Tue, 05 October 2004 09:46 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Another observation in that context:

It seems that the automatic build doesn't work at all in such
situations. And even the manual build occasionally fails to rebuild
things properly. Often I suddenly get hundreds of "<xyz> can't be
resolved" errors. I practically always have to do a Clean All and
Rebuild All (sometimes even twice!) to get all things properly
rebuilt.

But I guess that's known and you are working on this, isn't it? This
is on 1.2.0.20041002192124

Michael
Re: aspects across eclipse projects? [message #42313 is a reply to message #42265] Tue, 05 October 2004 10:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hawkinsh.uk.ibm.com

Michael Moser wrote:

> Another observation in that context:

> It seems that the automatic build doesn't work at all in such
> situations. And even the manual build occasionally fails to rebuild
> things properly. Often I suddenly get hundreds of "<xyz> can't be
> resolved" errors. I practically always have to do a Clean All and
> Rebuild All (sometimes even twice!) to get all things properly
> rebuilt.

> But I guess that's known and you are working on this, isn't it? This
> is on 1.2.0.20041002192124

> Michael

Hi Micahel,

There is a bug open looking at when rebuilds should be triggered if
"automatic rebuilding" is enabled:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=73859

An extension to this is that an AJ build should be triggered when the
classpath changes (which it currently isn't).

https://bugs.eclipse.org/bugs/show_bug.cgi?id=74174

Both are being worked on at the moment and will hopefully be fixed soon.

It's a bit concerning that you sometimes have to do a build all several
times - can you give more details about your set up?

Thanks, Helen
Re: aspects across eclipse projects? [message #42340 is a reply to message #42265] Tue, 05 October 2004 10:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hawkinsh.uk.ibm.com

Michael Moser wrote:

> Another observation in that context:

> It seems that the automatic build doesn't work at all in such
> situations. And even the manual build occasionally fails to rebuild
> things properly. Often I suddenly get hundreds of "<xyz> can't be
> resolved" errors. I practically always have to do a Clean All and
> Rebuild All (sometimes even twice!) to get all things properly
> rebuilt.

> But I guess that's known and you are working on this, isn't it? This
> is on 1.2.0.20041002192124

> Michael

Hi Micahel,

There is a bug open looking at when rebuilds should be triggered if
"automatic rebuilding" is enabled:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=73859

An extension to this is that an AJ build should be triggered when the
classpath changes (which it currently isn't).

https://bugs.eclipse.org/bugs/show_bug.cgi?id=74174

Both are being worked on at the moment and will hopefully be fixed soon.

It's a bit concerning that you sometimes have to do a build all several
times - can you give more details about your set up?

Thanks, Helen
Re: aspects across eclipse projects? [message #42390 is a reply to message #42212] Tue, 05 October 2004 10:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mchapman.uk.ibm.com

On Tue, 05 Oct 2004 10:58:42 +0200, Michael Moser wrote:
> Hi Matt,
> thanks for your help. Your described solution worked!
>
> I am only a bit puzzled why one needs to build a .jar file first. In the
> described case, the advice doesn't generate any code (it only contains a
> "declare warning") so why or what goes into that .jar???

The bytecodes for the aspect go into the jar file. I think the reason for
needing to build the jar file stems from the -aspectpath option to
the AspectJ compiler, which accepts only jar files. The inpath and
classpath also accept directories. Maybe -aspectpath could accept
directories too? If it did AJDT could add support for specifying an aspect
path entry as the output directory of another project. Feel free to submit
an enhancement request if you think this would be useful.

Regards,

Matt.
Re: aspects across eclipse projects? [message #42425 is a reply to message #42244] Tue, 05 October 2004 10:28 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
> There's been some confusion in general amongst users of AspectJ and
AJDT
> regarding the difference between classpath, inpath, aspectpath, and
what
> they all mean. Rather than replying directly in this thread, I've
written
> a short piece describing the differences and how they work, that you
can
> find at:
>
>
http://www.aspectprogrammer.org/blogs/adrian/2004/10/three_p aths_sta.html
>
> Hope it helps to clarify things a little.

It did indeed - I think... ;-)
Thanks!

I guess the misunderstanding was on my side. I started to create a
project that contains misc. compile time aspects to enforce or check
for adherence to misc. policies and imported a couple of existing
projects.
My idea had been that - as long as this aspect project is "active",
i.e. open - these checks get "woven into the code" of the other
currently open projects (although most advice don't actually generate
code but rather are declare statements only).
If the project containing my aspects would be closed, i.e. "inactive",
then these aspects should NOT get built nor "woven in" or dealt with
in any form. Thus by triggering a clean & rebuild after
opening/closing a project I had intended to be able to generate
different versions of misc. other projects.

But this - if I understand your writeup and Matt's response
correctly - is not really possible (and maybe not even desireable...).
Rather, one needs the aspect-project to generate some .jar or library
which is then made part of the aspectpath (or potentially inpath) of
the other projects and then gets woven into those when these projects
are (re)built.

Which means - in order to enable/disable my aspects I either have to
fiddle with a couple of aspect-/in-paths each time (or I find a
mechanism to enable/disable all my aspects in one go, e.g. generate an
empty .jar or something of that sort...).

I think my confusion stemmed from the two different possible ways of
looking at this entire "aspectization process" when spreaded over 2 or
more projects:

a.) An aspect prior needs to exist and is woven into a project during
a build (which means it has to be part of the class-/in-/aspect-path
during the build which implies that the project containing the aspect
must have been built before).
vs.
b.) an aspect is "added" to a project after it has been built (in a
kind of second "round" or re-build) in which case building a project
might (& will!) fiddle and modify imported and already existing and
built files. This is of course somewhat touchy and not very
transparent...

For some reason I had assumed things to work like in b.) while
actually they seem to work like in a.)

Sorry for this rambling but maybe it can at least serve to give you an
idea how far off people can be in understanding your stuff... :-)
Michael
Re: aspects across eclipse projects? [message #42456 is a reply to message #42425] Tue, 05 October 2004 13:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mchapman.uk.ibm.com

On Tue, 05 Oct 2004 12:28:16 +0200, Michael Moser wrote:
> Which means - in order to enable/disable my aspects I either have to
> fiddle with a couple of aspect-/in-paths each time (or I find a mechanism
> to enable/disable all my aspects in one go, e.g. generate an empty .jar or
> something of that sort...).

Hi Michael,

The mechanism to enable and disable aspects is known as "build
configurations". Please see the docs on this topic for more info, but in
summary you can just right-click on one or more aspects (or classes or
packages, or a combination) and include or exclude them from the current
build configuration. So in your example you could right-click and exclude
FlagStatics.aj in project B. You then need to rebuild project A, and the
warnings will disappear. You can also store a set of includes and excludes
in a .ajproperties file for later use.

Regards,

Matt.
Re: aspects across eclipse projects? [message #42515 is a reply to message #42456] Tue, 05 October 2004 15:16 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hey - this is brilliant! EXACTLY what I need!

Chapeau - You guys really think ahead!

Michael

"Matt Chapman" <mchapman@uk.ibm.com> wrote in message
news:pan.2004.10.05.13.07.37.75304@uk.ibm.com...
> On Tue, 05 Oct 2004 12:28:16 +0200, Michael Moser wrote:
> ...
> The mechanism to enable and disable aspects is known as "build
> configurations". Please see the docs on this topic for more info,
but in
> summary you can just right-click on one or more aspects (or classes
or
> packages, or a combination) and include or exclude them from the
current
> build configuration.
> ...
Re: aspects across eclipse projects? [message #42546 is a reply to message #42313] Tue, 05 October 2004 20:51 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi Helen,
> ...
> It's a bit concerning that you sometimes have to do a build all
several
> times - can you give more details about your set up?

What exactly would you like to know? When it happens I suddenly have
like 200+ error messages re. non-resolvable imports after a
clean-build. I then do a clean-build again and they are all gone.
I am using Eclipse 3.0.1 with AJDT 1.2M1 (1.2.0.20041002192124). Let
me know what else could be of help.

The effect isn't very frequent and , alas, not really reproducible (at
least I haven't observed any pattern, yet, that allows me to reproduce
it). It has become much less frequent though since I am using the
include/exclude from build feature that I just learned about today.
Before I had more often fiddled with the build-settings, maybe that is
one of the reasons.

It hasn't fully disappeared though and I still had such a case right
now, which is why I am responding. Sorry, that I can't be more
specific and helpful...

Michael
Re: aspects across eclipse projects? [message #42576 is a reply to message #42546] Wed, 06 October 2004 07:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hawkinsh.uk.ibm.com

Michael Moser wrote:

> Hi Helen,
> > ...
> > It's a bit concerning that you sometimes have to do a build all
> several
> > times - can you give more details about your set up?

> What exactly would you like to know? When it happens I suddenly have
> like 200+ error messages re. non-resolvable imports after a
> clean-build. I then do a clean-build again and they are all gone.
> I am using Eclipse 3.0.1 with AJDT 1.2M1 (1.2.0.20041002192124). Let
> me know what else could be of help.

> The effect isn't very frequent and , alas, not really reproducible (at
> least I haven't observed any pattern, yet, that allows me to reproduce
> it). It has become much less frequent though since I am using the
> include/exclude from build feature that I just learned about today.
> Before I had more often fiddled with the build-settings, maybe that is
> one of the reasons.

> It hasn't fully disappeared though and I still had such a case right
> now, which is why I am responding. Sorry, that I can't be more
> specific and helpful...

> Michael

Hi Michael,

Sorry I wasn't more specific :-(

What I meant to ask was about your setup with project dependencies - are
all your projects AJ projects, or do you have Java projects depending on
AJ projects (and do they have project dependencies rather than something
like class folder dependencies --> the build path section in the project
properties and then either the projects or libraries tab)?

Hopefully, when the bug about automatically triggering a rebuild in these
circumstances has been fixed, you will no longer see this problem. If you
do continue to see it please raise a bug.

Thanks, Helen
Re: aspects across eclipse projects? [message #42665 is a reply to message #42185] Tue, 12 October 2004 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: geirAoves.online.no

Hello,

Your solution works in the sense that I can compile my projects, and the
aspects are woven properly. HOWEVER, in Eclipse 3.01 using AJDT 1.1.12, the
places Advices is NOT marked in the editor in the Java code. The affected
methods are also NOT marked in the Method / Outline view in the Java code,
and the Outline for the Aspect does NOT show which methods in the Java code
that are advised.

I have in vain tried to report this many times now: Is there a solution? Use
another version of AJDT ???

Geir Ove

"Matt Chapman" <mchapman@uk.ibm.com> wrote in message
news:pan.2004.10.04.20.58.19.298074@uk.ibm.com...
> Hi Michael,
>
> Thanks for the simple example, it makes it easier to explain. Say you have
> Test.java in project A, and FlagStatics.aj in project B, one way to think
> of it is as that project B contains your aspect library - aspects which
> you want to weave into other code. So you create your aspect library as a
> JAR file, by entering a name, say library.jar into the "output jar" field
> of the "AspectJ" section of the project's properties page. Now hit the
> build button and the library.jar file will be created. Back to project A.
> Aspects you want to weave are provided on the aspect path, so simply go to
> the "AspectJ Aspect Path" section of project A's properties page, and add
> the library.jar from project B, and hit the build button. That should do
> the trick - I just followed it through on 1.1.12 to make sure I didn't
> miss anything. It should also work the same on 1.2.0 development
> builds.
>
> Regards,
>
> Matt.
>
> On Mon, 04 Oct 2004 18:31:46 +0200, Michael Moser wrote:
> > Hi again - and sorry for my high NG volume! I seem to keep bumping into
> > all kinds of problem today...
> >
> > We are writing some code, that should NOT use static variables since
> > that may make later multi-threading or "componentization" of the code
> > more difficult than necessary.
> > Ah - "a case for AspectJ!" I thought at first but now I am running into
> > the problem, that AJDT seems to declare warnings only for files within
> > the same project. Is that so? Since when? I am pretty sure, that I have
> > written aspects that have worked accross project boundaries under older
> > AJDT versions (i.e. 1.1.10 and earlier).
> >
> > I boiled that down to the following tiny example: a classes and an
> > aspect:
>
> > If the above two files reside within the same project things work and
> > the locations where the static field is set or used are properly
> > flagged.
> > If I separate these file into TWO projects, i.e. the file Test.java in
> > one project, the file FlagStatics.aj in another then no warnings are
> > emitted, no matter whether I make the first project import the second or
> > vice versa.
> >
> > I tried the Java Build Path-s as well as the project references
> > settings, but couldn't get things to work. How do I apply an aspect
> > within a project to (an) other project(s)?
> >
> > Michael
Re: aspects across eclipse projects? [message #42697 is a reply to message #42665] Tue, 12 October 2004 12:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mchapman.uk.ibm.com

On Tue, 12 Oct 2004 12:43:15 +0200, Geir Ove wrote:
> Your solution works in the sense that I can compile my projects, and the
> aspects are woven properly. HOWEVER, in Eclipse 3.01 using AJDT 1.1.12,
> the places Advices is NOT marked in the editor in the Java code. The
> affected methods are also NOT marked in the Method / Outline view in the
> Java code, and the Outline for the Aspect does NOT show which methods in
> the Java code that are advised.
>
> I have in vain tried to report this many times now: Is there a solution?
> Use another version of AJDT ???

Hi Geir,

This should work fully with Eclipse 3.0.1 and AJDT 1.1.12. We're trying to
work out what is different about your setup or environment that prevents
this from working for you. You raised bug 75594 for this issue, and I made
some requests for further information there. You should have received
email notification about this. Please help us get to the bottom of this
problem by responding there. Here is a link to the bug report:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=75594

Regards,

Matt.
Re: aspects across eclipse projects? [message #45403 is a reply to message #42390] Sun, 02 January 2005 18:03 Go to previous messageGo to next message
Ivan S. Dubrov is currently offline Ivan S. DubrovFriend
Messages: 7
Registered: July 2009
Junior Member
Matt Chapman wrote:

> The bytecodes for the aspect go into the jar file. I think the reason for
> needing to build the jar file stems from the -aspectpath option to
> the AspectJ compiler, which accepts only jar files. The inpath and
> classpath also accept directories. Maybe -aspectpath could accept
> directories too? If it did AJDT could add support for specifying an aspect
> path entry as the output directory of another project. Feel free to submit
> an enhancement request if you think this would be useful.

Yes, seems like this would be very useful feature.

In the current situation I do not know how to setup build process for
dependent
plugin projects. One plugin project contains aspects, other plugin project
depends on it. Aspects from first project should be weaved into classes of
second
project. The solution with the "output jar" is not good, because it messes
plugin
build process.
Re: aspects across eclipse projects? [message #45462 is a reply to message #45403] Tue, 04 January 2005 12:33 Go to previous message
Ivan S. Dubrov is currently offline Ivan S. DubrovFriend
Messages: 7
Registered: July 2009
Junior Member
Ivan Dubrov wrote:

> In the current situation I do not know how to setup build process for
> dependent plugin projects. One plugin project contains aspects, other plugin
> project depends on it. Aspects from first project should be weaved into
classes
> of second project. The solution with the "output jar" is not good, because
it
> messes plugin build process.

By the way, I found the acceptable solution. Just add a new ANT builder to
the
project providing the aspect classes. The ANT script should just jar
classes
from output directory into jar. Then feed this jar to the dependent
projects
that require aspects from the first project.

This is different from setting "output jar" in the configuration in the
following
way: weaved classes are left in the output folder and could be used by
plugin
build/export process. Setting "output jar" makes weaved classes put
directly
into jar and not in output directory.
Re: aspects across eclipse projects? [message #583839 is a reply to message #42057] Mon, 04 October 2004 20:58 Go to previous message
Matt Chapman is currently offline Matt ChapmanFriend
Messages: 429
Registered: July 2009
Senior Member
Hi Michael,

Thanks for the simple example, it makes it easier to explain. Say you have
Test.java in project A, and FlagStatics.aj in project B, one way to think
of it is as that project B contains your aspect library - aspects which
you want to weave into other code. So you create your aspect library as a
JAR file, by entering a name, say library.jar into the "output jar" field
of the "AspectJ" section of the project's properties page. Now hit the
build button and the library.jar file will be created. Back to project A.
Aspects you want to weave are provided on the aspect path, so simply go to
the "AspectJ Aspect Path" section of project A's properties page, and add
the library.jar from project B, and hit the build button. That should do
the trick - I just followed it through on 1.1.12 to make sure I didn't
miss anything. It should also work the same on 1.2.0 development
builds.

Regards,

Matt.

On Mon, 04 Oct 2004 18:31:46 +0200, Michael Moser wrote:
> Hi again - and sorry for my high NG volume! I seem to keep bumping into
> all kinds of problem today...
>
> We are writing some code, that should NOT use static variables since
> that may make later multi-threading or "componentization" of the code
> more difficult than necessary.
> Ah - "a case for AspectJ!" I thought at first but now I am running into
> the problem, that AJDT seems to declare warnings only for files within
> the same project. Is that so? Since when? I am pretty sure, that I have
> written aspects that have worked accross project boundaries under older
> AJDT versions (i.e. 1.1.10 and earlier).
>
> I boiled that down to the following tiny example: a classes and an
> aspect:

> If the above two files reside within the same project things work and
> the locations where the static field is set or used are properly
> flagged.
> If I separate these file into TWO projects, i.e. the file Test.java in
> one project, the file FlagStatics.aj in another then no warnings are
> emitted, no matter whether I make the first project import the second or
> vice versa.
>
> I tried the Java Build Path-s as well as the project references
> settings, but couldn't get things to work. How do I apply an aspect
> within a project to (an) other project(s)?
>
> Michael
Re: aspects across eclipse projects? [message #583853 is a reply to message #42185] Tue, 05 October 2004 08:58 Go to previous message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi Matt,
thanks for your help. Your described solution worked!

I am only a bit puzzled why one needs to build a .jar file first. In
the described case, the advice doesn't generate any code (it only
contains a "declare warning") so why or what goes into that .jar???

Michael
Re: aspects across eclipse projects? [message #583871 is a reply to message #42212] Tue, 05 October 2004 09:15 Go to previous message
Adrian Colyer is currently offline Adrian ColyerFriend
Messages: 61
Registered: July 2009
Member
Michael Moser wrote:

> Hi Matt,
> thanks for your help. Your described solution worked!

> I am only a bit puzzled why one needs to build a .jar file first. In
> the described case, the advice doesn't generate any code (it only
> contains a "declare warning") so why or what goes into that .jar???

> Michael

There's been some confusion in general amongst users of AspectJ and AJDT
regarding the difference between classpath, inpath, aspectpath, and what
they all mean. Rather than replying directly in this thread, I've written
a short piece describing the differences and how they work, that you can
find at:

http://www.aspectprogrammer.org/blogs/adrian/2004/10/three_p aths_sta.html

Hope it helps to clarify things a little.
Regards, Adrian.
Re: aspects across eclipse projects? [message #583891 is a reply to message #42212] Tue, 05 October 2004 09:46 Go to previous message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Another observation in that context:

It seems that the automatic build doesn't work at all in such
situations. And even the manual build occasionally fails to rebuild
things properly. Often I suddenly get hundreds of "<xyz> can't be
resolved" errors. I practically always have to do a Clean All and
Rebuild All (sometimes even twice!) to get all things properly
rebuilt.

But I guess that's known and you are working on this, isn't it? This
is on 1.2.0.20041002192124

Michael
Re: aspects across eclipse projects? [message #583928 is a reply to message #42265] Tue, 05 October 2004 10:11 Go to previous message
Eclipse UserFriend
Originally posted by: hawkinsh.uk.ibm.com

Michael Moser wrote:

> Another observation in that context:

> It seems that the automatic build doesn't work at all in such
> situations. And even the manual build occasionally fails to rebuild
> things properly. Often I suddenly get hundreds of "<xyz> can't be
> resolved" errors. I practically always have to do a Clean All and
> Rebuild All (sometimes even twice!) to get all things properly
> rebuilt.

> But I guess that's known and you are working on this, isn't it? This
> is on 1.2.0.20041002192124

> Michael

Hi Micahel,

There is a bug open looking at when rebuilds should be triggered if
"automatic rebuilding" is enabled:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=73859

An extension to this is that an AJ build should be triggered when the
classpath changes (which it currently isn't).

https://bugs.eclipse.org/bugs/show_bug.cgi?id=74174

Both are being worked on at the moment and will hopefully be fixed soon.

It's a bit concerning that you sometimes have to do a build all several
times - can you give more details about your set up?

Thanks, Helen
Re: aspects across eclipse projects? [message #583942 is a reply to message #42265] Tue, 05 October 2004 10:11 Go to previous message
Eclipse UserFriend
Originally posted by: hawkinsh.uk.ibm.com

Michael Moser wrote:

> Another observation in that context:

> It seems that the automatic build doesn't work at all in such
> situations. And even the manual build occasionally fails to rebuild
> things properly. Often I suddenly get hundreds of "<xyz> can't be
> resolved" errors. I practically always have to do a Clean All and
> Rebuild All (sometimes even twice!) to get all things properly
> rebuilt.

> But I guess that's known and you are working on this, isn't it? This
> is on 1.2.0.20041002192124

> Michael

Hi Micahel,

There is a bug open looking at when rebuilds should be triggered if
"automatic rebuilding" is enabled:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=73859

An extension to this is that an AJ build should be triggered when the
classpath changes (which it currently isn't).

https://bugs.eclipse.org/bugs/show_bug.cgi?id=74174

Both are being worked on at the moment and will hopefully be fixed soon.

It's a bit concerning that you sometimes have to do a build all several
times - can you give more details about your set up?

Thanks, Helen
Re: aspects across eclipse projects? [message #583972 is a reply to message #42212] Tue, 05 October 2004 10:31 Go to previous message
Matt Chapman is currently offline Matt ChapmanFriend
Messages: 429
Registered: July 2009
Senior Member
On Tue, 05 Oct 2004 10:58:42 +0200, Michael Moser wrote:
> Hi Matt,
> thanks for your help. Your described solution worked!
>
> I am only a bit puzzled why one needs to build a .jar file first. In the
> described case, the advice doesn't generate any code (it only contains a
> "declare warning") so why or what goes into that .jar???

The bytecodes for the aspect go into the jar file. I think the reason for
needing to build the jar file stems from the -aspectpath option to
the AspectJ compiler, which accepts only jar files. The inpath and
classpath also accept directories. Maybe -aspectpath could accept
directories too? If it did AJDT could add support for specifying an aspect
path entry as the output directory of another project. Feel free to submit
an enhancement request if you think this would be useful.

Regards,

Matt.
Re: aspects across eclipse projects? [message #583985 is a reply to message #42244] Tue, 05 October 2004 10:28 Go to previous message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
> There's been some confusion in general amongst users of AspectJ and
AJDT
> regarding the difference between classpath, inpath, aspectpath, and
what
> they all mean. Rather than replying directly in this thread, I've
written
> a short piece describing the differences and how they work, that you
can
> find at:
>
>
http://www.aspectprogrammer.org/blogs/adrian/2004/10/three_p aths_sta.html
>
> Hope it helps to clarify things a little.

It did indeed - I think... ;-)
Thanks!

I guess the misunderstanding was on my side. I started to create a
project that contains misc. compile time aspects to enforce or check
for adherence to misc. policies and imported a couple of existing
projects.
My idea had been that - as long as this aspect project is "active",
i.e. open - these checks get "woven into the code" of the other
currently open projects (although most advice don't actually generate
code but rather are declare statements only).
If the project containing my aspects would be closed, i.e. "inactive",
then these aspects should NOT get built nor "woven in" or dealt with
in any form. Thus by triggering a clean & rebuild after
opening/closing a project I had intended to be able to generate
different versions of misc. other projects.

But this - if I understand your writeup and Matt's response
correctly - is not really possible (and maybe not even desireable...).
Rather, one needs the aspect-project to generate some .jar or library
which is then made part of the aspectpath (or potentially inpath) of
the other projects and then gets woven into those when these projects
are (re)built.

Which means - in order to enable/disable my aspects I either have to
fiddle with a couple of aspect-/in-paths each time (or I find a
mechanism to enable/disable all my aspects in one go, e.g. generate an
empty .jar or something of that sort...).

I think my confusion stemmed from the two different possible ways of
looking at this entire "aspectization process" when spreaded over 2 or
more projects:

a.) An aspect prior needs to exist and is woven into a project during
a build (which means it has to be part of the class-/in-/aspect-path
during the build which implies that the project containing the aspect
must have been built before).
vs.
b.) an aspect is "added" to a project after it has been built (in a
kind of second "round" or re-build) in which case building a project
might (& will!) fiddle and modify imported and already existing and
built files. This is of course somewhat touchy and not very
transparent...

For some reason I had assumed things to work like in b.) while
actually they seem to work like in a.)

Sorry for this rambling but maybe it can at least serve to give you an
idea how far off people can be in understanding your stuff... :-)
Michael
Re: aspects across eclipse projects? [message #584009 is a reply to message #42425] Tue, 05 October 2004 13:07 Go to previous message
Matt Chapman is currently offline Matt ChapmanFriend
Messages: 429
Registered: July 2009
Senior Member
On Tue, 05 Oct 2004 12:28:16 +0200, Michael Moser wrote:
> Which means - in order to enable/disable my aspects I either have to
> fiddle with a couple of aspect-/in-paths each time (or I find a mechanism
> to enable/disable all my aspects in one go, e.g. generate an empty .jar or
> something of that sort...).

Hi Michael,

The mechanism to enable and disable aspects is known as "build
configurations". Please see the docs on this topic for more info, but in
summary you can just right-click on one or more aspects (or classes or
packages, or a combination) and include or exclude them from the current
build configuration. So in your example you could right-click and exclude
FlagStatics.aj in project B. You then need to rebuild project A, and the
warnings will disappear. You can also store a set of includes and excludes
in a .ajproperties file for later use.

Regards,

Matt.
Re: aspects across eclipse projects? [message #584033 is a reply to message #42456] Tue, 05 October 2004 15:16 Go to previous message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hey - this is brilliant! EXACTLY what I need!

Chapeau - You guys really think ahead!

Michael

"Matt Chapman" <mchapman@uk.ibm.com> wrote in message
news:pan.2004.10.05.13.07.37.75304@uk.ibm.com...
> On Tue, 05 Oct 2004 12:28:16 +0200, Michael Moser wrote:
> ...
> The mechanism to enable and disable aspects is known as "build
> configurations". Please see the docs on this topic for more info,
but in
> summary you can just right-click on one or more aspects (or classes
or
> packages, or a combination) and include or exclude them from the
current
> build configuration.
> ...
Re: aspects across eclipse projects? [message #584045 is a reply to message #42313] Tue, 05 October 2004 20:51 Go to previous message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi Helen,
> ...
> It's a bit concerning that you sometimes have to do a build all
several
> times - can you give more details about your set up?

What exactly would you like to know? When it happens I suddenly have
like 200+ error messages re. non-resolvable imports after a
clean-build. I then do a clean-build again and they are all gone.
I am using Eclipse 3.0.1 with AJDT 1.2M1 (1.2.0.20041002192124). Let
me know what else could be of help.

The effect isn't very frequent and , alas, not really reproducible (at
least I haven't observed any pattern, yet, that allows me to reproduce
it). It has become much less frequent though since I am using the
include/exclude from build feature that I just learned about today.
Before I had more often fiddled with the build-settings, maybe that is
one of the reasons.

It hasn't fully disappeared though and I still had such a case right
now, which is why I am responding. Sorry, that I can't be more
specific and helpful...

Michael
Re: aspects across eclipse projects? [message #584060 is a reply to message #42546] Wed, 06 October 2004 07:47 Go to previous message
Eclipse UserFriend
Originally posted by: hawkinsh.uk.ibm.com

Michael Moser wrote:

> Hi Helen,
> > ...
> > It's a bit concerning that you sometimes have to do a build all
> several
> > times - can you give more details about your set up?

> What exactly would you like to know? When it happens I suddenly have
> like 200+ error messages re. non-resolvable imports after a
> clean-build. I then do a clean-build again and they are all gone.
> I am using Eclipse 3.0.1 with AJDT 1.2M1 (1.2.0.20041002192124). Let
> me know what else could be of help.

> The effect isn't very frequent and , alas, not really reproducible (at
> least I haven't observed any pattern, yet, that allows me to reproduce
> it). It has become much less frequent though since I am using the
> include/exclude from build feature that I just learned about today.
> Before I had more often fiddled with the build-settings, maybe that is
> one of the reasons.

> It hasn't fully disappeared though and I still had such a case right
> now, which is why I am responding. Sorry, that I can't be more
> specific and helpful...

> Michael

Hi Michael,

Sorry I wasn't more specific :-(

What I meant to ask was about your setup with project dependencies - are
all your projects AJ projects, or do you have Java projects depending on
AJ projects (and do they have project dependencies rather than something
like class folder dependencies --> the build path section in the project
properties and then either the projects or libraries tab)?

Hopefully, when the bug about automatically triggering a rebuild in these
circumstances has been fixed, you will no longer see this problem. If you
do continue to see it please raise a bug.

Thanks, Helen
Re: aspects across eclipse projects? [message #584110 is a reply to message #42185] Tue, 12 October 2004 10:43 Go to previous message
Eclipse UserFriend
Originally posted by: geirAoves.online.no

Hello,

Your solution works in the sense that I can compile my projects, and the
aspects are woven properly. HOWEVER, in Eclipse 3.01 using AJDT 1.1.12, the
places Advices is NOT marked in the editor in the Java code. The affected
methods are also NOT marked in the Method / Outline view in the Java code,
and the Outline for the Aspect does NOT show which methods in the Java code
that are advised.

I have in vain tried to report this many times now: Is there a solution? Use
another version of AJDT ???

Geir Ove

"Matt Chapman" <mchapman@uk.ibm.com> wrote in message
news:pan.2004.10.04.20.58.19.298074@uk.ibm.com...
> Hi Michael,
>
> Thanks for the simple example, it makes it easier to explain. Say you have
> Test.java in project A, and FlagStatics.aj in project B, one way to think
> of it is as that project B contains your aspect library - aspects which
> you want to weave into other code. So you create your aspect library as a
> JAR file, by entering a name, say library.jar into the "output jar" field
> of the "AspectJ" section of the project's properties page. Now hit the
> build button and the library.jar file will be created. Back to project A.
> Aspects you want to weave are provided on the aspect path, so simply go to
> the "AspectJ Aspect Path" section of project A's properties page, and add
> the library.jar from project B, and hit the build button. That should do
> the trick - I just followed it through on 1.1.12 to make sure I didn't
> miss anything. It should also work the same on 1.2.0 development
> builds.
>
> Regards,
>
> Matt.
>
> On Mon, 04 Oct 2004 18:31:46 +0200, Michael Moser wrote:
> > Hi again - and sorry for my high NG volume! I seem to keep bumping into
> > all kinds of problem today...
> >
> > We are writing some code, that should NOT use static variables since
> > that may make later multi-threading or "componentization" of the code
> > more difficult than necessary.
> > Ah - "a case for AspectJ!" I thought at first but now I am running into
> > the problem, that AJDT seems to declare warnings only for files within
> > the same project. Is that so? Since when? I am pretty sure, that I have
> > written aspects that have worked accross project boundaries under older
> > AJDT versions (i.e. 1.1.10 and earlier).
> >
> > I boiled that down to the following tiny example: a classes and an
> > aspect:
>
> > If the above two files reside within the same project things work and
> > the locations where the static field is set or used are properly
> > flagged.
> > If I separate these file into TWO projects, i.e. the file Test.java in
> > one project, the file FlagStatics.aj in another then no warnings are
> > emitted, no matter whether I make the first project import the second or
> > vice versa.
> >
> > I tried the Java Build Path-s as well as the project references
> > settings, but couldn't get things to work. How do I apply an aspect
> > within a project to (an) other project(s)?
> >
> > Michael
Re: aspects across eclipse projects? [message #584129 is a reply to message #42665] Tue, 12 October 2004 12:41 Go to previous message
Matt Chapman is currently offline Matt ChapmanFriend
Messages: 429
Registered: July 2009
Senior Member
On Tue, 12 Oct 2004 12:43:15 +0200, Geir Ove wrote:
> Your solution works in the sense that I can compile my projects, and the
> aspects are woven properly. HOWEVER, in Eclipse 3.01 using AJDT 1.1.12,
> the places Advices is NOT marked in the editor in the Java code. The
> affected methods are also NOT marked in the Method / Outline view in the
> Java code, and the Outline for the Aspect does NOT show which methods in
> the Java code that are advised.
>
> I have in vain tried to report this many times now: Is there a solution?
> Use another version of AJDT ???

Hi Geir,

This should work fully with Eclipse 3.0.1 and AJDT 1.1.12. We're trying to
work out what is different about your setup or environment that prevents
this from working for you. You raised bug 75594 for this issue, and I made
some requests for further information there. You should have received
email notification about this. Please help us get to the bottom of this
problem by responding there. Here is a link to the bug report:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=75594

Regards,

Matt.
Re: aspects across eclipse projects? [message #585490 is a reply to message #42390] Sun, 02 January 2005 18:03 Go to previous message
Ivan S. Dubrov is currently offline Ivan S. DubrovFriend
Messages: 7
Registered: July 2009
Junior Member
Matt Chapman wrote:

> The bytecodes for the aspect go into the jar file. I think the reason for
> needing to build the jar file stems from the -aspectpath option to
> the AspectJ compiler, which accepts only jar files. The inpath and
> classpath also accept directories. Maybe -aspectpath could accept
> directories too? If it did AJDT could add support for specifying an aspect
> path entry as the output directory of another project. Feel free to submit
> an enhancement request if you think this would be useful.

Yes, seems like this would be very useful feature.

In the current situation I do not know how to setup build process for
dependent
plugin projects. One plugin project contains aspects, other plugin project
depends on it. Aspects from first project should be weaved into classes of
second
project. The solution with the "output jar" is not good, because it messes
plugin
build process.
Re: aspects across eclipse projects? [message #585511 is a reply to message #45403] Tue, 04 January 2005 12:33 Go to previous message
Ivan S. Dubrov is currently offline Ivan S. DubrovFriend
Messages: 7
Registered: July 2009
Junior Member
Ivan Dubrov wrote:

> In the current situation I do not know how to setup build process for
> dependent plugin projects. One plugin project contains aspects, other plugin
> project depends on it. Aspects from first project should be weaved into
classes
> of second project. The solution with the "output jar" is not good, because
it
> messes plugin build process.

By the way, I found the acceptable solution. Just add a new ANT builder to
the
project providing the aspect classes. The ANT script should just jar
classes
from output directory into jar. Then feed this jar to the dependent
projects
that require aspects from the first project.

This is different from setting "output jar" in the configuration in the
following
way: weaved classes are left in the output folder and could be used by
plugin
build/export process. Setting "output jar" makes weaved classes put
directly
into jar and not in output directory.
Previous Topic:Pointcut for super.foo
Next Topic:AspectJ and CVS
Goto Forum:
  


Current Time: Tue Apr 23 10:05:41 GMT 2024

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

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

Back to the top