diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/common/DateFormatValidatorFactory.java b/processor/src/main/java/org/mapstruct/ap/internal/model/common/DateFormatValidatorFactory.java index dddd6d685..cee6a1987 100755 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/common/DateFormatValidatorFactory.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/common/DateFormatValidatorFactory.java @@ -154,6 +154,9 @@ final class DateFormatValidatorFactory { catch ( InvocationTargetException e ) { return invalidDateFormat( dateFormat, e.getCause() ); } + catch ( ClassNotFoundException e ) { + return noJodaOnClassPath(); + } catch ( Exception e ) { return invalidDateFormat( dateFormat, e ); } @@ -185,4 +188,8 @@ final class DateFormatValidatorFactory { private static DateFormatValidationResult invalidDateFormat(String dateFormat, Throwable e) { return new DateFormatValidationResult( false, Message.GENERAL_INVALID_DATE, dateFormat, e.getMessage() ); } + + private static DateFormatValidationResult noJodaOnClassPath() { + return new DateFormatValidationResult( false, Message.GENERAL_JODA_NOT_ON_CLASSPATH ); + } } diff --git a/processor/src/main/java/org/mapstruct/ap/internal/util/Message.java b/processor/src/main/java/org/mapstruct/ap/internal/util/Message.java index 4d7d629fb..3a65e30ce 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/util/Message.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/util/Message.java @@ -95,6 +95,7 @@ public enum Message { GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK( "No dateFormat check is supported for types %s, %s" ), GENERAL_VALID_DATE( "Given date format \"%s\" is valid.", Diagnostic.Kind.NOTE ), GENERAL_INVALID_DATE( "Given date format \"%s\" is invalid. Message: \"%s\"." ), + GENERAL_JODA_NOT_ON_CLASSPATH( "Cannot validate Joda dateformat, no Joda on classpath. Consider adding Joda to the annotation processorpath.", Diagnostic.Kind.WARNING ), GENERAL_NOT_ALL_FORGED_CREATED( "Internal Error in creation of Forged Methods, it was expected all Forged Methods to finished with creation, but %s did not" ), GENERAL_NO_SUITABLE_CONSTRUCTOR( "%s does not have an accessible parameterless constructor." ),