Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Maven AspectJ plugin compiles differently on build server

Hi,

Your extra bit of info has helped me reason about what the issue is.
It relates to compilation ordering.  If I compile your files in this
order:

 MyParameterAnnotation.java MyAspectTest.java MyAspect.java A.java ABean.java

the advice applies and the test runs.  If I compile the files in this order:

MyParameterAnnotation.java MyAspectTest.java MyAspect.java ABean.java A.java

the advice does not apply and the test fails.

This is not an unheard of problem, there is no enforced ordering and
sometimes different machines just decide to compile things in a
different order.  It shouldn't make any difference but here is a
situation where it does (a bug).  Basically the match works if the
weaving of the class is done after the compilation of the interface.
At different times during compilation the entities are represented as
either eclipse based data types or bcel based data types.  Here we are
finding the weaving fails unless the interface has made it all the way
through already (and is being represented as a bcel type).

Your local machine and your build machine are just differing in
orderings.  There is a flag to force an ordering but I don't think you
can set it through the maven plugin.

I've raised: https://bugs.eclipse.org/bugs/show_bug.cgi?id=349961 to
cover the issue

cheers
Andy

On 21 June 2011 01:41, Samaey, Diether (Diether)
<diether.samaey@xxxxxxxxxxxxxxxxxx> wrote:
> I found a workaround and wrote a unit test that runs on developer machines but not on the build server !
>
> The problem occurs with parameter annotations on an local interface :
>
> The parameter annotation :
>
>  package com.example;
>
>  import java.lang.annotation.ElementType;
>  import java.lang.annotation.Inherited;
>  import java.lang.annotation.Retention;
>  import java.lang.annotation.RetentionPolicy;
>  import java.lang.annotation.Target;
>
>  @Inherited
>  @Retention(RetentionPolicy.RUNTIME)
>  @Target(ElementType.PARAMETER)
>  public @interface MyParameterAnnotation {
>  }
>
>
> The local interface :
>
>  package com.example;
>
>  import javax.ejb.Local;
>
>  @Local
>  interface A {
>      public String a(@MyParameterAnnotation String s);
>  }
>
>
> The implementation bean :
>
>  package com.example;
>
>  import javax.ejb.Stateless;
>
>  @Stateless
>  class ABean implements A {
>      public String a(String s) {
>          return s;
>      }
>  }
>
>
> The aspect :
>
>  package com.example;
>
>  import org.aspectj.lang.ProceedingJoinPoint;
>  import org.aspectj.lang.annotation.Around;
>  import org.aspectj.lang.annotation.Aspect;
>  import org.aspectj.lang.annotation.Pointcut;
>
>  @Aspect
>  public class MyAspect {
>
>      @Pointcut("execution(* *(..,@MyParameterAnnotation (String),..))")
>      public void anyMethodCallWithMyParameterAnnotation() {
>      }
>
>      @Around("anyMethodCallWithMyParameterAnnotation()")
>      public Object aroundMethodWithMyParameterAnnotation(ProceedingJoinPoint pjp) throws Throwable {
>          throw new RuntimeException("OK");
>      }
>  }
>
>
> The unit test :
>
>  package com.example;
>
>  import org.junit.Assert;
>  import org.junit.Test;
>
>  public class MyAspectTest {
>
>      @Test
>      public void testIt() {
>          A a = new ABean();
>          try {
>              Assert.assertEquals("aha", a.a("aha"));
>              Assert.fail("Failed due to a weaving problem.");
>          }
>          catch (Exception e) {
>              Assert.assertEquals("OK", e.getMessage());
>          }
>      }
>  }
>
> This test can be "fixed" when you add the @MyParameterAnnotation annotation on the parameter of the implementation bean too.
>
> Regards,
>
> Diether
>
> ________________________________________
> From: aspectj-users-bounces@xxxxxxxxxxx [aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andy Clement [andrew.clement@xxxxxxxxx]
> Sent: Thursday, June 16, 2011 6:22 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Maven AspectJ plugin compiles differently on build server
>
> The formatting on all those weavinfo messages you appended was messed
> up for me.  Have you tried diffing the full set? is there something in
> common for all those that are missing:
> - all those for the same aspect
> - all those in the same type/package
> - all those joinpoints of the same kind
>
> I presume you get no warnings on the server (like 'cant find type')
> that you are not getting on the client?
> Have you tried turning on verbose mode to see if the same set of files
> are passed to the compiler in both cases?
>
> cheers,
> Andy
>
> On 16 June 2011 02:24, dsamaey <diether.samaey@xxxxxxxxxxxxxxxxxx> wrote:
>> When comparing local developer maven builds with the builds generated by our
>> build server, there is a weird difference.  On the build server, there are
>> 211 weaving statements in the build log compared to 300 weaving statement in
>> the developer builds.  The weaving on the build server is incomplete.
>>
>>            <plugin>
>>                <groupId>org.codehaus.mojo</groupId>
>>                <artifactId>aspectj-maven-plugin</artifactId>
>>                <version>1.3.1</version>
>>                <dependencies>
>>                    <dependency>
>>                        <groupId>org.aspectj</groupId>
>>                        <artifactId>aspectjrt</artifactId>
>>                        <version>1.6.11</version>
>>                    </dependency>
>>                    <dependency>
>>                        <groupId>org.aspectj</groupId>
>>                        <artifactId>aspectjtools</artifactId>
>>                        <version>1.6.11</version>
>>                    </dependency>
>>                </dependencies>
>>                <configuration>
>>                    <source>1.6</source>
>>                    <complianceLevel>1.6</complianceLevel>
>>                    <verbose>true</verbose>
>>                    <showWeaveInfo>true</showWeaveInfo>
>>                    <target>1.6</target>
>>                </configuration>
>>                <executions>
>>                    <execution>
>>                        <goals>
>>                            <goal>compile</goal>
>>                            <goal>test-compile</goal>
>>                        </goals>
>>                    </execution>
>>                </executions>
>>            </plugin>
>>
>>
>> I have been looking for differences between our build server and the
>> developer setup but they run the same Maven version and the same JDK
>> version.
>>
>> Local developer machines run either Win7 or OSX, the build server runs Linux
>> :
>>
>> cat /proc/version
>>
>> Linux version 2.6.18-92.el5PAE (mockbuild@xxxxxxxxxxxxxxxxxxxx) (gcc version
>> 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Jun 10 19:22:41 EDT 2008
>>
>> uname -m
>>
>> i686
>>
>> Any suggestions what could be wrong with our build server ?
>>
>> --
>> View this message in context: http://aspectj.2085585.n4.nabble.com/Maven-AspectJ-plugin-compiles-differently-on-build-server-tp3601938p3601938.html
>> Sent from the AspectJ - users mailing list archive at Nabble.com.
>> _______________________________________________
>> 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
>


Back to the top