Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working test case undet intellij #1

Merged
merged 4 commits into from
Sep 3, 2017
Merged

Conversation

laurentperez
Copy link
Contributor

Intellij defaults to Ajc compiler when it sees the aspect, you need to set its compiler back to Javac because lombok does not support Ajc

@wrporter wrporter merged commit c401a22 into wrporter:master Sep 3, 2017
@wrporter
Copy link
Owner

wrporter commented Sep 3, 2017

@laurentperez When I run the test in IntelliJ, it fails due to the thrown exception not getting caught by my aspect. I changed the compiler to use Javac and those are the results I get. Lombok appears to work fine though.

When I run it on the command-line, everything seems to work fine, but I see the following warning about an unsupported compiler for Lombok. Do you get the same results?

─wesp@wesp ~/projects/sandbox/aspect-delete (master|✔)
╰─➤  mvn clean test
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building aspect 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ aspect ---
[INFO] Deleting /Users/wesp/projects/sandbox/aspect-delete/target
[INFO] 
[INFO] --- lombok-maven-plugin:1.16.16.0:delombok (default) @ aspect ---
[INFO] Delombok complete.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ aspect ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ aspect ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/wesp/projects/sandbox/aspect-delete/target/classes
[INFO] 
[INFO] --- aspectj-maven-plugin:1.10:compile (default) @ aspect ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
        <unknown source file>:<no line information>

[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ aspect ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/wesp/projects/sandbox/aspect-delete/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ aspect ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/wesp/projects/sandbox/aspect-delete/target/test-classes
[INFO] 
[INFO] --- aspectj-maven-plugin:1.10:test-compile (default) @ aspect ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
        <unknown source file>:<no line information>

[WARNING] advice defined in com.test.YourAspect has not been applied [Xlint:adviceDidNotMatch]
        /Users/wesp/projects/sandbox/aspect-delete/target/classes!com/test/YourAspect.class:0

[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ aspect ---
[INFO] Surefire report directory: /Users/wesp/projects/sandbox/aspect-delete/target/surefire-reports
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.12.4/surefire-junit4-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.12.4/surefire-junit4-2.12.4.pom (3 KB at 8.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.12.4/surefire-providers-2.12.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.12.4/surefire-providers-2.12.4.pom (3 KB at 23.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.12.4/surefire-junit4-2.12.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.12.4/surefire-junit4-2.12.4.jar (37 KB at 179.4 KB/sec)

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.test.MyTest
MyObject(id=meh)
Aspect Before
My function: MyObject(id=2ebb6620-df9b-4c18-88fe-23842525cfb3)
Aspect Catch: Oh no!
Aspect After
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.152 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.690 s
[INFO] Finished at: 2017-09-03T14:03:20-06:00
[INFO] Final Memory: 27M/381M
[INFO] ------------------------------------------------------------------------

@laurentperez
Copy link
Contributor Author

@wrporter yes, same results, my bad. under cmdline the warnings do not matter : lombok still works (the id/toString works) and the aspect applies (the "Aspect" lines). But under intellij, because of Javac instead of Ajc the aspect does not applies, does not catch, so the RuntimeException crashes the test.

So it's back to square one, indeed. Under intellij we can't have both lombok+aspects under the same project under Ajc. That's why I revived the zombie thread. My "solution" was to bluntly remove lombok from my aspect projects. Writing my own accessors, toString/equals/hashcode/builder is acceptable.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants