mapstruct / mapstruct-eclipse Goto Github PK
View Code? Open in Web Editor NEWAn Eclipse plug-in for working with MapStruct
License: Other
An Eclipse plug-in for working with MapStruct
License: Other
Support nested properties and properties of several-sources parameters.
I think the license-tag in the feature.xml needs to be added, but I'm not that sure about the content to add there.
For the "Unmapped target property" error, another quick-fix could set @Mapper#unmappedTargetProperty=IGNORE
.
I'm hesitant to post this as issues like this tend to be a misconfig somewhere...
I'm no longer getting any code completions at all from MapStruct. I initially thought this was because we used records almost exclusively everywhere, but now I tried to create a simple POJO and that offers no code completions for @Mapping
either.
Eclipse 2023-09, MapStruct Tools 0.1.0.201701192129. The error log seems clear. Enabling or disabling "Enable non-blocking completions" makes no difference.
Example code:
@Mapper
public interface AhaMapper {
@Mapping(target = "name", source = "name2")
Aha fromDto2(Aha2 ahaaa);
}
public static class Aha {
private final String name;
public Aha(String name) {
this.name = name;
}
public String getName() { return name; }
}
public static class Aha2 {
private final String name2;
public Aha2(String name2) {
this.name2 = name2;
}
public String getName2() { return name2; }
}
Consider the Mapper :
@GearQualifier
public abstract class GearSpecMapper {
@GearDTO1Qualifier
public GearDTO1 toDTO1(GearSpec entity) {
return ... // some mapping logic
}
@GearDTO2Qualifier
public GearDTO2 toDTO2(GearSpec entity) {
return ... // some mapping logic
}
}
And my main mapper
@Mapper(uses=GearQualifier.class)
public interface GearSpecMapper {
@Mapping(target="gearDTO", source="gear", qualifiedBy={GearQualifier.class, GearDTO1Qualifier.class})
EngineDTO1 fromEntity(Entity entity);
}
All my @Gear*Qualifier
are @Qualifier
with propeper retention
I get an error saying my mapping is ambigious and he quotes that he cannot choose beetween the two method of my GearSpecMapper
In the documentation the only example shown with @Qualifier
is used mapping a String to a String. Is using this a limitation (no mapping object supported )?
Did I miss something.
I used a decorator as a workaround.
Cheers,
PS : love the framework otherwise ;-), great work !
In @InheritConfiguration#name()
/@InheritInverseConfiguration#name()
there could be shown a filtered list of existing (and applicable) method names, including those defined in supertypes, mappers referenced via uses
and in a @MapperConfig
.
The release (https://dl.bintray.com/mapstruct/mapstruct-eclipse-site/) and snapshot update-site seem to be down at the moment.
@larswetzer For some reason the build fails if I cannot connect to the internet. Any idea how to improve that? Thanks!
When working with a Maven project for which MapStruct is enabled (e.g. through via maven-processor-plugin), upon import of the project M2E will automatically configure the Eclipse project to run the MapStruct annotation processor.
But for plain "Java Project"s it'd be nice if the plug-in could be used to set up MapStruct. It could like this:
@larswetzer WDYT, would that make sense?
Hello,
When installing the plugin from mapstruct website or from eclipse marketplace, I have this error in eclipse:
Unable to read repository at https://mapstruct.org/eclipse/content.xml.
Certificate for <mapstruct.org> doesn't match any of the subject alternative names: [*.github.com, www.github.com, github.io, github.com, *.github.io, githubusercontent.com, *.githubusercontent.com]
Can you look into it ?
I searched a little the website repository and found that there is no content.xml file in the static/eclipse folder, maybe it is related ? (I don't know anything about how to deploy and develop an eclipse plugin).
Doesn't work, if:
@MappingTarget
parameter@TargetType
parameterEclipse 2018-12RC1 run on OpenJDK 11. Target project is Java 8 or Java 11. I guess any target will work the same.
In pom.xml:
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>1.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.2.0.Final</version>
<scope>provided</scope>
</dependency>
When I change any of a mapped class or a mapping interface the interface gets error marker with the stack trace below:
Internal error in the mapping processor: java.lang.RuntimeException: javax.annotation.processing.FilerException: Source file already exists : test.mapstruct.TestMapperImpl at org.mapstruct.ap.internal.processor.MapperRenderingProcessor.createSourceFile(MapperRenderingProcessor.java:71) at org.mapstruct.ap.internal.processor.MapperRenderingProcessor.writeToSourceFile(MapperRenderingProcessor.java:52) at org.mapstruct.ap.internal.processor.MapperRenderingProcessor.process(MapperRenderingProcessor.java:42) at org.mapstruct.ap.internal.processor.MapperRenderingProcessor.process(MapperRenderingProcessor.java:37) at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:280) at org.mapstruct.ap.MappingProcessor.processMapperTypeElement(MappingProcessor.java:260) at org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:226) at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:162) at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.handleProcessor(RoundDispatcher.java:142) at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:124) at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:174) at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:138) at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:940) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:450) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:386) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:371) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:318) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.incrementalBuildLoop(IncrementalImageBuilder.java:186) at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:143) at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:281) at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:202) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:833) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: javax.annotation.processing.FilerException: Source file already exists : test.mapstruct.TestMapperImpl at org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl.createSourceFile(IdeFilerImpl.java:177) at org.mapstruct.ap.internal.processor.MapperRenderingProcessor.createSourceFile(MapperRenderingProcessor.java:68) ... 33 more
We're using Eclipse 2019-12 and Mapstruct 1.3.1.Final.
Same issue as #43
This seems related to ecj compiler since we have the same issue with intellij when using ecj compiler instead of the javac compiler.
This issue is really annoying since we have to rebuild the whole project each time that we have a new mapping with mapstruct.
The Eclipse download seems offline. There's only a message that says jenkins is hybernated.
Currently we don't have an infrastructure for unit-testing the mapstruct-eclipse plugin. We should change that at some point... ๐
Provide a p2 repository using Maven Tycho.
The following error message:
Can't map property "org.foobar.OtherType prop3" to "org.foobar.SomeType prop3". Consider to declare/implement a mapping method: "org.foobar.SomeType map(org.foobar.OtherType value)".
... could use a quick-fix to either ignore the property, or to add a method with the suggested signature.
for public abstract Target toTarget(Source source)
, it creates this:
public abstract @Mapping(target="foobar", ignore = true) Target toTarget(Source source)
@Mapper#componentModel()
there could be shown the list of supported values@Mapper#config()
there could be shown a filtered list only containing actual config classes@InheritConfiguration#name()
/@InheritInverseConfiguration#name()
there could be shown a filtered list of existing method names@Mapper#dependsOn()
should suggest only properties of the target beanHello,
I am trying to install the plugin for Eclipse and when I try to install, an error message appears saying "No repository found at https://dl.bintray.com/mapstruct/mapstruct-eclipse-site/." This happens when I install with the Eclipse Marketplace and also when Idrag the image to eclipse.
@Mapping#dependsOn()
should suggest only properties of the target bean, excluding the one named in target
of the same annotation.
When hovering with the cursor over or CRTL+clicking certain annotation members, it'd be great to get a) a tooltip with more information (type, full signature) and b) jumping to the declaration of that element:
@Mapping#source()
/ target()
@InheritConfiguration#name()
Hey @larswetzer, WDYT, is it doable?
We definitely should think about to list a more mature version of the MapStruct plug-in on the Eclipse Marketplace.
Currently, only the properties of the class itself are shown, but not those from the super classes.
Much more documentation is needed:
When a bean property getter/setter is refactored, any references in @Mapping#source()
or target()
should be updated as well.
List<Target> toTargetList(List<Source> sources)
Error message: No implementation can be generated for this method. Found no method nor implicit conversion for mapping source element type into target element type.
Quick-Fix to add method:
Target toTarget(Source source)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.