formatqs
formatqs

Reputation: 77

Turn off @Generate annotation in MapStruct

I want to disable @Generate annotation in generated (by mapstruct) classes.

I try args -Amapstruct.suppressGeneratorTimestamp=true and -Amapstruct.suppressGeneratorVersionInfoComment=true, but it's still do not turn off annotation.

In the source code of mapstruct I found class GeneratedType, which has in constructor declare a field generatedTypeAvailable, which affect on a template GeneratedType.ftl:

<#if !generatedTypeAvailable>/*</#if>
@Generated(
    value = "org.mapstruct.ap.MappingProcessor"<#if suppressGeneratorTimestamp == false>,
    date = "${.now?string("yyyy-MM-dd'T'HH:mm:ssZ")}"</#if><#if suppressGeneratorVersionComment == false>,
    comments = "version: ${versionInformation.mapStructVersion}, compiler: ${versionInformation.compiler}, environment: Java ${versionInformation.runtimeVersion} (${versionInformation.runtimeVendor})"</#if>
)<#if !generatedTypeAvailable>
*/</#if>

So, how to set field value generatedTypeAvailable to false ?

Upvotes: 3

Views: 1542

Answers (1)

Filip
Filip

Reputation: 21403

Currently it is not possible to disable the creation of the @Generated annotation. Why do you need to do that?

What you can do is to:

  • Suppress the timestamp value using -Amapstruct.suppressGeneratorTimerstamp=true
  • Suppress the version using -Amapstruct.suppressGeneratorVersionInfoComment

Upvotes: 1

Related Questions