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

Eclipse integration issue #28

Closed
guillaumBrisard opened this Issue Oct 8, 2014 · 7 comments

Comments

Projects
None yet
2 participants
@guillaumBrisard
Copy link

guillaumBrisard commented Oct 8, 2014

Hi Séven,

My projects work fine with gradle, but I couldn’t get them work with Eclipse 4.4:

  • I checked all the box under JavaCompiler/Annotation Processing
  • I had the 3 jars in Factory Path:
    • myProject/lib/selma-processor-0.8.jar
    • myProject/lib/selma-0.8.jar
    • myProject/lib/javawriter-2.2.1.jar
  • "Clean and Build All" projects just to be sure

==> no generated class and when I deploy it in Tomcat 8, I obviously have a nice "java.lang.ClassNotFoundException"

It's really important for me that it work under Eclipse. What am I missing here ?

Thanks.

PS : My projects works fine with gradle, except selma generates the class at the root,
it's a bit weird, it's not an issue but is it possible to choose the location ?

@slemesle

This comment has been minimized.

Copy link

slemesle commented Oct 9, 2014

Hello,

can you provide the complete Stack trace please ?

For eclipse configuration steps are :

  • Enable Annotation Processing and add javawriter, selma and selma-processor libraries to the factory path of the annotation processing settings
  • Project Properties → Java Compiler → Annotation Processing
    check "Enable project specific settings" and "Enable annotation processing"
  • Project Properties → Java Compiler → Annotation Processing → Factory Path
    "Add JARs..." for each downloaded jar

For the class not found stack trace will help akka which class is not found.

Last, generated class are placed where compiler tells it, using maven by default it will be in target/generated-sources, there should be a setting in gradle to specify it.

Perhaps this will help you with gradle ? [http://stackoverflow.com/questions/25239243/annotation-processor-in-gradle-outputs-source-files-to-build-classes-making-java]

I will try a demo build with gradle to see what happens.

@guillaumBrisard

This comment has been minimized.

Copy link
Author

guillaumBrisard commented Oct 9, 2014

Hi,

I figured out what was my issue, it's AJDT.
If I remove the aspectj nature of my project, and I enable Annotation Processing and add the jars, it works but just once.
If I clean and build my projects, no src generation. I have to disable Annotation Processing, remove the jars and do everything again and I have generated src.
How I can trigger the src generation, is it not by cleaning and building ?
Do you have any idea ?

For AJDT I knew they was an issue, but it supposed to be fixed according to this blog
http://andrewclement.blogspot.fr/2014/08/annotation-processing-in-ajdt.html

Your previous link help me, it works with javac but not with ajc (aspectJ)
I am still working on it.

Thanks

@slemesle

This comment has been minimized.

Copy link

slemesle commented Oct 9, 2014

I've read the blog post and saw that you should be running the same java version as the one used to compile the processor.
For now I chose to deliver the processor compiled in Java 6 so every one can benefit of Selma from this release.
Perhaps you could give a try building Selma using youre preferred Java version, the project builds on Java 6, 7 and 8 travis-ci ensures it [https://travis-ci.org/xebia-france/selma].

I personally use IntelliJ for long time but I know others succeed with eclipse builds smoothly.

Can you provide me a demo project ?

Also please tell me youre eclipse release.

@slemesle

This comment has been minimized.

Copy link

slemesle commented Oct 16, 2014

Hi again,

I managed to download a clean Luna workbench, then imported the sample project provided in the source tree.
So I first made a working test without installing AJDT.
Then I installed AJDT and add the AspectJ nature to the project and it worked once. I should change the annotation processor settings to get it built once again.

So there is still a bug in AJDT with annotation processors, we should report a bug.

@guillaumBrisard

This comment has been minimized.

Copy link
Author

guillaumBrisard commented Oct 16, 2014

Thanks,

Did you try a project without Aspect, but just with APT enabled ?
For me it's the same thing, just works once.

I think I find a workaround, it's not perfect but it works.
I will post it here this week-end.

@slemesle slemesle added bug question and removed bug labels Oct 16, 2014

@slemesle

This comment has been minimized.

Copy link

slemesle commented Oct 16, 2014

I did try starting a brand new project with only APT enabled.
When AJDT is installed but not used it fails the same for me. There should be some hook installed by AJDT in APT.

The good news is that it does work without AJDT at all.

@guillaumBrisard

This comment has been minimized.

Copy link
Author

guillaumBrisard commented Oct 18, 2014

One Solution,

First you need this gradle plugin https://github.com/eveoh/gradle-aspectj
You have to build it by yourself because the last release (1.4) doesn't have the feature we need,
which is the possibility to add any options to the compiler ajc (additionalAjcArgs)

One it's done,

  • copy the jar in your project under lib, we will say. (myProject/lib)
  • add these lines at the beginning of your build.gradle
buildscript {
    dependencies {
        classpath files('lib/gradle-aspectj-1.5.jar')
    }
}

project.ext {
    aspectjVersion = '1.8.2'
}

apply plugin: 'aspectj'

It needs to be at last the 1.8.2 version to work with Annotation Processor

  • and these ones too
ext.generatedSrc = "$buildDir/generated-src"
ext.generatedSrcDir = file("$generatedSrc")

compileAspect {
        doFirst {
            generatedSrcDir.exists() || generatedSrcDir.mkdirs()
        }
        additionalAjcArgs = [
            's' : "$generatedSrc"
        ]
   }
  • Now it will work with at least gradle. But not with Eclipse
  • Finally add these lines
sourceSets {
    main {
        java {
            srcDir generatedSrcDir
        }
    }
}

Now Eclipse, after "gradle compileAspect", will know the generated classes, and you can deploy your favorite app in Tomcat for example.

But each time you modify your bean, DTO, Mapper, you need to run "gradle compileAspect"

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.