Can't use annotation processing in a maven project

Hi guys.
I’m converting a normal project to a maven one and i’m using lombok into it. I had no problems without maven but now i get errors while Getter and Setter methods are called (not when they’re declarated).
Example:

@Getter private ArrayList<Weapon> weapons = new ArrayList<>(); (No error)

for(Weapon weap:map.getWeapons()) (This gives me error)

The error is that the method doesn’t exist. I use this code into pom.xml to register lombok:

<dependency> <groupId>com.lombok</groupId> <artifactId>lombok_uppercase_patch</artifactId> <version>1.1</version> <type>jar</type> <scope>provided</scope> </dependency>

I went on google but i just saw threads from 2010 and no real solution.

mhhh that’s not really related to JME.
Also it seems like a lot of hassle to avoid a right click/generate getters and setters

Well without seeing the error it’s hard to tell what’s wrong. However, when you declare a dependency using provided scope, you’re telling maven to not bundle that jar with your application and that you will sort that out yourself later on. Now assuming you get a class not found exception or similar, I would remove the line altogether and let maven include it in the built artifact for you.

Depends on the IDE you are using. AFAIK all ide’s do not use gradle/maven for compiling/error checking.

For Eclipse you have to install the official lombok plugin.
For IntelliJ there is also a lombok plugin, and you have to enable annotation processing in the compiler settings
I guess for Netbeans there is also a solution

Lombok does offer quite a few nice features. Why writing getters/setters? They are just boilerplate and increase the number of lines you have to scroll.
And the more advanced stuff like @Builder are pretty nice because you don’t have to refactor your Builder/Factory

Maybe I’m just too old school :wink:

try

	<dependency>
		<groupId>org.projectlombok</groupId>
		<artifactId>lombok</artifactId>
		<version>1.16.4</version>
		<scope>provided</scope>
	</dependency>

from official doc Project Lombok

PS: I used lombock+gradle+jME+java8 but slowly moving to Xtend. I like to have less boilerplate (a daily scala dev)

While we are shouting off topic stuff… you get the same effect on Groovy with:

def weapons = []

for(Weapon weap : map.getWeapons())

Or:
for(Weapon weap : map.weapons) // still goes through the generated getter

Or:
map.weapons.each {
}

The error is that the method doesn’t “getSpatials” doesn’t exist into “map” and netbeans (i’m using the 3.1 sdk) suggest me to create that method.

you have the error when you compile with maven on command line or in netbeans (SDK) ?
Can you copy/paste the error ?

Both times.

http://s10.postimg.org/hluphd9x5/scoreboard2.png

‘map’ is of type AbstractMap ? not the type with the ‘weapons’ fields.

What is the type of ‘map’ ? (show the declaration)
What is the type with ‘weapons’ and @Getter ? (show the declaration)

1 Like

1)Yes,it is,you can see it in the screen.
2) AbstractMap map=(AbstractMap) Helpers.compileClass(name,Helpers.modPath+"/Maps/"+name);
3) @Getter private ArrayList<Weapon> weapons = new ArrayList<>();

So compiler is correct, you can’t write map.weapons.
you can call .weapons only on instance of the class with the field ‘@Getter …’

Side Advices:

  • try to avoid cast
  • never use AbstractMap (it’s only for extends), use the concret class or the Map interface

We talk about java.util.AbstractMap ?

Ok,i solved.The uppercase patch was not working,i switched to 1.15 and annotations get compiled,thanks everyone :smile:

But now,i have to import the asset folder and the project isn’t recognizing it automatically,how can i do it?

I show you the dependencies 23h ago, with the recommended version, groupId,… from the official doc: 1.16.4
see above post 6.

Seems i’m not the only one!

I tried this version but it didn’t work,i’m actually using 1.16.5

Sorry to update thread but i still haven’t got a solution :\

The problem is that i don’t know how to specify the asset folder. Do i have to change all my paths in the game or is there a way to make it work like a jme3 pre-configurated project like the one that IDE propose?

Just add it to your classpath

Is there a way to do it with maven projects into IDE or do i have to modify configuration files?