[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Can't compile basic mixin example
|
Glad you got it working.
> BTW is this the right forum for Eclipse related Aspectj issues?
There is an AJDT mailing list too (and newsgroup), but we don't have a
problem with you putting eclipse related issues on this one.
cheers,
Andy
On 17 November 2011 14:48, Abhijit Inamdar <Ainamdar@xxxxxxxxxxxxxx> wrote:
> Thanks for your response Andy. I think I got the problem fixed. it is not actually a bug.
> As I suspected ajc wasn't getting involved at the right time.
> To fix it I needed to add a line to my maven pom.xml for the target project(i.e. the project that is using the mixin library)
>
> For future reference ...
>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>aspectj-maven-plugin</artifactId>
> <version>1.4</version>
> <stuff snipped>
> <executions>
> <execution>
> <phase>process-sources</phase> <<<-------------------------- THIS LINE
> <goals>
> <goal>compile</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
>
> BTW is this the right forum for Eclipse related Aspectj issues?
>
> ________________________________________________________________________________
> From: aspectj-users-bounces@xxxxxxxxxxx [aspectj-users-bounces@xxxxxxxxxxx] on behalf of Andy Clement [andrew.clement@xxxxxxxxx]
> Sent: Wednesday, November 16, 2011 8:24 AM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Can't compile basic mixin example
>
> looks like a possible bug, have you tried avoiding the maven stuff and
> just using ajc on the command line to see if the compiler behaves?
> That will tell us if it is maven configuration that is at fault or
> AspectJ.
>
> Andy
>
> On 14 November 2011 20:36, Abhijit Inamdar <Ainamdar@xxxxxxxxxxxxxx> wrote:
>> I am probably doing something really dumb here, but I can't seem to compile a basic mixin example under maven. I am using the example code from AspectJ in Action by Ramnivas Laddad Chapter 5(Like Listing 5.15 in section 5.1.5).
>> I am packaging a basic Nameable mixin into a jar and that seems to work ok in that even though the files have the .java extension, the class files seem to build the aspect stuff correctly including the NameableMixin$Impl.
>>
>> I have ...
>>
>> 1. src/main/java/ajia/mixin/Entity.java
>>
>> package ajia.mixin;
>>
>> public class Entity implements Nameable {
>> }
>>
>> 2. src/main/java/ajia/mixin/Nameable.java
>>
>>
>> package ajia.mixin;
>>
>> public interface Nameable {
>> public void setName(String name);
>> public String getName();
>>
>> static aspect Impl {
>> private String Nameable.name;
>> public void Nameable.setName(String name) {
>> this.name = name;
>> }
>> public String Nameable.getName() {
>> return this.name;
>> }
>> }
>> }
>>
>>
>> which yields (as expected) ...
>>
>> $ unzip -l target/myaspect-1.0-SNAPSHOT.jar
>> Archive: target/myaspect-1.0-SNAPSHOT.jar
>> Length Date Time Name
>> --------- ---------- ----- ----
>> 0 2011-11-14 17:17 META-INF/
>> 127 2011-11-14 17:17 META-INF/MANIFEST.MF
>> 0 2011-11-14 17:17 ajia/
>> 0 2011-11-14 17:17 ajia/mixin/
>> 1767 2011-11-14 17:17 ajia/mixin/Nameable.class
>> 4613 2011-11-14 17:17 ajia/mixin/Nameable$Impl.class
>> 1681 2011-11-14 17:17 ajia/Nameable.class
>> 4511 2011-11-14 17:17 ajia/Nameable$Impl.class
>> 525 2011-11-14 17:17 builddef.lst
>> 0 2011-11-14 17:17 META-INF/maven/
>> 0 2011-11-14 17:17 META-INF/maven/ajia.mixin/
>> 0 2011-11-14 17:17 META-INF/maven/ajia.mixin/myaspect/
>> 1318 2011-11-14 16:47 META-INF/maven/ajia.mixin/myaspect/pom.xml
>> 110 2011-11-14 17:17 META-INF/maven/ajia.mixin/myaspect/pom.properties
>> --------- -------
>> 17296 15 files
>>
>>
>>
>> Please let me know if any files in this jar are of interest.
>> Then I try to use this in another project but the build breaks with
>>
>> [INFO] -------------------------------------------------------------
>> [ERROR] COMPILATION ERROR :
>> [INFO] -------------------------------------------------------------
>> [ERROR] <snipped>src/main/java/<blah blah>/MyMixinTarget.java:[14,7] MyMixinTarget is not abstract and does not override abstract method setName(java.lang.String) in ajia/mixin/NameableMixin
>> [INFO] 1 error
>> [INFO] -------------------------------------------------------------
>>
>> Not sure why this is happening. Clearly the ajc is not getting involved where it should, and javac isn't looking for the aspect. Must all mixin targets be under src/main/aspect?
>>
>> The pom.xml for the target project contains(among many other things) :
>>
>> <dependency>
>> <groupId> ajia.mixin</groupId>
>> <artifactId>myaspect</artifactId>
>> <version>2.0.7-SNAPSHOT</version>
>> <scope>compile</scope>
>> </dependency>
>> <dependency>
>> <groupId>org.aspectj</groupId>
>> <artifactId>aspectjweaver</artifactId>
>> <version>1.6.11</version>
>> <scope>compile</scope>
>> </dependency>
>> <dependency>
>> <groupId>org.aspectj</groupId>
>> <artifactId>aspectjrt</artifactId>
>> <version>1.6.11</version>
>> </dependency>
>>
>> AND
>>
>> <plugin>
>> <groupId>org.codehaus.mojo</groupId>
>> <artifactId>aspectj-maven-plugin</artifactId>
>> <version>1.4</version>
>> <configuration>
>> <source>1.6</source>
>> <target>1.6</target>
>> <verbose>true</verbose>
>> <outxml>false</outxml>
>> <showWeaveInfo>true</showWeaveInfo>
>>
>> <weaveDependencies>
>> <weaveDependency>
>> <groupId>ajia.mixin</groupId>
>> <artifactId>myaspects</artifactId>
>> </weaveDependency>
>> </weaveDependencies>
>> </configuration>
>> <executions>
>> <execution>
>> <goals>
>> <goal>compile</goal>
>> </goals>
>> </execution>
>> </executions>
>> </plugin>
>>
>>
>>
>>
>> ********************************************************************************
>> Other info:
>>
>>
>>
>> $ ajc -version
>> AspectJ Compiler 1.6.6 (1.6.5 - Built: Wednesday Nov 4, 2009 at 04:40:09 GMT) - Eclipse Compiler 0.785_R33x, 3.3
>>
>> $ java -version
>> java version "1.6.0_26"
>> Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
>> Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
>>
>> $ mvn -version
>> Apache Maven 2.2.1 (r801777; 2009-08-06 12:16:01-0700)
>>
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>