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

Different Builders compilation result in IDEA and gradle #1852

Closed
Guchman opened this issue Jul 30, 2019 · 2 comments
Closed

Different Builders compilation result in IDEA and gradle #1852

Guchman opened this issue Jul 30, 2019 · 2 comments

Comments

@Guchman
Copy link

Guchman commented Jul 30, 2019

I have class

@Getter
@EqualsAndHashCode
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Account {
    @NotEmpty
    private String id;
    private LocalDate dateOpened;
    private LocalDate dateClosed;
}

@Mapper(componentModel = "spring",
        nullValueCheckStrategy = ALWAYS)
@NoArgsConstructor
public abstract class AccountDataConverter {

    @Mapping(target = "dateOpened", dateFormat = "yyyy-MM-dd")
    @Mapping(target = "dateClosed", dateFormat = "yyyy-MM-dd")
    public abstract Account convert(AccountData accountData);
}

@Data
public class AccountData {
    @Id
    private String id;
    private String dateOpened;
    private String dateClosed;
}

When I run build with gradle 5.4.1-5.5.1 it's fails with:
Property "dateClosed" has no write accessor
Property "dateOpened" has no write accessor

But when I run buidl through IDEA converter compiles well:

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2019-07-30T11:32:12+0300",
    comments = "version: 1.3.0.Final, compiler: javac, environment: Java 12.0.1 (AdoptOpenJDK)"
)
@Component
public class AccountDataConverterImpl extends AccountDataConverter {

    @Override
    public Account convert(AccountData accountData) {
        if ( accountData == null ) {
            return null;
        }
        AccountBuilder account = Account.builder();
        if ( accountData.getId() != null ) {
            account.id( accountData.getId() );
        }       
        if ( accountData.getDateOpened() != null ) {
            account.dateOpened( LocalDate.parse( accountData.getDateOpened(), DateTimeFormatter.ofPattern( "yyyy-MM-dd" ) ) );
        }
        if ( accountData.getDateClosed() != null ) {
            account.dateClosed( LocalDate.parse( accountData.getDateClosed(), DateTimeFormatter.ofPattern( "yyyy-MM-dd" ) ) );
        }

Mapstruct 1.3.0.Final
lombok 1.18.8
gradle 5.4.1-5.5.1

Update 1:
Also @setters on the fields fixes build, but compilation result is same as in the gradle case without @setters. Weird

@Guchman Guchman closed this as completed Jul 30, 2019
@Guchman Guchman reopened this Jul 30, 2019
@filiphr
Copy link
Member

filiphr commented Jul 31, 2019

@Guchman I think that this is the same as #1581 and is caused by projectlombok/lombok#1538.

@filiphr
Copy link
Member

filiphr commented Aug 18, 2019

Closing it in favour of #1581. If it is different then we can reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants