Comments (13)
That's interesting. I've extracted separate testcase and ... you're right. This problem is somehow related to our multi module project structure. However, the warning is shown for both kinds of submodules - these using mapstruct, and these not. We will try to dig into this.
@filiphr Thanks!
from mapstruct-idea.
@lvcyong I don't understand what you mean with this issue.
Can you please clarify?
If you are referring from the compiler output that you get this comes from the Java Annotation Processor running the Mapstruct processor and it seems you have unmapped target properties.
from mapstruct-idea.
How to disable this warning?
My clarification: this warning is a little annoying if you want to map entities to views/DTO or views/DTO to entities. In such scenario you will almost always have some unmapped properties (intentionally), because if you want to have all properties mapped between these two objects, why would you use mapstruct? You could just expose your domain object instead.
from mapstruct-idea.
@l0co are you referring to the compilation warning?
This is not linked with the IntelliJ plugin. You have multiple options to avoid this:
Mapper#unmappedTargetPolicy
- Explicitly ignore properties via
@Mapping(target = "something", ignore = true)
from mapstruct-idea.
Yes - the compilation warning. Thanks for your hint, I removed all our warnings now. However it would be useful to have an option to disable them by default, as now they can be disabled manually per each mapper only.
from mapstruct-idea.
Have you read about the Configuration options in our documentation? You can disable them via a compiler option. However, I strongly advise against using the compiler option. I always advise to explicitly define what you need too map
from mapstruct-idea.
I overlooked these options, thanks!
from mapstruct-idea.
Heh, it looks in java 10 the compiler option causes another warning (both gradle and Idea):
Information:javac 10 was used to compile java sources
Information:10.05.18 09:08 - Compilation completed successfully with 1 warning in 3s 64ms
Warning:java: The following options were not recognized by any processor: '[mapstruct.unmappedTargetPolicy]'
from mapstruct-idea.
We haven't really tested MapStruct with Java 10, but it should work. Are you still getting the unmapped target properties, or not?
from mapstruct-idea.
Are you still getting the unmapped target properties, or not?
With -Amapstruct.unmappedTargetPolicy=IGNORE
there's no more errors about unmapped properties. However there's persistent The following options were not recognized by any processor
warning (don't know if it's related to JDK 10). Because of this I've sadly needed to get back to per-mapper annotation option because I've spent almost two hours to get rid of this, without any success (only -Xlint:none
works).
FYI: We need to have absolutely no warnings in the build process. Because we heavily use JDK serialization we need to ensure that each Serializable
class has serialVersionUID
field and we use warnings for that with -Xlint:serial -Werror
options. So either first of second class of warnings related to mapstruct is harmful for us.
from mapstruct-idea.
If you don't see any MapStruct warnings with -Amapstruct.unmappedTargetPolicy=IGNORE
then there is a processor that consumes that option 😄.
The problem you are seeing might be if you have a multi module project and you set that property for all modules, but you have the MapStruct compiler only for some modules. The other explanation would be that something has changed in JDK 10 and we are not marking that property as consumed, or the JDK 10 compiler has some bug,
from mapstruct-idea.
@l0co I am not sure if you resolved your problem. However, I think that it might be related to mapstruct/mapstruct#1638. You might want to look into the test compile outputting this as well.
I am going to close this issue for now as there is nothing that the plugin can do
from mapstruct-idea.
You can do like this:
@Mapper
interface CustomerConverter {
@Mapping(source = "email", target = "nickname")
fun toPersonDto(customer: Customer): CustomerDto
@InheritInverseConfiguration
@Mapping(target = "age", ignore = true)
fun fromPersonDto(customerDto: CustomerDto): Customer
}
from mapstruct-idea.
Related Issues (20)
- Auto completion for InheritConfiguration#name, InheritInverseConfiguration#name HOT 1
- Disable unmapped target property warnings when implicitly mapping from a map HOT 2
- Completion for properties don't work (both target and source) HOT 2
- Array and Map paramter ignored as source-parameter if used as only source
- Java expression HOT 1
- Report Non-existing target properties as errors HOT 1
- WrongUsageOfMappersFactoryInspection ignores if componentModel is defined in MapperConfig HOT 1
- IDE Support of `BeanMapping#ignoredTargets`
- Code Completion didn't work well. HOT 12
- Wrong usage of mappers factory should be able to remove static initializer
- code wraps automatically, does not recognize keywords HOT 1
- Incompatible with idea 2024.1 RC HOT 4
- Plugin reports "Can't find related attribute" warning when using `source="."` HOT 2
- Code completion: mapTo... suggestions take precedence over more useful suggestions HOT 6
- Code completion for annotation parameters like @Mapping is not working HOT 5
- False positive missing mapping warning HOT 11
- Incorrect no source property defined inspection for `@Mapping`
- Renaming a @Getter annotated field results in a getter inside the mapping definition (instead of the new field name) HOT 4
- Add a warnig when using `source = "."`
- Expression can not get method hint when target uses @Lombok @FieldNameConstants HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapstruct-idea.