aaschmid / gradle-cpd-plugin

Gradle plugin to find duplicate code using PMDs copy/paste detection (= CPD).
Apache License 2.0
96 stars 12 forks source link

Support for Java Multiline Strings #70

Closed abigailCortis closed 8 months ago

abigailCortis commented 8 months ago

Are java multiline strings supported by the plugin please?

I am currently using Hibernate's @Query annotation with multiline strings such as the below example:

@Query("""
    SELECT 
        column_1,
        column_2
    FROM table
    WHERE column_3 = :=value
""")
Set<Object> findAll(@Param("value") int value);

However this is the error I am getting when running the cpdCheck task:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':cpdCheck'.
> A failure occurred while executing de.aaschmid.gradle.plugins.cpd.internal.worker.CpdAction
   > Lexical error in file <path to java class> at line 21, column 13.  Encountered: "\n" (10), after : "\""

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org
aaschmid commented 8 months ago

I guess this is a question for CPD itself which this plugin is just wrapping, see https://pmd.github.io/pmd/pmd_userdocs_cpd. If there are any new properties required to be set, this would be part of this plugin to make these available. However, I only see ignoreUsings for C# which this plugin doesn't support, yet.

abigailCortis commented 8 months ago

Thanks, I think I will use the ignoreAnnotations instead.